mysql -uroot -p
输入密码;
显示所有数据库
show databases;
选择库mysql
use mysql;
查看所有用户
select * from userG;
创建新用户
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 userG;
Host:标识可访问的IP地址,新用户 可配置为 “%” 表示所以ip都可以访问到
查看mysql 开放端口
show global variables like 'port';