create user zhang3 identified by '123123';
表示创建名称为zhang3的用户,密码设为123123;
select * from mysql.user; 以列的方式显示数据
select host,user,authentication_string,select_priv,insert_priv,drop_priv from mysql.user;
select_priv(查询) insert_priv(插入) drop_priv(删除)
host : 表示连接类型
user : 表示用户名
password : 密码
select_priv , insert_priv等
修改当前用户的密码:
set password =password('123456')
修改某个用户的密码:
必须使用root 用户
update mysql.user set authentication_string=password('111111') where user='zhang3';
所有通过user表的修改,必须用该命令才能生效。
flush privileges;
drop user zhang3 ; 推荐使用!
不要通过delete from user where user=‘zhang3’ 进行删除,系统会有残留信息保留。
grant select,insert,delete,update on donglindb.* to li4@localhost identified by ‘123123’;
2.给li4用户用本地命令行方式下,授予donglindb这个库下的所有表的插删改查的权限。(常用)
grant all privileges on * . * to joe@'%' identified by '123123';
3.授予通过网络方式登录的joe用户 ,对所有库所有表的全部权限,密码设为123123.
REVOKE ALL PRIVILEGES ON *.* FROM joe@'%';
3.收回mysql库下的所有表的插删改查权限
REVOKE select,insert,update,delete ON * . * FROM joe@'%';
须用户重新登录后才能生效
查看当前用户权限
show grants;
查看某用户的全局权限
select * from mysql.user ;
grant all privileges on *.* to root@'%' identified by 'root';
ping 192.168.121.140
systemctl start firewalld.service
systemctl status firewalld.service
systemctl stop firewalld.service
systemctl enable firewalld.service
systemctl disable firewalld.service
查看开放的端口号
firewall-cmd --list-all
设置开放的端口号 生成环境!
firewall-cmd --add-service=http --permanent
firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --add-port=3306/tcp --permanent
重启防火墙
firewall-cmd --reload
select * from mysql.user where user='root' and host='%';
grant all privileges on *.* to root@'%' identified by 'root';