以下摘自网络 ----------------------------------------
今天在用远程连接Mysql服务器的数据库,不管怎么弄都是连接不到,错误代码是1130,ERROR 1130: Host 192.168.2.159 is not allowed to connect to this MySQL server |
============================
一、通过MySQL-Front或mysql administrator连接mysql的时候发生的这个错误
ERROR 1130: Host ***.***.***.*** is not allowed to connect to this MySQL server
说明所连接的用户帐号没有远程连接的权限,只能在本机(localhost)登录。
需更改 mysql 数据库里的 user表里的 host项
把localhost改称%
首先按下面的步骤登录Mysql服务器
登录mysql需要切换到dos下的mysql的bin目录,进行如下操作:
语法格式:mysql -h host_name -u user_name -p password (本机的话-h 和host_name可省)
例如:
C:/program files/mysql/mysql server 5.0/bin>mysql -u root -p
Enter password:******
先输入用户名和密码登陆要求(-p),回车后等出现"Enter password:",再输入密码回车,这样就可以
成功登陆mysql,否则将会登陆失败。
登陆成功后会显示如下信息及Mysql标识符:
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 1 to server version: 5.0.1-nt
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
mysql>
标识符"mysql>",当你看到这个出现在窗口的最左边的顶格时,这就是告诉你,你可以输入命令进行操作了。
mysql> /s 查看版本信息
mysql> /q or mysql> quit 退出mysql数据库服务器
mysql> /h or mysql> help 查看帮助(其他的数据库服务器相关命令)
二、登录成功后可通过以下步骤对用户进行权限更改
mysql>use mysql;
mysql>update user set host = '%' where user ='root';
mysql>flush privileges;
mysql>select 'host','user' from user where user='root';
mysql>quit
退出后会回到DOS正常的提示符状态,此时可以通过远程连接Mysql了!
========================================
MySQL上的一个数据库要备份,装了个MySQL的gui工具。打开"MySQL Administrator"工具,填好用户名和密码却登录不了,老是报这个错“ERROR 1130: Host 'lijuan-' is not allowed to connect to this MySQL server”。网上查了下,有这两个方法解决:
解决方法:
1。 改表法。可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%" mysql -u root -pvmwaremysql>use mysql;mysql>update user set host = '%' where user = 'root';mysql>select host, user from user; 2. 授权法。例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。
如果你想允许用户myuser从ip为192.168.1.3的主机连接到mysql服务器,并使用mypassword作为密码
我的mysql.user里root用户的host果然是localhost,先用改表法给localhost改成“%”,还是不行,仍然报1130的错误,又按“从任何主机连接到mysql服务器”方法授权,还是报一样的错,最后给自己的ip授权之后,终于登录上了。。。。
乎乎。。。 mysql的ERROR 1045 在上面情况后如再出现客户段1045可在服务器执行如下 UPDATE user SET Password=PASSWORD('123456') where USER='myuser'; |
如果在安装的时候 勾选 红色部分,则不会出现远程连接的问题