默认情况下Linux内的mysql数据库mysql,user表内的用户权限只是对localhost即本机才能登陆。需要更改权限:

如下的方式确认:

root#mysql -h localhost-u mysql -p 
Enter password:    ******

Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 4 to server version: 4.0.20a-debug

Type 'help;' or '/h' for help. Type '/c' to clear the buffer.

mysql> use mysql;   (此DB存放MySQL的各种配置信息)
Database changed
mysql> select host,user from user; (查看用户的权限情况)
+-------------+-------+
| host            | user    |
+-------------+-------+
| localhost      |           |
| localhost      | root   |
| localhost      |           |
| localhost      | mysql |
+-------------+-------+
6 rows in set (0.02 sec)

由此可以看出,只能以localhost的主机方式访问。

解决方法:

mysql> Grant all privileges on *.* to 'root'@'%' identified by ‘password’with grant option;
(%表示是所有的外部机器,如果指定某一台机,就将%改为相应的机器名;‘root’则是指要使用的用户名,)

mysql> flush privileges;  (运行为句才生效,或者重启MySQL)
Query OK, 0 rows affected (0.03 sec)

mysql> select host,user from user; (再次查看用户的权限情况)
+-------------+-------+
| host            | user    |
+-------------+-------+

| %                 | mysql |

| %                 | root   |
| localhost      |           |
| localhost      | root   |
| localhost      |           |
| localhost      | mysql |
+-------------+-------+

mysql>exit

现在再试试:
root#mysql -h mysql -u root -p
Enter password:******
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 9 to server version: 4.0.20a-debug

Type 'help;' or '/h' for help. Type '/c' to clear the buffer.

mysql>

就成功连接上了。

mysql 远程 ip访问的更多相关文章

  1. 脚本_统计每个远程IP访问本机apache的次数

    #!bin/bash#功能:统计每个远程IP访问本机apache的次数#作者:liusingbonawk '{ip[$1]++} END{for(i in ip){print ip[i],i}}'  ...

  2. mysql允许远程IP访问

    默认情况下Linux内的mysql数据库mysql,user表内的用户权限只是对localhost即本机才能登陆.需要更改权限: mysql> Grant all privileges on * ...

  3. Linux下支持mysql支持远程ip访问

    示例代码: use mysql; SELECT `Host`,`User` FROM user; UPDATE user SET `Host` = '%' WHERE `User` = 'use**' ...

  4. 开启mysql远程连接访问权限的几种方法

    1.改表法. 可能是你的帐号不允许从远程登陆,只能在localhost.这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 " ...

  5. MySQL远程(IP)连接报错:Host 'IP地址' is not allowed to connect to this MySQL server

    ERROR 1130: Host ’192.168.1.3′ is not allowed to connect to this MySQL server这是告诉你没有权限连接指定IP的主机,下面我们 ...

  6. RabbitMQ 远程 IP 访问 解决办法 -摘自网络

    刚刚安装的RabbitMQ-Server-3.3.5,并且也已经开启了Web管理功能,但是现在存在一个问题: 出于安全的考虑,guest这个默认的用户只能通过http://localhost:1567 ...

  7. RabbitMQ---5、远程 IP 访问

    刚刚安装的RabbitMQ-Server-3.3.7,并且也已经开启了Web管理功能,但是现在存在一个问题: 出于安全的考虑,guest这个默认的用户只能通过http://localhost:1567 ...

  8. Mysql远程链接访问权限设置

    Host 'XXX' is not allowed to connect to this MySQL server 解决方案/如何开启MySQL的远程帐号 如何开启MySQL的远程帐号-1)首先以 r ...

  9. mysql远程服务器访问数据库

    创建一个MySQL用户,并设置可以远程访问 grant usage on *.* to 'fred'@'localhost' identified by 'fred';//创建用户fred密码ferd ...

随机推荐

  1. 网络爬虫2:使用crawler4j爬取网络内容

    https://github.com/yasserg/crawler4j 需要两个包: crawler4j-4.1-jar-with-dependencies.jar slf4j-simple-1.7 ...

  2. es6基础(1)--声明

    function test(){ //let只在块作用域有效 for(let i=1;i<3;i++){ console.log(i); } //es6严格模式,变量未声明,不可以用 //con ...

  3. Xcode 如何导入IOS项目

    前言:基于mac上如何导入ios项目的文章,手机自动化项目需要进行手机元素定位,前提是导入IOS项目 1.安装Xcode 到官网下载mac版Xcode:当前使用版本Version 7.3.1 http ...

  4. 【Tomcat】Tomcat安装及Eclipse配置教程

    ==================================================================================================== ...

  5. [Unity工具]查找GameObject在场景中所有被引用的地方

    参考链接: https://blog.csdn.net/hjzyzr/article/details/53316919?utm_source=blogxgwz4 https://blog.csdn.n ...

  6. 安装hyperledger fabric V1.0.0-beta

      安装文档位置: https://github.com/hyperledger/fabric   fabric代码托管地址 https://hyperledger-fabric.readthedoc ...

  7. 1、eclipse

    1.安装java 32位 jdk-7u79-windows-i586-20151024.rar http://www.oracle.com/technetwork/java/javase/downlo ...

  8. 30.纯 CSS 创作一个晃动的公告板

    原文地址:https://segmentfault.com/a/1190000014983030 感想: 绝对定位+动画 HTML代码: <div class="signboard&q ...

  9. python中的upper、lower、capitalize、title

    upper()字符串中字母由小写变为大写 lower()字符串中字母由大写变为小写 capitalize()字符串中字母首字母大写其余小写 title()字符串中字母每个单词的首字母大写其余小写 举个 ...

  10. List 的一个有用的高效的操作 removeAll

    如果有多个list集合,那么 使用 removeAll 可以快速的删除另外一个集合的内容: List<String> list1 = new ArrayList<String> ...