1. The background

During the development process, Error “Server returns invalid timezone. Go to ‘Advanced’ TAB and set ‘serverTimezone’ property” occurs when the mysql database is connected Manually. “. It means the time zone is not set correctly. So I looked for a solution.

2. The train of thought

Log in to the machine where mysql is installed. Take a look at the current mysql time zone Settings

show variables like "%time_zone%";
Copy the code

The following figure shows SYSTEM, indicating the default time zone used. We need to change it to +8 Beijing time zone.

image.png

Example 3.

Step 1: Log in to the machine where mysql is installed

  • Mysql -hlocalhost -uroot -p
  • Enter the password to enter the mysql interactive mode

Step 2: Change the time zone

set global time_zone = '+8:00';
   set time_zone = '+8:00';
Copy the code

That’s it.

4. The extension

The method that takes effect permanently is added below.

The restart takes effect permanently

Modify the configuration file /etc/my.cnf

[mysqld]
default-time_zone = '+8:00'
Copy the code

Restart the mysql

systemctl stop mysqld.service
   systemctl start mysqld.service
Copy the code

5. Reference:

Blog.csdn.net/liuqiker/ar… www.cnblogs.com/minseo/p/11…