Mysql数据库账户权限设置

1.修改mysql数据库的root密码:

修改 数据库.表名 SET password=加密(密码) where user=’root’;

UPDATE mysql.user SET password = PASSWORD('123') WHERE user='root'; flush PRIVILEGES;

备注: flush PRIVILEGES; 表示:刷新数据表,不添加,修改sql语句不会立即生效

2.添加mysql数据库的访问用户  用户名:cmstop 密码:自定义 (多服务器部署时添加前台的内网ip作为访问mysqluser中的host字段,可以防止外网的访问)

GRANT ALL PRIVILEGES ON testdb.* TO 'testuser'@'localhost' IDENTIFIED BY '123'; flush PRIVILEGES;

GRANT ALL PRIVILEGES ON testdb.* TO 'testuser'@'127.0.0.1' IDENTIFIED BY '123'; flush PRIVILEGES;

GRANT ALL PRIVILEGES ON testdb.* TO 'testuser'@'%' IDENTIFIED BY '123'; flush PRIVILEGES;

3.设置只读权限

GRANT SELECT ON testdb.* TO 'testuser'@'192.168.0.%' IDENTIFIED BY '123'; flush PRIVILEGES;

posted on 2018-03-07 10:53  天涯尘星  阅读(236)  评论(0编辑  收藏  举报

导航