溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

使用oneinstack安裝mysql設(shè)置遠(yuǎn)程連接教程簡析

發(fā)布時間:2020-04-30 11:13:56 來源:億速云 閱讀:356 作者:三月 欄目:MySQL數(shù)據(jù)庫

本文主要給大家介紹使用oneinstack安裝mysql設(shè)置遠(yuǎn)程連接教程簡析,文章內(nèi)容都是筆者用心摘選和編輯的,使用oneinstack安裝mysql設(shè)置遠(yuǎn)程連接教程簡析具有一定的針對性,對大家的參考意義還是比較大的,下面跟筆者一起了解下主題內(nèi)容吧。

oneinstack網(wǎng)站:

oneinstack.com


== 下面分mysql8版本和其他版本,兩種情況不同。

1.云主機安全組端口開放3306端口

參考文檔:《云主機安全組端口開放教程

2. 打開iptables 3306端口

如果您的操作系統(tǒng)為CentOS系列:

iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
service iptables save #保存iptables規(guī)則

使用oneinstack安裝mysql設(shè)置遠(yuǎn)程連接教程簡析

3. 數(shù)據(jù)庫授權(quán)

注意??:遠(yuǎn)程連接新建一個帳號(帳號名不能為root)。
如:添加一個用戶名為db_user,密碼為db_pass,授權(quán)為% (%表示所有IP能連接)對db_name數(shù)據(jù)庫所有權(quán)限,命令如下:

1)MySQL8.0版本
# mysql -uroot -p
MySQL [(none)]> create user db_user@'%' identified by 'db_pass'; #創(chuàng)建用戶
MySQL [(none)]> grant all privileges on db_name.* to db_user@'%' with grant option; #授權(quán)
MySQL [(none)]> exit; #退出數(shù)據(jù)庫控制臺,特別注意有分號



其他數(shù)據(jù)庫版本:


# mysql -uroot -p
 MySQL [(none)]> grant all privileges on db_name.* to db_user@'%' identified by 'db_pass'; #授權(quán)語句,特別注意有分號
 MySQL [(none)]> flush privileges;
 MySQL [(none)]> exit; #退出數(shù)據(jù)庫控制臺,特別注意有分號


總結(jié):


1.iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT

2.service iptables save

3.mysql -uroot -p

4.grant all privileges on *.* to sunny@'%' identified by '123456';

5.flush privileges;

6.exit;



解釋如下:

  1. 打開iptables 3306  端口。

  2. 保存iptables規(guī)則

  3. 數(shù)據(jù)庫授權(quán)給新用戶sunny,密碼為123456,授權(quán)%表示,所有ip能連接,對所有數(shù)據(jù)庫*.*具有權(quán)限。

  4. 刷新設(shè)置

  5. 退出


如果僅分配某數(shù)據(jù)庫,比如oneinstack數(shù)據(jù)庫,則*.*改為oneinstack.*


如果安裝完成后,

[root@bogon ~]# mysql -uroot -p
bash: mysql: command not found

[root@bogon bin]# cd ~
[root@bogon ~]# vim .bash_profile

加一句:

export PATH=$PATH:/usr/local/mysql/bin

然后使之生效:

[root@bogon ~]# source .bash_profile


看完以上關(guān)于使用oneinstack安裝mysql設(shè)置遠(yuǎn)程連接教程簡析,很多讀者朋友肯定多少有一定的了解,如需獲取更多的行業(yè)知識信息 ,可以持續(xù)關(guān)注我們的行業(yè)資訊欄目的。

 

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI