• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

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

mysql 搞代码 7年前 (2018-05-31) 138次浏览 已收录 0个评论

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用户授权可以进行网络连接


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:mysql不能连接本机服务器解决办法

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址