mysql5.6容許遠程服務器訪問數據庫

因爲開發須要,有時咱們須要可以遠程訪問連接數據庫。默認mysql設置關閉了遠程訪問。咱們能夠經過修改設置來達到目的mysql

$ cd /etc/mysql
$ sudo vim my.cnf

在文件中將bind-address = 127.0.0.1註釋掉(即在行首加#)
舊版本的MySQL(從一些資料上顯示是5.0及其之前的版本)上使用的是skip-networking。
建立一個mysql用戶,並設置能夠遠程訪問sql

grant usage on *.* to 'fred'@'localhost' identified by 'fred';//建立用戶fred密碼ferd
    select host,user,password from mysql.user where user='fred';//查看記錄  
    grant all privileges on *.* to fred@'%'identified by 'fred';//設置能夠遠程訪問

建立一個mysql用戶,並設置能夠遠程訪問

grant usage on *.* to 'fred'@'localhost' identified by 'fred';//建立用戶fred密碼ferd
select host,user,password from mysql.user where user='fred';//查看記錄  
grant all privileges on *.* to fred@'%'identified by 'fred';//設置能夠遠程訪問
相關文章
相關標籤/搜索