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; #刷新權限表,使配置生效