在mysql的user表中存储了MySQL的用户信息
主要字段:mysql
desc user; # 查看用户信息
# root帐户登陆 mysql -uroot -p # 经常使用权限列表:create、alter、drop、insert、update、delete、select 若是分配全部权限,能够使用all privileges # 访问主机一般使用:百分号%,表示此帐户能够使用任何ip的主机登陆访问此数据库 # 访问主机能够设置成 localhost或具体的ip,表示只容许本机或特定主机访问 grant 权限名称 on 数据库 to '用户名'@'访问主机' identified by '密码'; # 查看用户有哪些权限 show grants for laowang@localhost; # 退出root登陆 quit
grant 权限名称 on 数据库 to 帐户@主机 with grant option;
update user set authentication_string=password('新密码') where user='用户名'; flush privileges; # 刷新权限
# 方法一 drop user '用户名'@'主机'; # 方法二 delete from user where user='用户名'; flush privileges
vim /etc/mysql/mysql.conf.d/mysqld.cnf bind-address = 0.0.0.0 service mysql restart # 重启