织梦CMS - 轻松建站从此开始!

罗索

Allow remote connections to your MySQL server

jackyhwei 发布于 2011-02-28 09:21 点击:次 
You will need access to the MySQL administrators password as well as administrative access so you can edit a MySQL configuration file. Other than that simple necessity (and a terminal window), you are ready to get cracking.
TAG:

Before we begin

You will be glad to know, assuming you have MySQL up and running, there is no installation necessary for this task. You will need access to the MySQL administrators password as well as administrative access so you can edit a MySQL configuration file. Other than that simple necessity (and a terminal window), you are ready to get cracking.

Editing my.conf
Before you actually start editing the /etc/mysql/my.conf file, I would suggest you back up your current file. Do this with the command:
sudo cp /etc/mysql/my.conf /etc/mysql/my.conf.bak

Now that the file is backed up let’s open this baby up for editing. When you have the file open you are going to want to look for this line:

bind-address = 127.0.0.1
What the above line does is limit connections to the localhost and only the localhost. You want to comment this line out by changing it to:
#bind-address = 127.0.0.1
Now save that file and restart MySQL with the command:
sudo /etc/init.d/mysql restart
When MySQL has restarted you now need to get to the MySQL command prompt.
The mysql prompt
In order to get to the mysql prompt you will want to issue the command:
mysql -u root -p
Where root is the MySQL administrative user (most like it is root).

You will be prompted for the MySQL administrators password. After you have successfully authenticated you will have a new prompt that looks like:

mysql>
You are now at the MySQL prompt. You only have one command to enter for this to work. You will want to enter this command carefully:
GRANT ALL PRIVILEGES ON *.* TO username@address IDENTIFIED BY “password”;
Where username is the username on the remote machine that will be connecting, address is the IP address of the remote machine, and password is the password that will be used by the remote user.
When that command is issued successfully you should see something like:
Query OK, 0 rows affected (0.00 sec)
As long as you get Query OK, you should be good to go.

Now when you need to connect from a remote machine you will use the IP address of the MySQL server, the username you entered in the MySQL command prompt, and the username will be the username you entered in the MySQL command prompt.

That’s it. Your MySQL server is ready to accept remote connections.
Final thoughts
It should go without saying that you will also want to make sure this MySQL server is protected with a good firewall
 
(warking_xp)
本站文章除注明转载外,均为本站原创或编译欢迎任何形式的转载,但请务必注明出处,尊重他人劳动,同学习共成长。转载请注明:文章转载自:罗索实验室 [http://www.rosoo.net/a/201102/10975.html]
本文出处:blog.163.com/warking_xp 作者:warking_xp
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
将本文分享到微信
织梦二维码生成器
推荐内容