Ubuntu Server中LAMP下MySQL无法远程连接问题1130

运维 系统运维
Ubuntu server中,LAMP的配置时,我们常常会遇到MYSQL无法远程连接的问题。本文讲述的是:“10061Can not connect to mysql error 10061”,“1130is not allowed to connect to this MySQL server1130”这两个问题的解决。第二个问题:

Ubuntu Server中LAMPMySQL无法远程连接该怎么办:

MySQL无法远程连接问题10061问题1130 

  很常见的问题发生了,我们怎么处理它?

  环境:ubuntu Server (版本8.04以上对于LAMP应用都大同小异), cl@ubuntu.

  目的:安装LAMP重新配置RT系统。

  软件:服务器端已安装LAMP组件,MySQL5.1版本;客户端使用Navicat进行远程连接。

  问题② 提示”is not allowed to connect to this MySQL server” ,如图2  

LAMP/MySQL/远程连接

 

  对于数据库的远程连接不外乎两方面入手:1、客户端至服务器端的连通性。2、服务器端没有合理配置。当然非要加上客户端也没有配置之类的,也尚可,比如ODBC的方式连接MySQL。

  ②当MySQL 连接服务器时发生”is not allowed to connect to this MySQL server”错误,我们要注意在MySQL的user表中修改host列的localhost为%,即可以远程连接。

  做如下操作:

  mysql> use mysql --切换数据库上下文

  Reading table information for completion of table and column names

  You can turn off this feature to get a quicker startup with -A

  Database changed

  mysql> select host,user,password from user; --查询USER 表

  +-----------+------------------+-------------------------------------------+

  1.   | host | user | password |  
  2.  

  +-----------+------------------+-------------------------------------------+

  1.   | localhost | root | *MD5加密 |  
  2.  
  3.   | ubuntu | root | *MD5加密 |  
  4.  
  5.   | 127.0.0.1 | root | *MD5加密 |  
  6.  
  7.   | localhost | debian-sys-maint | * MD5加密|  
  8.  

  +-----------+------------------+-------------------------------------------+

  1.   mysql> delete from user where user='root' and host <> '%'--删除多余用户  
  2.  
  3.   Query OK, 2 rows affected (0.00 sec)  
  4.  
  5.   mysql> update user set host ='%' where host='localhost' and user='root'--更新host  
  6.  
  7.   Query OK, 1 row affected (0.00 sec)  
  8.  
  9.   Rows matched: 1 Changed: 1 Warnings: 0  
  10.  
  11.   mysql> select host,user,password from user;  
  12.  

  +-----------+------------------+-------------------------------------------+

  | host | user | password |

  +-----------+------------------+-------------------------------------------+

  | % | root | *MD5加密|

  | localhost | debian-sys-maint | * MD5加密|

  +-----------+------------------+-------------------------------------------+

  2 rows in set (0.00 sec)

  注:如果在修改User时失误出现以下结果,怎么办?

  mysql> select host,user,password from user;

  +-----------+------------------+-------------------------------------------+

  | host | user | password |

  +-----------+------------------+-------------------------------------------+

  | ubuntu | root | * MD5加密|

  | localhost | debian-sys-maint | * MD5加密|

  +-----------+------------------+-------------------------------------------+

  2 rows in set (0.00 sec)

  此时没有127.0.0.1和localhost主机,所以无法用root用户进行连接,会提示以下错误

 

  1.   ~$ mysql -u root -p  
  2.  
  3.   Enter password:  
  4.  
  5.   ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)  
  6.  

  则此时只能用系统自带的debian-sys-maint用户登录,修改host。该用户的的登录密码在/etc/mysql/debian.cnf中明文显示。

  比如:

  1.   host = localhost 
  2.  
  3.   user = debian-sys-maint  
  4.  
  5.   password = 明文密码  
  6.  
  7.   socket = /var/run/mysqld/mysqld.sock  
  8.  
  9.   basedir = /usr  
  10.  

  做如下操作:

  1.   ~$ mysql -u debian-sys-maint -p  
  2.  
  3.   Enter password:  
  4.  
  5.   mysql> use mysql;  
  6.  
  7.   mysql> update user set host ='%' where host='ubuntu';  
  8.  
  9.   mysql> exit  
  10.  
  11.   ~$ sudo /etc/init.d/mysql restart  
  12.  

  清理思路,注意操作后需重启服务。

【编辑推荐】

Ubuntu10.10下安装LAMP的方法

Ubuntu下LAMP的PHP错误提示的开启

Ubuntu下LAMP配置文件路径

责任编辑:zhaolei 来源: CSDN
相关推荐

2011-03-14 10:21:25

LAMPMySQL远程连接

2011-04-19 17:10:12

UbuntuServer远程连接

2011-03-14 13:07:23

Ubuntu安装LAMP

2011-03-10 10:51:45

Ubuntu搭建LAMP

2011-03-10 08:59:04

Ubuntu安装LAMP

2011-03-10 10:09:09

UbuntuLAMP搭建

2011-03-09 15:13:00

UbuntuLAMP配置

2011-03-09 15:44:14

UbuntuLAMP

2011-03-11 10:27:45

UbuntuLAMP配置

2011-03-14 11:29:43

2011-03-10 11:06:02

Ubuntu搭建LAMP

2011-03-21 16:37:57

2011-03-08 10:35:23

2010-10-19 13:05:31

Sql Server远

2021-01-22 15:18:21

UbuntuLinuxApache

2011-09-08 10:21:16

UbuntuSNMP

2011-03-21 16:21:21

ubuntulamp

2011-03-11 10:09:59

UbuntuLAMP路径

2011-03-09 15:25:36

UbuntuLAMPPHPadmin

2011-03-22 10:25:54

UbuntuLAMP
点赞
收藏

51CTO技术栈公众号