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

How to connect to MySQL8 database

2025-03-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article focuses on "how to connect to the MySQL8 database", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to connect to MySQL8 database.

The database drivers of MySQL8 and MySQL5.1, 5.5,5.6,5.7 have changed and need to be adjusted.

Replace the JDBC driver

If you use the source code to develop, you can modify pom.xml to change the jdbc driver to MySQL8 driver:

Mysql mysql-connector-java 8.0.22

Using the program deployed to tomcat, you can replace the JDBC driver file in the / WEB-INF/lib directory. Replace mysql-connector-java-5.1.x.jar with mysql-connector-java-8.0.x.jar.

Download MySQL8 JDBC driver: mysql-connector-java-8.0.22.jar

Modify driver classes and database connections

Driver class: com.mysql.jdbc.Driver is changed to com.mysql.cj.jdbc.Driver.

Database connection: jdbc:mysql://127.0.0.1:3306/jspxcms?characterEncoding=utf8 changed to jdbc:mysql://127.0.0.1:3306/jspxcms?serverTimezone=Asia/Shanghai

Developed with source code, modify / src/main/resources/application.properties.

Use the program to deploy to tomcat, modify / WEB-INF/classes/application.properties.

# original configuration # configure spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driverspring.datasource.url=jdbc:mysql://127.0.0.1:3306/jspxcms?serverTimezone=Asia/Shanghai after spring.datasource.driver-class-name=com.mysql.jdbc.Driver#spring.datasource.url=jdbc:mysql://127.0.0.1:3306/jspxcms?characterEncoding=utf8# modification

Note: if configured as serverTimezone=UTC, it will cause jet lag in the date field, because we are using Beijing time (Shanghai time, East eighth District time, UTC+8), which is international time plus eight hours.

Connect to the jdbc urlspring.datasource.url=jdbc:mysql://127.0.0.1:3306/jspxcms?characterEncoding=utf8&useSSL=false of MySQL 5.7. here, I believe you have a deeper understanding of "how to connect to the MySQL8 database". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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

Development

Wechat

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

12
Report