Mysql 开启远程连接

#mysql -uroot -p

输入密码进入mysql命令行模式

mysql> use mysql;
Database changed
mysql> grant all privileges on *.* to root@'%' identified by "root";
Query OK, 0 rows affected (0.00 sec)
mysql> update user set password=PASSWORD(123456) where host='%';
Query OK, 1 rows affected (0.00 sec)
mysql> select host,user,password from user;
+--------------+------+-------------------------------------------+
| host         | user | password                                  |
+--------------+------+-------------------------------------------+
| localhost    | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| 192.168.1.1  | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| %            | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+--------------+------+-------------------------------------------+
3 rows in set (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

这样机器就可以以用户名root密码root远程访问该机器上的MySql.


你可能感兴趣的:(Mysql 开启远程连接)