包括功能:
端口,是否啟用bin log , 指定目錄, InnoDB是否啟用壓縮,MySQL使用舊的密碼驗證方式.
說明,建表的時候要添加必要的參數才會啟用表數據壓縮存儲,以下為例:
CREATE TABLE `win008` ( `id` int(11) DEFAULT NULL, `name` char(50) DEFAULT NULL, `note` varchar(255) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4
關於初始化安裝,請參考 http://www.cnblogs.com/laumians-notes/p/9069498.html 不再累贅 .
[mysqld] #是否啟用bin log skip-log-bin # 設置3306端口 port=3306 # 設置mysql的安裝目錄 basedir=D:\\webserver\\mysql\\mysql-8.0.12-winx64 # 切記此處一定要用雙斜杠\\,單斜杠我這里會出錯 # 設置mysql數據庫的數據的存放目錄 datadir=D:\\webserver\\mysql\\data\\mysql8 # 允許最大連接數 max_connections=20 # 允許連接失敗的次數。這是為了防止有人從該主機試圖攻擊數據庫系統 max_connect_errors=10 # 服務端使用的字符集默認為UTF8 character-set-server=utf8mb4 # 默認使用“mysql_native_password”插件認證 default_authentication_plugin=mysql_native_password #InnoDB# # 創建新表時將使用的默認存儲引擎 default-storage-engine=INNODB innodb_buffer_pool_size=2G #innodb_additional_pool_size=20M innodb_log_file_size=256M innodb_log_buffer_size=12M innodb_flush_log_at_trx_commit=2 #innodb_flush_method #thread_cache=8 #innodb_autoextend_increment=128M #這里確認是否起用壓縮存儲功能 innodb_file_per_table=1 #innodb_file_format=barracuda #mysql 8 不支持該功能 #決定壓縮程度的參數,如果你設置比較大,那么壓縮比較多,耗費的CPU資源也較多; #相反,如果設置較小的值,那么CPU占用少。默認值6,可以設置0-9# innodb_compression_level=6 #指定在每個壓縮頁面可以作為空閑空間的最大比例, #該參數僅僅應用在設置了innodb_compression_failure_threshold_pct不為零情況下,並且壓縮失敗率通過了中斷點。 #默認值50,可以設置范圍是0到75 innodb_compression_pad_pct_max=50 [mysql] # 設置mysql客戶端默認字符集 default-character-set=utf8 [client] # 設置mysql客戶端連接服務端時默認使用的端口 port=3306 default-character-set=utf8
接下來初始化數據環境:
mysqld --initialize --user=mysql --console
大概會得到如下結果:
C:\Users\Administrator>mysqld --initialize --user=mysql --console 100 200 100 200 2019-04-20T14:41:31.854709Z 0 [System] [MY-013169] [Server] C:\mysql-8.0.15-winx 64\bin\mysqld.exe (mysqld 8.0.15) initializing of server in progress as process 13720 2019-04-20T14:42:13.645099Z 5 [Note] [MY-010454] [Server] A temporary password i s generated for root@localhost: F-/Yn%lhd3,K 2019-04-20T14:42:24.641728Z 0 [System] [MY-013170] [Server] C:\mysql-8.0.15-winx 64\bin\mysqld.exe (mysqld 8.0.15) initializing of server has completed
從中可以得到初始化數據的root的密碼,接下來繼續安裝和啟動服務:
C:\Users\Administrator>mysqld --install Service successfully installed. C:\Users\Administrator>net start mysql MySQL 服務正在啟動 .... MySQL 服務已經啟動成功。
登錄並修改原始密碼:
C:\Users\Administrator>mysql -uroot -p Enter password: ************ Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 11 Server version: 8.0.15 Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> ALTER USER "root"@"localhost" IDENTIFIED BY "123456"; Query OK, 0 rows affected (0.40 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)