HOSt ip is not allowed to connect to this MySql server, MYSQL添加远程用户或允许远程访问三种方法
报错:1130-host ... 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>flush privileges;
mysql>select host, user from user;
mysql>quit
2. 授权法。
例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
如果你想允许用户myuser从ip为192.168.1.6的主机连接到mysql服务器,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
如果你想允许用户myuser从ip为192.168.1.6的主机连接到mysql服务器的dk数据库,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON dk.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
我用的第一个方法,刚开始发现不行,在网上查了一下,少执行一个语句 mysql>FLUSH RIVILEGES 使修改生效.就可以了
另外一种方法,不过我没有亲自试过的,在csdn.net上找的,可以看一下.
在安装mysql的机器上运行:
1、d:\mysql\bin\>mysql -h localhost -u root //这样应该可以进入MySQL服务器
2、mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION //赋予任何主机访问数据的权限
3、mysql>FLUSH PRIVILEGES //修改生效
4、mysql>EXIT //退出MySQL服务器
这样就可以在其它任何的主机上以root身份登录啦!

版权声明:本文为博主原创文章,未经博主允许不得转载。
mysql教程添加远程用户或允许远程访问三种方法
用root用户登陆,然后:
grant all privileges on *.* to 创建的用户名 @"%" identified by "密码";
flush privileges; * 刷新刚才的内容*
格式:grant 权限 on 数据库教程名.表名 to 用户@登录主机 identified by "用户密码";
@ 后面是访问MySQL的客户端ip地址(或是 主机名) % 代表任意的客户端,如果填写 localhost 为
本地访问(那此用户就不能远程访问该mysql数据库了)。
同时也可以为现有的用户设置是否具有远程访问权限。如下:
use mysql;
update db set host = '%' where user = '用户名'; (如果写成 host=localhost 那此用户就不具有远程访问权限)
flush privileges;
grant all privileges on *.* to 'myuser'@'%' identified by 'mypassword' with grant option;
方法二
1. 使用grant语句添加:首先在数据库本机上用root用户
登录mysql(我是用远程控制Linux服务器,相当于在服务器本机登录mysql了),然后输入:
mysql>grant all privileges on *.* to admin@localhost identified by 'something' with grant option;
添加一个用户admin并授权通过本地机(localhost)访问,密码"something"。
mysql>grant all privileges on *.* to admin@"%" identified by 'something' with grant option;
添加一个用户admin并授权可从任何其它主机发起的访问(通配符%)。使用这一条语句即可。
2.使用insert语句:
mysql>insert into user values('%','admin',password('something'), 'y','y','y','y','y','y',
'y','y','y','y','y','y','y','y')
用户信息可在mysql数据库中的users表中查看,这里不在介绍了就。数清y的个数哦。
好了,使用admin帐号连接试试看,我是屡试屡成功哦,呵呵!
方法三
添加远程用户admin密码为password
grant all privileges on *.* to admin@localhost identified by 'password' with grant option
grant all privileges on *.* to admin@"%" identified by 'password' with grant option
由于项目开发的要求数据库的设计不得不用远程模式。但是数据库的远程设置并没那么简单,该项目的数据库是mysql5.0。刚开始以为只要装了数据库服务器就可以进行远程链接了,但是mysql的设置是为了用户的安全,系统默认的设置是不允许远程用户连接,只能本地的用户连接。只要我们设置下系统的管理员用户的host这一项的值就可以给远程的用户访问了。
HOSt ip is not allowed to connect to this MySql server, MYSQL添加远程用户或允许远程访问三种方法的更多相关文章
- HOST ip is not allowed to connect to this MySql server
报错:1130-host ... is not allowed to connect to this MySql server 解决方法: 1. 改表法. 可能是你的帐号不允许从远程登陆,只能在loc ...
- mariadb 远程访问报:Host xxx is not allowed to connect to this MariaDb server
刚开始试的是: 结果报错了,哎,这折腾的. 继续折腾,加个密码试试: 再用Navicat试试,果然成功了.
- Host xxx is not allowed to connect to this MariaDb server
直接复制代码,无需修改 第一:// %:表示从任何主机连接到mysql服务器 GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' IDENTIFIED BY 'pass ...
- Navicat 连接MariaDB 失败: Host '*' is not allowed to connect to this MariaDB server
题描述:Navicat 为管理方便,连接Linux 中Mariadb失败,如下如下错误:Host '*' is not allowed to connect to this MariaDB serve ...
- java.sql.SQLException: null, message from server: “Host ‘xxx’ is not allowed to connect
java.sql.SQLException: null, message from server: “Host ‘xxx’ is not allowed to connect 2014年06月29日 ...
- 解决服务器连接错误Host ‘XXX’ is not allowed to connect to this MySQL server
这段时间在研究火车头的入库教程,在“配置登陆信息和数据库(mysql)”连接中,出现“服务器连接错误Host 'XXX' is not allowed to connect to this MySQL ...
- Host 'hello-PC' is not allowed to connect to this MySQL server远程连接mysql授权
问题:"Host 'admin-PC' is not allowed to connect to this MySQLserver" (其中,admin-PC为我的机器名) 原 ...
- Host 'xxx' is not allowed to connect to this MySQL server.
mysql开启远程连接 今天在服务器安装了mysql,准备用mysqlguitools远程登录的时候出错,提示:Host 'xxx' is not allowed to connect to this ...
- 连接远程数据库时出现 SSH: expected key exchange group packet from server / 2003 - Can't connect to MySQL server on 'XXX' (10038) / 1130 - Host 'XXX' is not allowed to connect to this MySQL server
昨天在自己的远程服务器上玩,把系统重装了.新装了MySQL,在本地用navicat连接的时候出了几个小问题. 问题一:SSH: expected key exchange group packet f ...
随机推荐
- node中__dirname、__filename表示的路径
__dirname 表示当前文件所在的目录的绝对路径__filename 表示当前文件的绝对路径module.filename ==== __filename 等价process.cwd() 返回运行 ...
- 关于Python缩进,我们该了解哪些?
Python是一门独特的语言,它的代码块是通过缩进(Indentation)来标记的(大部分语言都是使用花括号作为代码块的标记),具有相同缩进的多行代码属于同一个代码块.如果代码莫名其妙的乱缩进,Py ...
- Git-svn:用git管理svn仓库
1. 将svn仓库中的项目导入本地git仓库 使用 git svn clone [svn_url] 命令即可完成从svn仓库导入本地,由于该命令会将svn仓库中所有版本的更新都会同步到本地仓库,如果项 ...
- Web学习之跨域问题及解决方案
在做前端开发时,我们时常使用ajax与服务器通信获取资源,享受ajax便利的同时,也知道它有限制:跨域安全限制,即同源策略. 同源策略(SOP),核心是确保不同源提供的文件之间是相互独立的 默认情况下 ...
- Apple Watch和Apple Pay将助苹果成为首家市值万亿美元公司
苹果公司周二盘中市值首次突破7000亿美元,成为标普中首家市值超过7000亿美元的公司,市值是第二名Exxon的1.7倍.有分析师预测苹果在明年的市值将会逼近8000亿美元,不过如果参考著名激进投资人 ...
- Eslint报错的翻译
若在git中出现这个 http://eslint.org/docs/rules/eol-last 他是提醒你:在文件末尾要求或禁止换行 比如代码如下: 若在git中出现这个 https://eslin ...
- 【水滴石穿】imooc_gp
这个项目应该是一个标杆项目,看到之前很有几个项目都是按照这个项目的页面摆放顺序来的 不过可以作为自己做项目的一种方式 源码地址为:https://github.com/pgg-pgg/imooc_gp ...
- Nginx - 01 - Nginx初体验
首先下载Nginx,这里电脑太垃圾,没法装虚拟机,所以只能用Windons版本的Nginx. 安装包下载地址:http://nginx.org/en/download.html 下载下来,然后解压: ...
- 洛谷P1879 玉米田
题目描述 农场主John新买了一块长方形的新牧场,这块牧场被划分成M行N列(1 ≤ M ≤ 12; 1 ≤ N ≤ 12),每一格都是一块正方形的土地.John打算在牧场上的某几格里种上美味的草,供他 ...
- 开启远程XUL
参考:https://developer.mozilla.org/zh-cn/Remote_XUL firefox自4.0起(2011年4月版本,目前最新版为13.0),开始禁用远程XUL,这阻碍了初 ...