linuxsir首页 LinuxSir.Org | Linux、BSD、Solaris、Unix | 开源传万世,因有我参与欢迎您!
网站首页 | 设为首页 | 加入收藏
您所在的位置:主页 > Linux数据库 >

MySQL 创建用户及权限的操作命令

时间:2019-01-28  来源:未知  作者:admin666

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        |
+---------------------------------------------------------------------+

Linux公社的RSS地址:https://www.linuxidc.com/rssFeed.aspx

友情链接