linux 服务器mysql已经配置好,远程连接不上(已解决)

先确认你已经开始了允许远程访问的权限:

 

◆为了在其它电脑上能用root用户登录,需进行以下动作:

1、mark@marklinux mark>mysql -h localhost -u root

//这样应该可以进入MySQL服务器

2、mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION

//赋予任何主机访问数据的权限

3、mysql>FLUSH PRIVILEGES

//修改生效

4、mysql>EXIT

//退出MySQL服务器

这样就可以在其它任何的主机上以root身份登录啦!

 

客户端(windows)

c:/program files/mysql/mysql server 5.1/bin>mysql -h 192.168.0.249 -uroot -p

enter password:

 

远程报错:

ERROR 2003(HY000):Can't connect to MySQL server on '192.168.0.249' (10065) 

 

把linux服务器的防火墙添加端口tcp: 3306后就OK了。

 

c:/program files/mysql/mysql server 5.1/bin>mysql -h 192.168.0.249 -uroot -p

enter password:

Welcome to the MySQL monitor. Commands end with ; or /g.

Your MySQL connection id is 13

Server version:4.1.22-standard-log

 

Type 'help' or '/h' for help. Type '/c' to clear the buffer.

mysql>

 

如果出现: 1045 Access denied for user 'root'@'192.168.1.3' (using password:YES) 错误的话。

是因为上述第二步密码为'%' 所以不用加密码即可。

猜你喜欢

转载自201307121509.iteye.com/blog/2005703