mysql 設置遠程連接

機器用的debian 7.wheezy系統。其他系統就不寫了。過程一樣。centos與redhat 部分安裝完程序命令部分爲mysqld

source.list設置部分前面有說。就不說了。

sudo apitude mysql-server;sudo apitude mysql-client;


安裝過程中會要求輸入密碼。輸入root


安裝完成以後。

修改配置文件,去掉綁定代碼

vim /etc/mysql/my.conf

#bind_address = 127.0.0.1


下一步。連接本地mysql登錄。

mysql -h localhost -u root -proot

注意這裏-proot是 緊靠在一起的。root爲密碼。

不出意外會提示

mysql>命令行。說明登錄成功。

新建1個用戶.

create user watsy identified by 'hellomysql';

新建1個數據庫

create database hellomysqldb;


設置用戶訪問權限

grant all privileges on *.* to watsy@'localhost' identified by 'hellomysql' with grant option; 
grant all privileges on `hellomysqldb`.* to watsy@'%' identified by 'hellomysql' with grant option;
flush privileges;

執行完以後退出mysql

exit

重啓mysql數據庫

sudo /etc/init.d/mysql restart

遠程執行

mysql -h remoteip -u watsy -phellomysql

不出意外,可以登錄了。


以上代碼爲記憶寫岀。有問題歡迎留言。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章