连接mysql错误:ERROR 1130: Hostis *not allowed to connect to this MySQL server

连接mysql错误:ERROR 1130: Hostis *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了!

猜你喜欢

转载自pengzhaocheng16.iteye.com/blog/1584061