mysql ubuntu 远程连接工具_ubuntu mysql 远程连接

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

参考链接:

本机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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值