前言
在學(xué)習(xí)任何一個后端技術(shù),如果不讓數(shù)據(jù)庫參與進(jìn)來,那只能說在學(xué)習(xí)過程中都不算完整的。
以前用的是5.7版本的mysql,在學(xué)習(xí)實(shí)踐springboot的時候順帶升級了一下8.0,遇到了一些坑,在這記錄一下,有碰到同類問題的童鞋需要自取。
下面話不多說了,來一起看看詳細(xì)的介紹吧
1、使用 navicat連接發(fā)現(xiàn)報錯1251- client does not support authentication protocol 錯誤
這個筆者查詢資料發(fā)現(xiàn)是新版本的加密規(guī)則變了,在mysql8之后,加密規(guī)則是caching_sha2_password,之前的是mysql_native_password,所以解決辦法要不就是升級navicat要不就是修改加密規(guī)則。
這里修改加密規(guī)則:
1.進(jìn)入mysql的bin目錄打開cmd,然后輸入mysql -u root -p,輸入密碼
2.然后輸入
1
2
3
4
5
|
alter user 'root' @ 'localhost' identified by 'password' password expire never; #修改加密規(guī)則 alter user 'root' @ 'localhost' identified with mysql_native_password by '輸入你的密碼' ; #更新一下用戶的密碼 flush privileges; #刷新權(quán)限 |
2、mysql8.0)could not create connection to database server - java mysql connector
這是因為沒有更新驅(qū)動的原因,在maven中更新下mysql-connector的版本
1
2
3
4
5
6
7
8
9
|
<!-- mysql 連接驅(qū)動依賴 --> <dependency> <groupid>mysql</groupid> <artifactid>mysql-connector-java</artifactid> <version> 8.0 . 11 </version> </dependency> <!--properties文件中更改driver--> spring.datasource.driver- class -name=com.mysql.cj.jdbc.driver |
3、使用jdbc連接mysql時出現(xiàn):the server time zone value '?й???????' is unrecognized or represents more than one time zone. you must configure either the server or jdbc driver (via the servertimezone configuration
這是mybatis時區(qū)錯誤,在鏈接庫的url中加servertimezone=utc
1
|
spring.datasource.url=jdbc:mysql: //localhost:3306/axin?useunicode=true&characterencoding=utf8&servertimezone=utc |
總結(jié)
以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,如果有疑問大家可以留言交流,謝謝大家對服務(wù)器之家的支持。
原文鏈接:http://www.cnblogs.com/keeya/p/9786403.html