mysql服务器不能连接本机_mysql不能连接本机服务器解决办法

mysql不能连接本机服务器

连接localhost,空密码,可以连接。

$   mysql   -u   root   -h   localhost   -p

Enter   password:

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

Your   MySQL   connection   id   is   4   to   server   version:   4.0.14-classic

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

mysql>   quit

Bye

连接机器名sd03,空密码,出现错误。

$   mysql   -u   root   -h   sd03   -p

Enter   password:

ERROR   2003:   Can 't   connect   to   MySQL   server   on   'sd03 '   (239)

$

------解决方案--------------------

需要sd03上MySQL服务器的root用户名密码

本机的MySQL不需要密码,并不代表sd03上的也不需要密码

------解决方案--------------------

给sd03上MySQL服务器的root用户赋予网络连接的权限了吗?

------解决方案--------------------

GRANT ALL PRIVILEGES ON *.* TO root@ "% " WITH GRANT OPTION;

------解决方案--------------------

$ mysql -u root -h localhost -p

Enter password:

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

Your MySQL connection id is 4 to server version: 4.0.14-classic

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

mysql> GRANT ALL PRIVILEGES ON *.* TO root@ "% " WITH GRANT OPTION;

Query OK, 0 rows affected (0.04 sec)

mysql>

------解决方案--------------------

开了防火墙也会导致连接不到服务器

------解决方案--------------------

需要给机器赋予权限的,MySQL默认的是localhost!

------解决方案--------------------

新建一个用户来连接,或者给root用户授权可以进行网络连接

原创文章,转载请注明: 转载自搞代码

e7ce419cf2d6ad34d01da2ceb8829eed.png

微信 赏一包辣条吧~

023a57327877fb4402bcc76911ec18ea.png

支付宝 赏一听可乐吧~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值