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

本文详细介绍了在遇到ERROR1130:Host***.***.***.***isnotallowedtoconnecttothisMySQLserver错误时,如何通过更改MySQL数据库里的user表中的host项来赋予远程连接权限,并提供了登录MySQL服务器、权限更改的具体步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

连接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了!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值