共计 969 个字符,预计需要花费 3 分钟才能阅读完成。
MySQL 创建新用户
CREATE USER ‘newuser’@’localhost’ IDENTIFIED BY ‘password’;
赋予操作权限:
GRANT ALL PRIVILEGES ON database_name.table_name TO‘username’@’localhost’;
GRANT ALL PRIVILEGES ON database_name.* TO‘username’@’localhost’;
删除用户:
DROP USER‘username’@‘localhost’;
刷新权限:
FLUSH PRIVILEGES;
显示所有用户:
mysql> SELECT user, host FROM mysql.user;
+——————+———–+
| user | host |
+——————+———–+
| debian-sys-maint | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| phpmyadmin | localhost |
| root | localhost |
+——————+———–+
显示一个用户的权限:
mysql> SHOW GRANTS FOR ‘root’@’localhost’;
+———————————————————————+
| Grants for root@localhost |
+———————————————————————+
| GRANT ALL PRIVILEGES ON *.* TO ‘root’@’localhost’ WITH GRANT OPTION |
| GRANT PROXY ON ”@” TO ‘root’@’localhost’ WITH GRANT OPTION |
+———————————————————————+
: