Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mycat integrates MySQL 8.x trampling practice

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Mycat currently does not fully support MySQL versions above 8, which may cause some problems, such as Mycat may report password errors when connecting to MySQL 8, because the new password encryption method is different from the old version. There is also the time zone problem, the new version of the connection mode needs to increase the time zone parameter. Besides, there may be other problems. Therefore, we need to change some configuration of Mycat so that it can connect to MySQL 8.x properly.

Download drivers for version 8.x

First you need to download version 8.x driver, Mycat default MySQL driver version is 5.x. Copy the download address of the 8.x driver jar package to the maven central repository, and then download it to Linux using the wget command:

[root@txy-server ~]# cd /usr/local/src[root@txy-server /usr/local/src]# wget https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.18/mysql-connector-java-8.0.18.jar

Move the driver package to the lib directory of mycat and delete the original 5.x driver package:

[root@txy-server /usr/local/src]# mv mysql-connector-java-8.0.18.jar /usr/local/mycat/lib/[root@txy-server /usr/local/src]# rm -rf /usr/local/mycat/lib/mysql-connector-java-5.1.35.jar

Then use the chmod command to set permissions for the driver package:

[root@txy-server /usr/local/mycat]# chmod 777 lib/mysql-connector-java-8.0.18.jar Fix schema.xml

Modify the schema.xml configuration file located in the conf directory to change how Mycat connects to MySQL:

[root@txy-server /usr/local/mycat]# vim conf/schema.xml

Modify the dbDriver attribute in the dataHost tag to jdbc, and modify the url attribute in the writeHost tag:

select user() Modify server.xml

Modify the server.xml configuration file located in the conf directory:

[root@txy-server /usr/local/mycat]# vim conf/server.xml

Set useHandshakeV10 to 1. If there is no label, add:

1 ... Restart Mycat and test

Restart Mycat:

[root@txy-server /usr/local/mycat]# mycat stopStopping Mycat-server... Stopped Mycat-server. [root@txy-server /usr/local/mycat]# mycat startStarting Mycat-server... [root@txy-server /usr/local/mycat]#

When testing whether Mycat can be connected properly, I encountered another problem. Using MySQL 8.x client tools to connect Mycat reported a password error:

[root@txy-server ~]# mysql -uroot -p -P9066 -h227.0.0.1Enter password: ERROR 1045 (HY000): Access denied for user 'root', because password is error [root@txy-server ~]#

Again, this is because MySQL versions 8 and above have different encryption methods than previous versions. Mycat currently only supports version 5.x encryption, so using MySQL client tools above version 8 to connect to Mycat will report password error.

There are two main ways to solve this problem. One is to specify the encryption method for mysql client connection. Examples include:

[root@txy-server ~]# mysql -uroot -p -P9066 -h227.0.0.1 --default-auth=mysql_native_password

The second is to use version 5.x MySQL client tools to connect to Mycat. The following example:

[root@txy-server /usr/local/mysql-5.7.28]# bin/mysql -uroot -p -P9066 -h227.0.0.1

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report