在其它电脑主机上访问时提示host ip is not allowed to connect to this mysql

下面代码为解决该问题的方法:

 :\Program Files\mysql-5.5.\bin>mysql -u root -p

Enter password: ******

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.5.51-log MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use mysql;

Database changed

mysql> select host,user,password from user;

+-----------+------+-------------------------------------------+

| host      | user | password                                  |

+-----------+------+-------------------------------------------+

| localhost | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |

| 127.0.0.1 | root |                                           |

| ::1       | root |                                           |

| localhost |      |                                           |

+-----------+------+-------------------------------------------+

4 rows in set (0.00 sec)

mysql> update user set host='%' where user='root';

ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'

mysql> update user set host=' %' where user='root';

ERROR 1062 (23000): Duplicate entry ' %-root' for key 'PRIMARY'

mysql> select host,user from user where user='root';

+-----------+------+

| host      | user |

+-----------+------+

|  %        | root |

| 127.0.0.1 | root |

| ::1       | root |

+-----------+------+

3 rows in set (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.02 sec)

mysql> quit;

Bye

D:\Program Files\mysql-5.5.51\bin>net stop MySQL

MySQL 服务正在停止.

MySQL 服务已成功停止。

D:\Program Files\mysql-5.5.51\bin>net start MySQL

MySQL 服务正在启动 .

MySQL 服务已经启动成功。

D:\Program Files\mysql-5.5.51\bin>mysql -u root -p

Enter password: ******

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: Y

ES)

D:\Program Files\mysql-5.5.51\bin>mysql -u root -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.5.51-log MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit;

Bye

D:\Program Files\mysql-5.5.51\bin>mysqladmin -uroot password 123456

D:\Program Files\mysql-5.5.51\bin>mysql -uroot -p123456

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 6

Server version: 5.5.51-log MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;

Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

解释下上面遇到的问题:

1.首先查询有没有开启远程访问(可以让任意IP通过root用户访问)

2.没有开启,则修改host='%',会报错:ERROR 1062 (23000): Duplicateentry ' %-root'for key'PRIMARY'

3.忽略第二个问题,并flush privileges;(刷新MySQL系统权限相关表,否则会报错:拒绝访问)

4.通过命令重新登录报错:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES),原因是密码变成空了,重新设置密码:mysqladmin -uroot password 123456

5.这个时候访问还是报错:  host ip is not allowed to connect to this mysql。通过以下两个命令即可解决,grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;flush privileges;

参考:https://jingyan.baidu.com/article/60ccbceb05804164cab1978c.html

MySQL5.5.51启用网络远程连接的更多相关文章

  1. centos7安装mysql5.7.19及配置远程连接

    centos7安装mysql5.7.19及配置远程连接------https://blog.csdn.net/Lh19931122/article/details/77996213

  2. Windows远程连接局域网内或同一个网段或同一个路由器的某台机器

    http://bbs.shendu.com/thread-1443245-1-1.html     亲自试验,具体操作如下:    我现在有三台机器和对应的ip地址(ip地址自己手动填写,不会网上搜) ...

  3. windows server2008 r2 下启用 sqlserver 2008的远程连接

    首先说明,本文转自互联网. TMD 花了二天,终于找到怎么开启这个远程连接了.....娘的,累死了,写下来,希望能帮助同胞们... 用win server 2008 r2 和sql server 20 ...

  4. VMware虚拟机里centos7下安装mysql5.6并授权远程连接Navicat

    这节来安装Mysql5.6,并远程授权连接本地windows的Navicat,可以根据以下步骤安装.此文章为自己收藏,必要时拿出来直接用的,有需要的友友可以查看查看的.文章图片有借助于网络的. 1.新 ...

  5. NAT模式下远程连接centos6虚拟机与虚拟机网络配置

    最近装了centos,但是没有网络,也无法远程连接.关键是虚拟机中没有ip地址. 网上方法很多,但是每个人情况不一样,所以不尽适用. 1.解决这个问题,首先保证你的vmware的dhcp服务和net服 ...

  6. Linux yum安装MySQL5.7,及远程连接mysql(亲测有效!)

    一.安装配置MySQL的yum源 # 安装MySQL的yum源,下面是RHEL6系列的下载地址 rpm -Uvh http://dev.mysql.com/get/mysql-community-re ...

  7. win 10 远程连接出现 "由于安全设置错误, 客户端无法连接到远程计算机. 确定你已登录到网络后.” 错误

    win 10 远程连接出现 "由于安全设置错误, 客户端无法连接到远程计算机. 确定你已登录到网络后.” 错误 解决方法如下: Step 1:打开"本地安全策略"- Wi ...

  8. 虚拟机VMware网络类型&&SSH远程连接Linux

    前言: Linux专题是16年11月开始写,说来惭愧,已经5个月没学Linux,至今感觉连入门还没达到.暑假实习有投运维开发岗位,无奈对Linux不熟悉,校招简历也被刷了.so, 我打算先花1个月内的 ...

  9. 远程连接SqlServer 数据库时提示 "在与SQL Server 建立连接时出现与网络相关的或特定实例的错误" 解决方法

    前言 由于在之前的职业生涯中, 无论是数据库还是开发环境, 都是前人弄好的,自己只管使用就好啦.并不知安装过程中会出现各种各样的错.最近接触服务器之后,开发环境以及配置各方面都是从头到脚开始安装到配置 ...

随机推荐

  1. 代码覆盖率 (Code Coverage)从简到繁 (一)

    代码覆盖率(Code Coverage)是反映测试用例对被测软件覆盖程度的重要指标,也是衡量测试工作进展情况的重要指标.它也是对测试工作进行量化的重要指标之一,测试工作往往不如开发那样激动人心,一个重 ...

  2. Integer简介

    // 当创建范围为[-128,127]时 Integer a = ; Integer b = ; Integer c = ); System.out.println("a == b :&qu ...

  3. jenkins修改数据存放路径

    如果是用tomcat做容器的话,则在./bin/catalina.sh文件添加以下语句即可:export JENKINS_HOME="存放路径(需存在)" 例如:

  4. Zara带你快速入门WPF(4)---Command与功能区控件

    前言:许多数据驱动的应用程序都包含菜单和工具栏或功能区控件,允许用户控制操作,在WPF中,也可以使用功能区控件,所以这里介绍菜单和功能区控件. 一.菜单控件 在WPF中,菜单很容易使用Menu和Men ...

  5. https和http共存的nginx简单配置

    server{ listen 80; listen 443 ssl; ssl_certificate /usr/local/nginx/ssl/www.demo.com/www.demo.com.cn ...

  6. Python爬虫入门教程 14-100 All IT eBooks多线程爬取

    All IT eBooks多线程爬取-写在前面 对一个爬虫爱好者来说,或多或少都有这么一点点的收集癖 ~ 发现好的图片,发现好的书籍,发现各种能存放在电脑上的东西,都喜欢把它批量的爬取下来. 然后放着 ...

  7. spring cloud 配置zuul实用

    在线演示 演示地址:http://139.196.87.48:9002/kitty 用户名:admin 密码:admin 技术背景 前面我们通过Ribbon或Feign实现了微服务之间的调用和负载均衡 ...

  8. ES6躬行记(5)——对象字面量的扩展

    一.简洁属性和方法 当创建对象字面量时,如果属性值是与属性同名的已定义的标识符(例如变量.常量等),那么ES6允许省略冒号和属性值,这样就能避免冗余的初始化.下面分别用传统的键值对和最新的简写方式创建 ...

  9. Windows 花屏问题

    已经有2台电脑 Windows 10 系统出现花屏现象,表现为比较炫的界面出现花屏.文字显示不全.移位.闪烁等,如果点击“设置”.“开始”,Chrome浏览器等:比较平素的界面显示正常,比如资源管理器 ...

  10. vs2017安装pygame,vs2017安装python第三方包

    vs2017有独立的python环境:所以想在vs2017开发python并使用第三方包,需要在vs2017中操作,完成第三方包的安装. 一,查看vs2017有哪些版本的python,当前使用的是哪个 ...