Mysql資料庫的遠端訪問設定

life4711發表於2016-11-29

本篇文章意在糾正網上很多錯誤的部落格,下面是正確的方法:

以下操作使用root許可權

1、編輯mysql配置檔案,註釋掉“bind-address = 127.0.0.1”
    root@ubuntu:~# vim /etc/mysql/mysql.conf.d/mysqld.cnf
    #bind-address = 127.0.0.1


2、賦許可權:
    root@ubuntu:~# mysql -u root -proot 
    use database mysql;
    grant all privileges on *.* to 'username'@’%’ identified by ‘password’ with grand option;
    或者 grant all privileges on *.* to 'username'@’192.168.%.%’ identified by ‘password’ with grand option;
    或者 grant all privileges on *.* to 'username'@’192.168.1.99’ identified by ‘password’ with grand option;

3、重啟mysql
    root@ubuntu:~# /etc/init.d/mysql restart 

注:遠端訪問資料庫的圖形介面軟體推薦使用:HeidiSQL

相關文章