天天看點

9.2MySQL@windows安裝、解除安裝、常見報錯

一、安裝資料庫

1.下載下傳位址

https://dev.mysql.com/downloads/installer/

9.2MySQL@windows安裝、解除安裝、常見報錯
9.2MySQL@windows安裝、解除安裝、常見報錯

2.點選安裝包

9.2MySQL@windows安裝、解除安裝、常見報錯
9.2MySQL@windows安裝、解除安裝、常見報錯
9.2MySQL@windows安裝、解除安裝、常見報錯
9.2MySQL@windows安裝、解除安裝、常見報錯
9.2MySQL@windows安裝、解除安裝、常見報錯
9.2MySQL@windows安裝、解除安裝、常見報錯
9.2MySQL@windows安裝、解除安裝、常見報錯
9.2MySQL@windows安裝、解除安裝、常見報錯
9.2MySQL@windows安裝、解除安裝、常見報錯
9.2MySQL@windows安裝、解除安裝、常見報錯

二、安裝問題:

1.卡在了starting server

先放在那,然後打開控制台\管理工具\服務找到mysql

9.2MySQL@windows安裝、解除安裝、常見報錯
9.2MySQL@windows安裝、解除安裝、常見報錯

右鍵屬性自動改成手動

9.2MySQL@windows安裝、解除安裝、常見報錯

登入選擇本地使用者

9.2MySQL@windows安裝、解除安裝、常見報錯

最後在接着執行execute,就會發現服務可以啟動了

三、遠端連接配接資料庫

四、用sqlyog連接配接Mysql報錯

9.2MySQL@windows安裝、解除安裝、常見報錯
9.2MySQL@windows安裝、解除安裝、常見報錯

1.使用mysql資料庫

use mysql

2.檢視root使用者加密規則

select host, user, authentication_string, plugin from user;

3.修改密碼

ALTER USER 'root'@'localhost' IDENTIFIED BY '123456' PASSWORD EXPIRE NEVER;

4.修改root使用者加密規則

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';

5.重新整理

FLUSH PRIVILEGES;

6.檢視是否修改成功

select host, user, authentication_string, plugin from user;

六、資料庫檔案預設存儲在C槽,我想移到别處:

電腦系統重裝,之前在C槽儲存的資料都沒了,還沒備份............

9.2MySQL@windows安裝、解除安裝、常見報錯
9.2MySQL@windows安裝、解除安裝、常見報錯
9.2MySQL@windows安裝、解除安裝、常見報錯
9.2MySQL@windows安裝、解除安裝、常見報錯
9.2MySQL@windows安裝、解除安裝、常見報錯
9.2MySQL@windows安裝、解除安裝、常見報錯
9.2MySQL@windows安裝、解除安裝、常見報錯
9.2MySQL@windows安裝、解除安裝、常見報錯

七、項目連mysql8報錯!!連接配接池時druid!!!

1.異常:com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException

這個錯誤的原因時資料庫驅動版本不比對問題,找到pom檔案中相關配置,改掉

Mysql驅動要等于或高于mysql版本,暫時最新版時8.0.17和我安裝的mysql版本一緻

<dependency>

<groupId>mysql</groupId>

<artifactId>mysql-connector-java</artifactId>

<version>8.0.17</version>

</dependency>

Druid版本聽說要在1.1.0以上,為了保險直接用了最新版

<dependency>

<groupId>com.alibaba</groupId>

<artifactId>druid</artifactId>

<version>1.1.19</version>

</dependency>

2.異常:java.sql.SQLNonTransientConnectionException

這個錯誤時配置檔案url有問題,可以參考下面這個配置

spring.datasource.url=jdbc:mysql://127.0.0.1:3306/test?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true&characterEncoding=UTF-8

舊版本,MySQL Connector/J 5.x 版本的連接配接方式:

url = jdbc:mysql://localhost:3306/thrcloud_db01?useUnicode=true&characterEncoding=utf8

driver-class-name = com.mysql.jdbc.Driver

例如:

注意jar包:是5的版本

Class.forName("com.mysql.jdbc.Driver");

Connection connection = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/blog?useUnicode=true&characterEncoding=utf8", "root", "root");

新版本,MySQL Connector/J 6.x之後 的連接配接方式:

url = jdbc:mysql://localhost:3306/thrcloud_db01?serverTimezone=UTC&characterEncoding=utf8&useUnicode=true&useSSL=false

driver-class-name = com.mysql.cj.jdbc.Driver

例如:

注意jar包:是8的版本

Class.forName("com.mysql.cj.jdbc.Driver");

Connection connection = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/blog?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useUnicode=true&useSSL=false", "root", "root");

3.還有一個注意點:

資訊:Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.

這隻是一條提示資訊,意思是由于mysql版本高`com.mysql.jdbc.Driver'棄用了,要改為`com.mysql.cj.jdbc.Driver',但是系統已經幫你自動加載了,并不影響啥,但是為了保險還是把驅動配置改一下吧

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

八、忘記密碼