MySQL的一些经常使用命令

mysql -u root -h localhost -p #登陆

use mysql; #打开mysql数据库

select host,user from user where user='root'; #查看user表里的root数据

update user set host='%' where user='root' and host='localhost'; #将host设置为%表示任何ip都能链接mysql,也能够将host指定为某个ip

update user set host='localhost' where user='root’; #关闭远程链接,从新设置为localhost

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; #给root进行受权

flush privileges;  #刷新权限表,使配置生效
相关文章
相关标签/搜索