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 ...
随机推荐
- jquery源码学习(三)—— jquery.prototype主要属性和方法
上次我们学习了jquery中的主要对象jQuery和一些变量,现在我们开始学习jquery的原型 98行声明了jQuery.fn = jQuery.prototype = {} 285行jQuery. ...
- 合唱队形 ( 双向LIS )
#include <iostream> #include <stdio.h> #include <algorithm> using namespace std; ] ...
- vue2.0 兼容ie9及其以上
vue官方的意思是vue项目可以在ie8以上的ie版本中运行 但其实使用vue-cli构建的项目也还是不能在ie8[ie9,ie10,ie11]以上的版本中运行 下面就来讲vue如何在ie8以上ie版 ...
- python 匹配集合与补集
- LintCode_67 二叉树中序遍历
题目 给出一棵二叉树,返回其中序遍历 C++ 非递归 vector<int> inorderTraversal(TreeNode *root) { // write your code h ...
- 【JZOJ4922】【NOIP2017提高组模拟12.17】环
题目描述 小A有一个环,环上有n个正整数.他有特殊的能力,能将环切成k段,每段包含一个或者多个数字.对于一个切分方案,小A将以如下方式计算优美程度: 首先对于每一段,求出他们的数字和.然后对于每段的和 ...
- FastAdmin 自学教程 - 目录(持续更新)(2019-10-11)
FastAdmin 自学教程 - 目录 本自学教程将不定期更新. 了解 FastAdmin FastAdmin 开发第 1 天:了解 FastAdmin 框架 FastAdmin 开发第 2 天:安装 ...
- VS中,卸载,移除,删除项目的区别
不说话,上图.
- 关于redis的问题:RedisException with message read error on connection
最近碰到在REDIS执行一步get操作的时候报出错误:Uncaught RedisException: read error on connection,感觉不可理解,REDIS连接没有发现问题,但是 ...
- Java中清空session的方法
session.removeAttribute("sessionname")是清除SESSION里的某个属性. session.invalidate()是让SESSION失效. 或 ...