Linux系統下實現遠端連線MySQL資料庫的方法教程

來源:互聯網
上載者:User

標籤:des   maria   replace   install   size   uil   通過   nload   lin   

1、在伺服器端開啟遠端存取
首先進入mysql資料庫,然後輸入下面兩個命令:

grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘password‘;
flush privileges;
第一個*是資料庫,可以改成允許訪問的資料庫名稱
第二個 是資料庫的表名稱,代表允許訪問任意的表
root代表遠程登入使用的使用者名稱,可以自訂
%代表允許任意ip登入,如果你想指定特定的IP,可以把%替換掉就可以了
password代表遠程登入時使用的密碼,可以自訂
flush privileges;這是讓許可權立即生效
2、修改my.cnf設定檔
這個是mysql的設定檔,如果你無標題文章找不到在哪裡的話,可以輸入find /* -name my.cnf 找到

通過vim編輯該檔案,找到bind-address    = 127.0.0.1這一句,然後在前面加個#號注釋掉,儲存退出

3、重啟服務

service mysql restart
4、在本地遠端連線
在終端輸入:

mysql -h 伺服器ip地址 -P 3306 -u root -p
然後輸入密碼即可。
root是第1點設定的使用者名稱,密碼也是第1點設定的密碼

Install 3 Packages (+2 Dependent packages)
Total download size: 171 M
Downloading packages:
mysql-community-server-5.7.10-1.el7.x86_64.rpm | 142 MB 00:03:42
mysql-community-libs-compat-5.7.10-1.el7.x86_64.rpm | 2.0 MB 00:00:03
mysql-community-libs-5.7.10-1.el7.x86_64.rpm | 2.2 MB 00:00:05
mysql-community-client-5.7.10-1.el7.x86_64.rpm | 24 MB 00:00:41
warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.10-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY00 ETA
Public key for mysql-community-common-5.7.10-1.el7.x86_64.rpm is not installed
mysql-community-common-5.7.10-1.el7.x86_64.rpm | 269 kB 00:00:01
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
Userid : "MySQL Release Engineering <[email protected]>"
Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
Package : mysql57-community-release-el7-7.noarch (@/mysql57-community-release-el7-7.noarch)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mysql-community-common-5.7.10-1.el7.x86_64 1/6
Installing : mysql-community-libs-5.7.10-1.el7.x86_64 2/6
Installing : mysql-community-client-5.7.10-1.el7.x86_64 3/6
Installing : mysql-community-server-5.7.10-1.el7.x86_64 4/6
Installing : mysql-community-libs-compat-5.7.10-1.el7.x86_64 5/6
Erasing : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64 6/6
Verifying : mysql-community-server-5.7.10-1.el7.x86_64 1/6
Verifying : mysql-community-libs-compat-5.7.10-1.el7.x86_64 2/6
Verifying : mysql-community-common-5.7.10-1.el7.x86_64 3/6
Verifying : mysql-community-libs-5.7.10-1.el7.x86_64 4/6
Verifying : mysql-community-client-5.7.10-1.el7.x86_64 5/6
Verifying : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64 6/6
Installed:
mysql-community-libs.x86_64 0:5.7.10-1.el7 mysql-community-libs-compat.x86_64 0:5.7.10-1.el7 mysql-community-server.x86_64 0:5.7.10-1.el7
Dependency Installed:
mysql-community-client.x86_64 0:5.7.10-1.el7 mysql-community-common.x86_64 0:5.7.10-1.el7
Replaced:
mariadb-libs.x86_64 1:5.5.44-2.el7.centos
Complete!
[[email protected] ~]# clear

Linux系統下實現遠端連線MySQL資料庫的方法教程

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.