标签:
有时候需要远程连接mysql数据库,默认是不可以的,可以参考下面的方法,解决下。
1、登陆自己机器的MySQL数据库:mysql -uroot -p密码
设置root用户可以任意IP访问,代码如下(可选,这里%代表任意,也可以指定IP):
2、MySQL>GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘mypassword‘ WITH GRANT OPTION;
予任何主机访问数据的权限
3、MySQL>FLUSH PRIVILEGES;
修改生效
4、MySQL>EXIT
退出MySQL服务器
这样就可以在其它任何的主机上以root身份登录啦!
在其他机器上输入IP和端口(端口默认3306),亲测OK
C:\Users\XXXXX>mysql -uroot -proot -h192.168.0.3 -P3307
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 936
Server version: 5.5.28 MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql>
标签:
原文地址:http://www.cnblogs.com/huige-you/p/4280979.html