转Mysql远程链接
1、进入mysql,创建一个新用户root,密码为root:
格式:grant 权限 on 数据库名.表名 to 用户@登录主机 identified by "用户密码";
grant select,update,insert,delete on *.* to root@192.168.1.12 identified by "root";
原先数据表结构
mysql> use mysql;
Database changed
mysql> select host,user,password from user;
+-----------+------+-------------------------------------------+
| host | user | password |
+-----------+------+-------------------------------------------+
| localhost | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+-----------+------+-------------------------------------------+
执行上述语句后结果
mysql> use mysql;
Database changed
mysql> select host,user,password from user;
+--------------+------+-------------------------------------------+
| host | user | password |
+--------------+------+-------------------------------------------+
| localhost | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| 192.168.1.12 | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+--------------+------+-------------------------------------------+
2 rows in set (0.00 sec)
the article below is more useful !
How Do I Enable Remote Access To MySQL Database Server?
by Vivek Gite on March 31, 2006 · 103 comments
By default remote access to MySQL database server is disabled for security reasons. However, some time you need to provide remote access to database server from home or a web server.
MySQL Remote Access
You need type the following commands which will allow remote connections.
Step # 1: Login Using SSH (if server is outside your data center)
First, login over ssh to remote MySQL database server:
ssh user@mysql.nixcraft.i
Step # 2: Edit my.cnf File
Once connected you need to edit the MySQL server configuration file my.cnf using a text editor such as vi.
* If you are using Debian Linux file is located at /etc/mysql/my.cnf location
* If you are using Red Hat Linux/Fedora/Centos Linux file is located at /etc/my.cnf location
* If you are using FreeBSD you need to create a file /var/db/mysql/my.cnf
Edit /etc/my.cnf, run:
# vi /etc/my.cnf
Step # 3: Once file opened, locate line that read as follows
[mysqld]
Make sure line skip-networking is commented (or remove line) and add following line
bind-address=YOUR-SERVER-IP
For example, if your MySQL server IP is 65.55.55.2 then entire block should be look like as follows:
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port