開啟mysql遠端登入

2021-08-02 20:46:57 字數 977 閱讀 8871

開啟mysql遠端登入:

##第一步:開個使用者,設定密碼,給其遠端登入的許可權。

在資料庫所在的伺服器上面進入mysql,我的是mariadb,命令操作是一樣的,就是重啟服務命令不太一樣。

mariadb [(none)]> grant all privileges on *.* to 'yangshuiping'@'%' identified by '123456' with grant option;

query ok, 0 rows affected (0.00 sec)

mariadb [(none)]> flush privileges;

query ok, 0 rows affected (0.00 sec)

這就設定了yangshuiping這個使用者可以在任何機器上用123456這個密碼鏈結這台伺服器上的mysql資料庫。

##第二步:開啟伺服器3306埠對外訪問;

firewall-cmd --zone=public --add-port=3306/tcp --permanent
##第三步:重啟防火牆,我的是centos7,所以防火牆用的是firewalld;

systemctl stop firewalld.service

systemctl start firewalld.service

##第四步:測試一下,看看是不是真的可以了。

看到了沒,已經可以了!

拓展:

grant all privileges on *.* to 'yangshuiping'@'%'identified by '123456' with grant option;

開啟mysql遠端登入

開發過程中經常遇到遠端訪問mysql的問題,每次都需要搜尋,感覺太麻煩,這裡記錄下,也方便我以後查閱。首先訪問本機的mysql 用ssh登入終端,輸入如下命令 mysql uroot p 輸入密碼登陸進去後,輸入如下的語句 use mysql grant allprivileges on to us...

開啟mysql遠端登入

開發過程中經常遇到遠端訪問mysql的問題,每次都需要搜尋,感覺太麻煩,這裡記錄下,也方便我以後查閱。首先訪問本機的mysql 用ssh登入終端,輸入如下命令 mysql uroot p 輸入密碼登陸進去後,輸入如下的語句 use mysql grant allprivileges on to us...

開啟Mysql遠端登入賬號

1.確定伺服器上的防火牆沒有阻止 3306 埠。2.增加允許遠端連線 mysql 使用者並授權。grant all privileges on to root identified by localhost flush privileges 上面的語句表示將 discuz 資料庫的所有許可權授權給 ...