Idea 链接 mysql 后报错 Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property manually,可以通过设置 mysql 时区解决
cmd -> mysql -uroot -p 登录 DB
show variables like'%time_zone'; 查看时区, Value 为 SYSTEM 则表示没有设置过
set global time_zone = '+8:00'; 修改时区为东八区
重试链接,问题解决
这只是临时方案,重启 DB 后时区会重置,可以去 my.ini 配置文件中添加配置
1 2 3
[mysqld] # 设置默认时区 default-time_zone='+8:00'
MacOS 版本安装
1
brew install mysql # 使用 homebrew 安装
安装完毕的时候,终端回给出提示,最后的那段话比较值得注意
1 2 3 4 5 6 7 8 9 10 11 12
We've installed your MySQL database without a root password. To secure it run: mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run: mysql -uroot
To have launchd start mysql now and restart at login: brew services start mysql Or, if you don't want/need a background service you can just run: mysql.server start
翻译成人话就是
DB 安装成功,但是数据库 root 用户是没有密码的,你直接登陆会失败
运行 mysql_secure_installation 给数据库设置密码
使用命令 mysql -uroot 联接数据库
后台启动使用 brew services start mysql 前台启动使用 mysql.server start
VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
## 是否进行安全设置 Press y|Y for Yes, any other key for No: y
There are three levels of password validation policy:
LOW Length >= 8 MEDIUM Length >= 8, numeric, mixed case, and special characters STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
## 设置密码复杂度,最低也要 *8* 位密码起步 Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0 Please set the password for root here.
New password:
Re-enter new password:
Estimated strength of the password: 50 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.
## 是否删除匿名用户 Remove anonymous users? (Press y|Y for Yes, any other key for No) : y Success.
Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network.
## 是否开放 root 用户远程访问 Disallow root login remotely? (Press y|Y for Yes, any other key for No) :
... skipping. By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment.
## 是否删除测试表 Remove test database and access to it? (Press y|Y for Yes, any other key for No) :
... skipping. Reloading the privilege tables will ensure that all changes made so far will take effect immediately.
## 是否重新加载使得配置生效 Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y Success.
All done!
设置完毕之后就可以使用 mysql -uroot -p 登陆测试了。没有遇到其他问题,还挺顺利的 ε-(´∀`; )