授權遠端連線MySQL(Linux)

2021-09-07 13:40:51 字數 789 閱讀 3404

mysql遠端訪問的命令 格式: mysql -h主機位址 -uusername -p使用者password

首先在目標伺服器上(115.159.66.51)改動mysql的my.cnf檔案:

改動退出後,重新啟動mysql服務 命令:sudo service mysql restart

此時嘗試用115.159.66.51主機來連線mysql

ubuntu@vm-194-212-ubuntu:/etc/mysql$ mysql -h115.159.66.51 -uroot -pxiongchao

此時會出現無法連線的錯誤

原因:沒有對遠端主機115.159.66.51賦予訪問mysql server的許可權

賦予主機主機115.159.66.51以root的身份訪問資料許可權(注:訪問haibao資料庫):

grant all privileges on haibao.* to 『root』@』115.159.66.51』 identified by 『xiongchao』 with grant option;

賦予不論什麼主機以root的身份訪問資料許可權(注:訪問haibao資料庫):

grant all privileges on haibao.* to 『root』@』%』 identified by 『xiongchao』 with grant option;

改動生效:

flush privileges;

mysql遠端連線授權

mysql is not allowed to connect to this mysql server 如果你想連線你的mysql的時候發生這個錯誤 error 1130 host 192.168.1.3 is not allowed to connect to this mysql server...

遠端使用者連線mysql授權

mysql 授權法 在安裝mysql的機器上執行 1 d mysql bin mysql h localhost u root 這樣應該可以進入mysql伺服器 2 mysql grant all privileges on to root with grant option 賦予任何主機訪問資料的...

遠端使用者連線mysql授權

在安裝mysql的機器上執行 1 mysql u myuser p xx 進入mysql伺服器 2 mysql grant all privileges on to root with grant option 賦予任何主機訪問資料的許可權 例如,你想myuser使用mypassword從任何主機連...