最新消息:本站技术交流 QQ 群:28124927

mysql新建用户和授权登录

数据库 exchen 5069浏览

create user 'testuser'@'localhost' identified BY 'testpass'; //新建用户
grant all privileges on blog.* to testuser@localhost identified by 'testpass'; //授权用户登录blog数据库
grant all privileges on *.* to testuser@"%" identified by "testpass"; //授权用户能远程连接mysql
grant all privileges on *.* to root@"%" identified by "123456"; //允许 root 用户登录
set password for 'root'@'localhost' = password('newpass'); //设置root密码
flush privileges;

mysqladmin -u root -p flush-tables // 解决table read only
-----------------------------------------------------------------------------------------
如果连接不上,请注意设置iptables放行端口

转载请注明:exchen's blog » mysql新建用户和授权登录