參考:
https://jingyan.baidu.com/article/63f236284aca280208ab3dcc.html
下載地址(清華大學鏡像站):https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.7/mysql-5.7.21-winx64.zip
1 bin下編輯my.ini,內容如下
[mysqld]
basedir=D:\mysql-5.7.21-winx64
datadir=D:\mysql-5.7.21-winx64\data
port=3306
character-set-server=utf8
[client]
port=3306
character-set=utf8
2 配置環境變量,在path中添加解壓路徑
3 啓動
以管理員身份運行cmd
輸入cd D:\mysql-5.7.21-winx64\bin進入bin目錄下輸入mysqld --initialize --user=mysql --console
記下最後一行產生的隨機密碼
成功會顯示Servers Successfully installed
控制檯下輸入net start mysql 啓動mysql服務
4 可使用mysql -uroot -p命令來登錄數據庫,密碼爲上一步中生成的隨機密碼
使用如下語句用於更新密碼
alter user 'root'@'localhost' identified by 'root'
或者如下
update user set authentication_string = password('root'), password_expired = 'N', password_last_changed = now() where user = 'root';