Blame
| f50577 | Terry | 2025-11-27 08:34:57 | 1 | # 常用Mysql操作命令 |
| 2 | ||||
| 3 | --- |
|||
| 4 | ||||
| 5 | 1. 创建用户 |
|||
| 6 | ||||
| 7 | ```bash |
|||
| 8 | CREATE USER 'admin'@'%' IDENTIFIED BY '9piSt@J8BXoc6'; |
|||
| 9 | ``` |
|||
| 10 | ||||
| 11 | - 'admin'@'%'为 需要创建的用户名 |
|||
| 12 | - '9piSt@J8BXoc6' ,''内为设置的密码 |
|||
| 13 | ||||
| 14 | 2. 为用户 获取 数据库权限 |
|||
| 15 | ||||
| 16 | ```bash |
|||
| 17 | GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%'; |
|||
| 18 | ``` |
|||
| 19 | ||||
| 20 | - *.为 所有数据库的所有表 |
|||
| 21 | - admin 为上面创建的用户名 |
|||
| 22 | ||||
| 23 | 3. 刷新权限 |
|||
| 24 | ||||
| 25 | ```bash |
|||
| 26 | FLUSH PRIVILEGES; |
|||
| 27 | ``` |
|||
| 28 | ||||
| 29 | 4. 创建数据库 |
|||
| 30 | ||||
| 31 | ```bash |
|||
| 32 | CREATE DATABASE IF NOT EXISTS `test`; |
|||
| 33 | ``` |