Error:Connection to [email protected] failed. [08001] Could not create connection to database server

前几天心血来潮,为了好看的pycharm界面风格,就手欠升级了2019版本的pycharm,然后。。。然后就出现了这样的情况

Error:Connection to [email protected] failed. [08001] Could not create connection to database server

 

怎么就连不上,明明前几天还可以,于是呢,我就想到了会不会是新版的问题,于是就开始百度了。。。
就这样翻着一条又一条的方法,和同桌两个呕心沥血地尝试,更新、修改URL。。。等等,就差没卸载然后重新安装MySql了

遇到说的最多的问题就是:时区问题,可我也看不懂啊~反正就跟着试,下载新的驱动,等等等等,然后这个方法就显示连接成功了

Error:Connection to [email protected] failed. [08001] Could not create connection to database server

终于,不泛红了,连接成功了~

Error:Connection to [email protected] failed. [08001] Could not create connection to database server

 

看着成功了,但总感觉好像哪里不对劲,我也不能每次连接都要去修改URL吧,果不其然,连接上之后,就是这样了。。。

 Error:Connection to [email protected] failed. [08001] Could not create connection to database server

what?这是什么嘛,我的表呢~什么乱七八糟的啊~!我表示很无助还很焦虑 <!> 哈哈哈

最后真的尝试了太多太多,让我找到了这个方法,接下来,我们进入正题,完美的解决办法!

1. 检查user和password是否有错
2. 检查连接池是否正确,新版的8.0版的mysql连接池应该是

Error:Connection to [email protected] failed. [08001] Could not create connection to database server

3. 试试更改区时(往往问题都是出现在这)
    a. 在终端里先使用管理员登录mysql,也就是root
    mysql   -uroot   -p123
    b. 输入命令
    show variables like '%time_zone%'

Error:Connection to [email protected] failed. [08001] Could not create connection to database server

    c. Mysql默认为美国时间,我国时区要晚8小时,因此修改时间即可
    set global time_zone = '+8:00' ;       

Error:Connection to [email protected] failed. [08001] Could not create connection to database server

    d. 设置完以后,退出mysql,重新登录,检查时间是否被修改
4. 结束之后就可以退出cmd,去pycharm里面重新连接看看

所以,最好还是不要升级为新版本,因为说不定哪天就会蹦出一个新的bug让你措手不及