最近需要远程连接mysql服务器,先进行简单的测试,过程记录于此。

参考链接:

  http://blog.chinaunix.net/uid-28458801-id-3445261.html

  http://stackoverflow.com/questions/1420839/cant-connect-to-mysql-server-error-111

本机ip: 192.168.1.248

远程ip: 192.168.1.249

mysql服务器配置

# 1.更改配置文件

#因为远程mysql服务器,设置只监听本地的端口,更改mysql配置文件,注释掉下面的一行。打开远程服务器的配置文件.
sudo vi /etc/mysql/my.cnf # 注释下面一行。
# bind-address = 127.0.0.1
# 如果没注释上面的一行,客户端连接时,会出现如下错误。
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.249' (111) # 2. 打开mysql服务
sudo service /etc/init.d/mysql start # 3. 配置mysql服务器
qt@tony:~/Desktop$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 36
Server version: 5.5.53-0ubuntu0.12.04.1 (Ubuntu) Copyright (c) 2000, 2016, 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;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed # 允许用户的ip是192.168.1.248,使用用户名为 tony, 密码是 password进行登录。 mysql> grant all PRIVILEGES on *.* to tony@'192.168.1.248' identified by 'password';
Query OK, 0 rows affected (0.00 sec) mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec) mysql> quit
Bye

mysql客户端连接

# 连接出现错误。
# error1:
ERROR 1045 (28000): Access denied for user 'tony'@'aplex-2.local' (using password: YES)
# 我这边得情况是本地的ip没有配置,从新配置ip.
sudo ifconfig eth0 192.168.1.248. # 连接
# 以服务器设置的用户名登录
Qt@tony:~$ mysql -h 192.168.1.248 -u tony -p
Enter password:
# 或者以root用户登录
Qt@tony:~$ mysql -h 192.168.1.249 -u tony -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 37
Server version: 5.5.53-0ubuntu0.12.04.1 (Ubuntu) Copyright (c) 2000, 2016, 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>

Tony Liu

2016-11-4, Shenzhen

ubuntu mysql 远程连接的更多相关文章

  1. ubuntu mysql 远程连接问题解决方法

    在shell下输入mysql -uroot -p是可以登录的,所以问题应该是mysql不允许root用户远程登录的问题,于是通过输入下面命令: GRANT ALL PRIVILEGES ON *.*  ...

  2. ubuntu允许mysql远程连接

    ubuntu允许mysql远程连接 第一步: vim /etc/MySQL/my.cnf找到bind-address = 127.0.0.1 注释掉这行,如:#bind-address = 127.0 ...

  3. Mysql远程连接配置

    Mysql远程连接配置 环境:unbuntu 16.04 最新版本的Mysql在远程连接的配置上与老版本有了一些出入,照原先的配置已经不行了,所以在这里记录一下遇到的所有新问题. 配置远程连接的步骤如 ...

  4. 在Ubuntu14.04中配置mysql远程连接教程

    上一篇文章,小编带大家学会了在Ubuntu14.04中安装MySQL,没有来得及上课的小伙伴们可以戳这篇文章:如何在Ubuntu14.04中安装mysql,今天给大家分享一下,如何简单的配置MySQL ...

  5. mysql远程连接命令

    mysql远程连接命令   一.MySQL 连接本地数据库,用户名为“root”,密码“123”(注意:“-p”和“123” 之间不能有空格) C:\>mysql -h localhost -u ...

  6. Navicat for mysql 远程连接 mySql数据库10061、1045错误

    原文地址:http://www.111cn.net/database/mysql/46377.htm 有朋友可能会碰到使用Navicat for mysql 远程连接 mySql数据库会提示10061 ...

  7. mysql 远程连接速度慢的解决方案

    PHP远程连接MYSQL速度慢,有时远程连接到MYSQL用时4-20秒不等,本地连接MYSQL正常,出现这种问题的主要原因是,默认安装的MYSQL开启了DNS的反向解析,在MY.INI(WINDOWS ...

  8. mysql 远程连接

    4.现在如果用你电脑上的终端进行MySQL连接时,有可能出现如下错误: MySQL远程连接ERROR 2003 (HY000):Can't connect to MySQL server on'XXX ...

  9. 如何开启MYSQL远程连接权限

    开启MYSQL远程连接权限 //建议设置固定IP mysql> GRANT ALL PRIVILEGES ON *.* TO root@"8.8.8.8" IDENTIFIE ...

随机推荐

  1. POJ 3318 Matrix Multiplication(随机算法)

    题目链接 随机算法使劲水...srand((unsigned)time(0))比srand(NULL)靠谱很多,可能是更加随机. #include <cstdio> #include &l ...

  2. Noi 2016

    考砸只能说自己弱 Noi不是生活的全部, 人们也不会永远止步于失败. 大家加油 可以+我的qq:582744883

  3. [iOS经典面试题]用变量a给出下面的定义

    用变量a给出下面的定义       a)一个整型数(An integer) b) 一个指向整型数的指针(A pointer to an integer)  c) 一个指向指针的的指针,它指向的指针是指 ...

  4. Css3 - 动画旋转

    旋转1: <!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="U ...

  5. [转]支付宝接口程序、文档及解读(ASP.NET)

    本文转自:http://www.cnblogs.com/blodfox777/archive/2009/11/03/1595223.html 最近需要为网站加入支付宝的充值接口,而目前关于支付宝接口开 ...

  6. virt-XXX

    尽管 virt-manager 是 libvirt 虚拟化 API 的一个首要用户,但有一个越来越庞大的工具生态系统在使用此接口进行虚拟化管理.virt-manager 包提供了一个便捷的 GUI,用 ...

  7. Excel 2003 中如何用VBA 代码访问单元格里的值及操作单元格 - 唐诗宋词的专栏 - 博客频道 - CSDN.NET

    在Excel 中编写VBA 代码,最常做的事可能就是操作表单中单元格里的数据. 我这里总结一下如何从VBA 代码中操作单元格的数据. 在VBA 代码中操作单元格需要用到Range 对象,Range 是 ...

  8. $_ 与 $PSItem

    PowerShell 3.0 中的$PSItem 此文章于2012年11月4日发表在PowershellPowershell小技巧并加以Powershell 3.0管道的标签 by Mooser Le ...

  9. ubuntu + subversion + apache2 设置

    1.下载安装subversion,apache2 sudo apt-get updatesudo apt-get upgrade sudo  apt-get install apache2sudo a ...

  10. Java笔试面试题二(常考问答)转

    1.说出ArrayList,Vector, LinkedList的存储性能和特性 ArrayList 和Vector都是使用数组方式存储数据,此数组元素数大于实际存储的数据以便增加和插入元素,它们都允 ...