開啟遠端連線問題

2021-08-08 20:29:52 字數 1913 閱讀 7696

第一步:

修改 /etc/mysql/my.conf  bind-address的配置, 修改前為:bind-address = 127.0.0.1

願意是mysql為了資料安全只允許本機進行范文,現在想要使得遠端的機器能夠訪問mysql資料庫服務,就可以通過改bind-address來實現, 具體的修改方式有兩種:

1. bind-address = 0.0.0.0

解釋:0.0.0.0為windows對所有未知ip的位址描述,包括網絡卡dhcp的取得的位址、pppoe的ip,及其它非本機指定ip.

0.0.0.0是全零網路,代表預設網路,幫助路由器傳送路由表中無法查詢的包。如果設定了全零網路的路由,路由表中無法查詢的包都將送到全零網路的路由中去。

2. 直接把bind-address這一行注釋掉 #

bind-address = 127.0.0.1

3. /etc/init.d/mysql restart //重新啟動mysql服務

第二步:授權使用者遠端訪問

1. /etc/init.d/mysql stop (停止mysql執行)

2. mysqld_safe --user=mysql --skip-grant-tables --skip-networking &  (以非認證模式啟動mysql服務)

3. mysql -u root -p mysql  (登入mysql)

4. 提示輸入密碼,此時回車就可以了,也就是使用空密碼

5. grant all on *.* to 'root'@'%' identified by 'your password here

' with grant option;  (此處是授權從任何機器

使用root使用者訪問mysql資料庫)

需要注意的是5 畫刪除線滴地方,這裡是你mysql root的密碼,前提是你用root賬戶連你的mysql,如果此處出錯的話,你將收到以下錯誤。

error 1290 (hy000): the mysql server is running with the --skip-grant-tables option so it cannot execute this statement

6. quit;

7.  /etc/init.d/mysql restart   //重新啟動mysql服務

經過這兩個步驟,mysql伺服器,就可以從遠端訪問了。

root 密碼為空的時候配置檔案中下面這句:

skip-grant-tables

grant all privileges on *.* to identified by '123' with grant option;

執行這句時候錯誤:

error 1290 (hy000): the mysql serverisrunning with the --skip-grant-tables option so it cannot executethisstatement

mysql> grant all privileges on *.* to identified by'123'with grant option;

error 1290 (hy000): the mysql serverisrunning with the --skip-grant-tables option so it cannot executethisstatement

這個時候我們只需要

flush privileges

一下,在新增使用者就ok了

mysql開啟遠端 mysql 開啟遠端連線

1045,access denied for user root 192.168.100.1 using password yes 開啟資料庫遠端連線即可 1 先在本機使用root使用者登入mysql,然後進行授權。mysql grant all privileges on to root iden...

開啟mysql遠端連線

首先新增使用者 當然也可是使用root使用者 格式 grant 許可權 on 資料庫名.表名 使用者 登入主機 identified by 使用者密碼 grant select,update,insert,delete on to zhxia identified by 123456 或者所有許可權...

開啟mysql遠端連線

在mysql控制台執行 grant all privileges on to root identified by mypassword with grant option 在mysql控制台執行命令中的 root 可以這樣理解 root是使用者名稱,是主機名或ip位址,這裡的 代表任意主機或ip位...