我的Mysql環境是ubuntu+MySQL5
1.修改/etc/MySQL/my.conf,修改bind-address,指定為本機實際IP地址,你的my.con修改完大概是如下的樣子
[MySQLd]
#
# * Basic Settings
#
default-character-set=utf8
default-storage-engine=INNODB
bind-address = 192.168.1.107
user = MySQL
pid-file = /var/run/mysqld/MySQLd.pid
socket = /var/run/mysqld/MySQLd.sock
port = 3306
basedir = /usr
datadir = /var/lib/MySQL
tmpdir = /tmp
language = /usr/share/MySQL/english
skip-external-locking
2.用root登陸MySQL執行如下命令
grant all on sonardb.* to sonar@'%' identifIEd by '123456';
grant all on sonardb.* to sonar@localhost identifIEd by '123456';
sonardb替換為你想訪問的數據庫名,sonar是你的想使用的用戶名,123456替換為你的密碼,這樣就開啟了遠程訪問功能.