windows下mysql8初始化

去官網下載mysql的壓縮包解壓。
切換到 mysql/bin目錄下,運行 mysqld --initialize進行mysql的初始化。或者
mysqld --initialize --user=mysql --console
等運行完畢後,會在bin的上級目錄生成一個data文件夾。
找到該目錄下的app.err文件,使用文本編輯工具打開:裏面內容如下:

2018-12-06T09:19:29.189445Z 0 [System] [MY-013169] [Server] D:\mysql\bin\mysqld.exe (mysqld 8.0.12) initializing of server in progress as process 72472
2018-12-06T09:19:35.585456Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: tH*Kik6-!Bft
2018-12-06T09:19:40.374665Z 0 [System] [MY-013170] [Server] D:\mysql\bin\mysqld.exe (mysqld 8.0.12) initializing of server has completed
2018-12-06T09:22:51.428200Z 0 [System] [MY-010116] [Server] D:\mysql\bin\mysqld.exe (mysqld 8.0.12) starting as process 71876

找到A temporary password is generated for root@localhost: 後面就是生成的root的臨時密碼,用該密碼登錄後,修改root密碼。

ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword';

授權方面8.0與以前版本差別比較大。
8.0版本不再自動創建用戶,需要先創建用戶再授權。

create user 'mytest'@'%' identified by 'mytest';
#再進行授權
grant all privileges on *.* to 'mytest'@'%' with grant option;

運行 mysqld.exe --install MySQL將mysql註冊爲windows服務。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章