mysql-proxy不再支持mysql5.7的client客户端登录

一、服务器的环境:

[root@VM_82_178_centos ~]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core) 
[root@VM_82_178_centos ~]# 
本地云主机安装有mysql-proxy-0.8.5
采用二进制安装mysql5.7

二、mysql-proxy安装过程请看考如下链接:
https://blog.51cto.com/wujianwei/2087871

三、mysql-proxy配置文件如下:


[root@VM_82_178_centos ~]# cat /data/mysql-proxy/conf/mysql-proxy 
[mysql-proxy]
user=mysql-proxy
daemon=true
keepalive=true
###日志级别
log-level=info
log-file=/data/mysql-proxy/log/mysql-proxy.log
pid-file =/data/mysql-proxy/log/mysql-proxy.pid
###本机ip地址
proxy-address=0.0.0.0:9198
#admin-address=127.0.0.1:9197
##backend主   注意addresses
proxy-backend-addresses=10.135.82.178

四、启动命令:

/usr/local/mysql-proxy-0.8.5/bin/mysql-proxy --defaults-file=/data/mysql-proxy/conf/mysql-proxy
[root@VM_82_178_centos ~]# ss -lntup|grep mysql
tcp    LISTEN     0      128       *:9198                  *:*                   users:(("mysql-proxy",pid=7855,fd=10))
tcp    LISTEN     0      128      :::3306                 :::*                   users:(("mysqld",pid=5665,fd=31))

五、mysql client版本测试:
mysql5.7的客户端mysql的开到此处登录不到后端的mysql server

[root@VM_82_178_centos ~]# /usr/local/mysql7/bin/mysql -V
/usr/local/mysql7/bin/mysql  Ver 14.14 Distrib 5.7.24, for linux-glibc2.12 (x86_64) using  EditLine wrapper
[root@VM_82_178_centos ~]# 

[root@VM_82_178_centos ~]# /usr/local/mysql7/bin/mysql -uroot -p'69jianwuweimysql' -h10.135.82.178 -P9198
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.

mysql8.0的客户端mysql的开到此处登录不到后端的mysql server


[root@VM_82_178_centos bin]# /usr/local/mysql8013/bin/mysql -V
/usr/local/mysql8013/bin/mysql  Ver 8.0.13 for linux-glibc2.12 on x86_64 (MySQL Community Server - GPL)
[root@VM_82_178_centos bin]# /usr/local/mysql8013/bin/mysql -uroot -p'69jianwuweimysql' -h10.135.82.178 -P9198
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.

mysql5.6的客户端mysql的可以登录后端的mysql server

[root@VM_82_178_centos bin]# /usr/local/mysql5.6.39/bin/mysql -V
/usr/local/mysql5.6.39/bin/mysql  Ver 14.14 Distrib 5.6.39, for linux-glibc2.12 (x86_64) using  EditLine wrapper
[root@VM_82_178_centos bin]#  /usr/local/mysql5.6.39/bin/mysql -uroot -p'69jianwuweimysql' -h10.135.82.178 -P9198

mysql5.5的客户端mysql的可以登录后端的mysql server

[root@VM_82_178_centos ~]# /usr/local/mysql5.5/bin/mysql -V
/usr/local/mysql5.5/bin/mysql  Ver 14.14 Distrib 5.5.60, for linux-glibc2.12 (x86_64) using readline 5.1
[root@VM_82_178_centos ~]# 

[root@VM_82_178_centos ~]# /usr/local/mysql5.5/bin/mysql -uroot -p'69jianwuweimysql' -h10.135.82.178 -P9198 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 38033
Server version: 5.7.24-log MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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.

[email protected] [(none)]>show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| test01             |
| test02             |
+--------------------+
6 rows in set (0.13 sec)

mariadb5.5的版本测试可以通过mysql-proxy登录后端的mysql server:


[root@VM_82_178_centos bin]# rpm -qa|grep mariadb
[root@VM_82_178_centos bin]# rpm -qa|grep mariadb

centos7的系统上安装mysql client的方式:
yum install -y mariadb.x86_64 mariadb-libs.x86_64

[root@VM_82_178_centos bin]# rpm -qa|grep mariadb
mariadb-5.5.60-1.el7_5.x86_64
mariadb-libs-5.5.60-1.el7_5.x86_64

[root@VM_82_178_centos bin]# mysql -V
mysql  Ver 15.1 Distrib 5.5.60-MariaDB, for Linux (x86_64) using readline 5.1
[root@VM_82_178_centos bin]# 

[root@VM_82_178_centos bin]# mysql -uroot -p'69jianwuweimysql' -h10.135.82.178 -P9198
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 38323
Server version: 5.7.24-log MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

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

[email protected] [(none)]>show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| test01             |
| test02             |
+--------------------+
6 rows in set (0.00 sec)

六、登录云主机本地的mysql server,授权一个账户测试mysql-proxy代理后端数据库应用:

创建测试账户:

root@localhost [(none)]>grant all on test01.* to mpuser@'%' identified by '69jianwuweimysql';
Query OK, 0 rows affected, 1 warning (0.13 sec)

root@localhost [(none)]>flush privileges;
Query OK, 0 rows affected (0.10 sec)

登录测试:

[root@VM_82_178_centos ~]# mysql -umpuser -p'69jianwuweimysql' -h10.135.82.178 -P9198
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 74544
Server version: 5.7.24-log MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

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

[email protected] [(none)]>show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| test01             |
+--------------------+
2 rows in set (0.00 sec)

[email protected] [(none)]>\q

通过云控制台的安全组,授权特定的外网ip,允许访问本云主机的数据库:

mysql-proxy不再支持mysql5.7的client客户端登录

在远程的物理机器登录远端的云主机数据库:


[root@127 ~]# /usr/local/mysql5.5/bin/mysql -umpuser -p'69jianwuweimysql' -h119.29.97.131 -P9198
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 74679
Server version: 5.7.24-log MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| test01             |
+--------------------+
2 rows in set (0.04 sec)

到此处简单的讲解和演示完毕

猜你喜欢

转载自blog.51cto.com/wujianwei/2357050