windows10+mysql8.0.11zip安裝

準備:

MySQL8.0 Windows zip包下載地址:https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.11-winx64.zipmysql

環境:Windows 10nginx

1、安裝sql

1. 解壓zip包到安裝目錄

個人安裝目錄是D:\Program Files\mysql-8.0.11-winx64數據庫

2.配置文件

windows系統中配置文件默認是安裝目錄下的 my.ini 文件,部分配置須要在初始安裝時配置,大部分也能夠在安裝完成後進行更改,不知作別人是什麼狀況,個人是該文件目錄下不存在my.ini文件,因此我新建了該文件,以下windows

 

 寫入基本配置以下:安全

 1 [mysqld]
 2 default_authentication_plugin=mysql_native_password
 3 # Remove leading # and set to the amount of RAM for the most important data
 4 # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
 5 # innodb_buffer_pool_size = 128M
 6 
 7 # Remove leading # to turn on a very important data integrity option: logging
 8 # changes to the binary log between backups.
 9 # log_bin
10 
11 # These are commonly set, remove the # and set as required.
12 basedir=D:\Program Files\mysql-8.0.11-winx64
13 datadir=D:\Program Files\mysql-8.0.11-winx64\data(這兩行是主要修改的內容,會自動生成data文件夾,其餘直接粘貼便可) 14 port = 3306
15 # server_id = .....
16 
17 
18 # Remove leading # to set options mainly useful for reporting servers.
19 # The server defaults are faster for transactions and fast SELECTs.
20 # Adjust sizes as needed, experiment to find the optimal values.
21 # join_buffer_size = 128M
22 # sort_buffer_size = 2M
23 # read_rnd_buffer_size = 2M 
24 
25 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
26 
27 character-set-server = utf8mb4
28 
29 performance_schema_max_table_instances = 600
30 table_definition_cache = 400
31 table_open_cache = 256
32 
33 [mysql]
34 default-character-set = utf8mb4
35 
36 [client]
37 default-character-set = utf8mb4

注意,裏面的 basedir 是我本地的安裝目錄,datadir 是我數據庫數據文件要存放的位置,各項配置須要根據本身的環境進行配置。bash

 

3.初始化數據庫

在MySQL安裝目錄的 bin 目錄下執行命令:工具

.\mysqld --initialize --console

執行完成後,會打印 root 用戶的初始默認密碼,好比:ui

2018-05-01T14:35:01.507037Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2018-05-01T14:35:01.507640Z 0 [System] [MY-013169] [Server] D:\Program\MySQL8\bin\mysqld.exe (mysqld 8.0.11) initializing of server in progress as process 11064 2018-05-01T14:35:01.508173Z 0 [ERROR] [MY-010340] [Server] Error message file 'D:\Program Files\mysql-8.0.11-winx64\share\english\errmsg.sys' had only 1090 error messages, but it should contain at least 4512 error messages. Check that the above file is the right version for this program! 2018-05-01T14:35:05.464644Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: APWCY5ws&hjQ 2018-05-01T14:35:07.017280Z 0 [System] [MY-013170] [Server] D:\Program\MySQL8\bin\mysqld.exe (mysqld 8.0.11) initializing of server has completed

其中,第4行的「APWCY5ws&hjQ」就是初始密碼,在沒有更改密碼前,須要記住這個密碼,後續登陸須要用到。this

要是你手賤,關快了,或者沒記住,那也沒事,刪掉初始化的 datadir 目錄,再執行一遍初始化命令,又會從新生成的。固然,也可使用安全工具,強制改密碼,用什麼方法,本身隨意。

 

4.安裝服務

在MySQL安裝目錄的 bin 目錄下執行命令:

.\mysqld --install [服務名]

後面的服務名能夠不寫,默認的名字爲 mysql。固然,若是你的電腦上須要安裝多個MySQL服務,就能夠用不一樣的名字區分了,好比 mysql5 和 mysql8。

安裝完成以後,就能夠經過命令net start mysql啓動MySQL的服務了。 

二.更改密碼和密碼認證插件

在MySQL安裝目錄的 bin 目錄下執行命令:

 net start mysql

.\mysql -uroot -p

這時候會提示輸入密碼,記住了第3步的密碼,填入便可登陸成功,進入MySQL命令模式

在MySQL8.0.4之前,執行

SET PASSWORD=PASSWORD('[修改的密碼]');

就能夠更改密碼,可是MySQL8.0.4開始,這樣默認是不行的。由於以前,MySQL的密碼認證插件是「mysql_native_password」,而如今使用的是「caching_sha2_password」。

由於當前有不少數據庫工具和連接包都不支持「caching_sha2_password」,爲了方便,我暫時仍是改回了「mysql_native_password」認證插件。

在MySQL中執行命令:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';(注意必定要有分號)(注意必定要有分號)

修改密碼驗證插件,同時修改密碼。

若是想默認使用「mysql_native_password」插件認證,能夠在配置文件中配置default_authentication_plugin項。

[mysqld] default_authentication_plugin=mysql_native_password

相關文章
相關標籤/搜索