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 ...
随机推荐
- svn基本命令使用
1.svn help:可以通过该命令查看svn的所有操作命令,包括命令的缩写 2.首先需要从svn库中checkout对应的项目: (1)svn项目路径为svn://192.168.1.1/mypro ...
- 一位AI研究员+区块链创业者的终极展望:AI DAO将统治世界
一位AI研究员+区块链创业者的终极展望:AI DAO将统治世界 [日期:2017-01-09] 来源:infoq.com 作者:杨赛 [字体:大 中 小] Trent McConaghy是一位资深的 ...
- CSS3渐变效果
一.线性渐变linear-gradient 1.使用方法: background:-webkit-linear-gradient(red,blue);background:-moz-linear-g ...
- DateTimeFormatter
//解析日期 String dateStr= "2018年12月18日"; DateTimeFormatter formatter = DateTimeFormatter.ofPa ...
- HTML5小知识汇总
1.关于<!DOCTYPE HTML> H5只需要<!DOCTYPE HTML>这样简单的声明,不用之前一长串代码,因为H5不是基于SGML,所以不需要对DTD引用,但是需要D ...
- python ndarray相关操作:转置、翻转
- SDUT-3376_数据结构实验之查找四:二分查找
数据结构实验之查找四:二分查找 Time Limit: 30 ms Memory Limit: 65536 KiB Problem Description 在一个给定的无重复元素的递增序列里,查找与给 ...
- 【转载】【软件安装】Source Insight 4.0常用设置
1.Source Insight简介 Source Insight是一个面向软件开发的代码编辑器和浏览器,它拥有内置的对C/C++, C#和Java等源码的分析,创建并动态维护符号数据库,并自动显示有 ...
- java 使用 POI 操作 XWPFDocumen 创建和读取 Office Word 文档基础篇
注:有不正确的地方还望大神能够指出,抱拳了 老铁! 参考 API:http://poi.apache.org/apidocs/org/apache/poi/xwpf/usermodel/XWPFDoc ...
- Pycurl介绍
pycurl — A Python interface to the cURL library Pycurl包是一个libcurl的Python接口.pycurl已经成功的在Python2.2到Pyt ...