pycharm连不上数据库:报警代码Connection to api@localhost failed. [08001] Could not create connection to d
pycharm 换成2019之后连接数据库用户名密码数据库名字都没错,就是连接不上去,网上百度一下,试试将URL后面拼接
?useSSL=false&serverTimezone=UTC
发现终于可以了 也连接上去了,但是每一次都要自己设置一下???
完美解决办法,新版的8.0版的mysql连接池应该是 以前的5.7版本是com.mysql.jdbc.Driver
试试更改时区时(往往问题都是出现在这)
a. 在终端里先使用管理员登录mysql,也就是root
mysql -uroot -p123
b. 输入命令
show variables like '%time_zone%'

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

d. 设置完以后,退出mysql,重新登录,检查时间是否被修改
结束后就退出cmd,去pycharm里面重新连接看看
所以,最好还是不要升级为新版本,因为说不定哪天就会蹦出一个新的bug让你措手不及
Django 连接mysql数据库
cmd中使用python3 manage.py migrate命令,报warn
WARNINGS:
?: (mysql.W002) MySQL Strict Mode is not set for database connection 'default'
HINT: MySQL's Strict Mode fixes many data integrity problems in MySQL, such as data truncation upon insertion, by escalating warnings into errors. It is strongly recommended you activate it. See: https://docs.djangoprojec
t.com/en/dev/ref/databases/#mysql-sql-mode
解决办法:settings.py文件夹加入DATABASES['OPTIONS']['init_command'] = "SET sql_mode='STRICT_TRANS_TABLES'"
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'django_test',
'USER':'root',
'PASSWORD':'',
'HOST':'localhost',
'PORT':'3306',
#下面是新加入的
'OPTIONS':{
'init_command':"SET sql_mode='STRICT_TRANS_TABLES'",
'charset':'utf8mb4',
},
}
pycharm连不上数据库:报警代码Connection to api@localhost failed. [08001] Could not create connection to d的更多相关文章
- 关于Django数据库mysql连接错误问题Connection to api@localhost failed. [08001] Could not create connection to d
Connection to api@localhost failed. [08001] Could not create connection to d 错误类型 django连接mysql数据库错误 ...
- Connection to api@localhost failed. [08001] Could not create connection to d
pycharm 换成2019之后连接数据库用户名密码数据库名字都没错,就是连接不上去,网上百度一下,试试将URL后面拼接 ?useSSL=false&serverTimezone=UTC 发现 ...
- pycharm2019连接mysql错误08801 ------Connection to django1@localhost failed. [08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.
Error:Connection to django1@localhost failed. [08001] Could not create connection to database server ...
- IntelliJ IDEA连接不上数据库 (Connection to testdb@localhost failed. [08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.)
问题提示为: 原因:MySQL数据库版本为8.0以上,需要在URL加上时区,即加上?serverTimezone=GMT 成功后为:
- pycharm2019连接mysql错误:08801 ------Connection to django1@localhost failed. [08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.
- Connection to 天mysql failed. [08001] Could not create connection to database server. Attempted ,报错处理方法
https://blog.csdn.net/myzh215219/article/details/90314345 点击图上的DRIVER,然后点击GO TO DRIVER,之后更改合适的驱动. 我的 ...
- pycharm连接mysql是出现Connection to orm02@127.0.0.1 failed. [08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.
下面这个问题反正我是遇到了,也是难为我好几天,于是我决定发一个教程出来给大家看看!希望能帮助你们 原因: 可能是数据库的版本与本机装的驱动不匹配导致的, 解决方案一: 在 url 后面街上一句 因为笔 ...
- Connection to newtaotao failed. [08001] Could not create connection to database
jdbc.url=jdbc:mysql://localhost:3306/newtaotao?serverTimezone=UTC&characterEncoding=utf-8 数据库是5. ...
- 解决Connection to Xxx@localhost failed.
解决: Connection to jianshu@localhost failed. [08001] Could not create connection to database server. ...
随机推荐
- ORM之Entity Framework(EF)
ORM之Entity Framework(EF) 一.下载安装: nuget 搜索Entity Framework安装 EntityFramework.Extension是个扩展库根据需要安装 二.使 ...
- expect脚本自动获取root权限
Linux脚本中有很多场景是进行远程操作的,例如远程登录ssh.远程复制scp.文件传输sftp等.这些命令中都会涉及到安全密码的输入,正常使用命令时是需要人工手动输入密码并接受安全验证的.为了实现自 ...
- Spring通过注解获取所有被注解标注的Beans
Spring提供的方法:Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> annot ...
- IScroll中div点击事件触发两次解决办法
1.网上的同学说的,直接修改源代码,但是这种方法可能会影响到现有的程序. 搜索onBeforeScrollStart方法,将其中的preventDefault禁止掉搜索_end方法,将其中模拟clic ...
- 一个刚入行的BIOS工程师的自我简介
现在是北京时间2019年11月28日,大学毕业已经工作四个多月.说来也是奇怪,大学里面明明主修机械电子工程,几乎是纯机械方向,毕业之后的工作却与主修的课程毫无关系.因为对机械这一行业毫无兴趣,大学里面 ...
- U9数据权限分配枚举值方法
1.配置动态视图,定位应用对应控制实体,并设置动态视图类型:读取 或 增.删.改: 2.设置动态视图条件:MOPickList.MO.DocState.Value in (FunEnum('生产订单单 ...
- MySQL面试题及答案整理,史上最全!
原文链接:https://juejin.im/post/5d351303f265da1bd30596f9 前言 本文主要受众为开发人员,所以不涉及到MySQL的服务部署等操作,且内容较多,大家准备好耐 ...
- DotnetSpider爬虫简单示例 net core
文章地址 https://blog.csdn.net/sD7O95O/article/details/78097556 安装爬虫框架 NUGET 安装DotnetSpider 创建HTTP协议数据包 ...
- kafka集群安全化之启用kerberos与acl
一.背景 在我们部署完kafka之后,虽然我们已经可以“肆意”的用kafka了,但是在一个大公司的实际生产环境中,kafka集群往往十分庞大,每个使用者都应该只关心自己所负责的Topic,并且对其他人 ...
- Python中的单例设计
01. 单例设计模式 设计模式 设计模式 是 前人工作的总结和提炼,通常,被人们广泛流传的设计模式都是针对 某一特定问题 的成熟的解决方案 使用 设计模式 是为了可重用代码.让代码更容易被他人理解.保 ...