做個記錄,每次弄環境的時候,特別是弄mysql環境,時不時都要用到下面的命令
命令如下:
grant all privileges on *.* to 'root'@'%' identified by 'oa123456' with grant option; flush privileges; quit;
注意:
上面的命令原型如下:
grant all privileges on *.* to 'username'@'%' identified by 'password' with grant option;
命令中的“%”相當於授權任意主機。
另外還有就是通常授權用戶遠程連接,還需要修改配置文件,以Ubuntu16.04為例,需要修改mysqld.cnf配置文件,將里面的bind=127.0.0.1注釋掉即可
然后重啟一下mysql服務,這時你就可以通過sqlyong或navicat連接mysql服務。