mysql 添加新用户 赋予权限

mysql -uroot -p

输入密码;

显示所有数据库

show databases;

选择库mysql

use mysql; 

查看所有用户

select * from user\G;

 

创建新用户

grant all privileges on *.* to '用户名'@'可登录主机' identified by '密码' with grant option;

grant all privileges on *.* to 'test'@'%' identified by 'root' with grant option;

 

赋予新用户权限:

grant select,insert,update,delete on *.* to '用户名'@'可登录主机' identified by "密码";

例:

grant select,insert,update,delete on *.* to 'test'@'%' identified by "root";

刷新权限表

flush privileges;

 

查看所有用户

select * from user\G;

Host:标识可访问的IP地址,新用户 可配置为 “%” 表示所以ip都可以访问到

查看mysql 开放端口

show global variables like 'port';

 

posted @ 2017-02-14 12:45  暮色听雨声  阅读(263)  评论(0编辑  收藏  举报