Windows 下安裝 MySQL 5.7

1. 解壓

image.png

2. 環(huán)境變量

新增環(huán)境變量 MYSQL_HOME


image.png

追加環(huán)境變量 PATH


image.png

3. 配置文件內(nèi)容

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
basedir = D:\workingSoftware\mysql-5.7.17-winx64
datadir = D:\workingSoftware\mysql-5.7.17-winx64\data
# port = .....
# server_id = .....

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

安裝和初始化

進入 mysql 的 bin 文件夾以管理員身份運行 cmd

執(zhí)行 mysqld install,在服務(wù)中會出現(xiàn) MySQL 服務(wù)(如果不用管理員身份運行,將會因為權(quán)限不夠而出現(xiàn)錯誤:Install/Remove of the Service Denied!)
(Windows 移除服務(wù)命令:sc delete mysql)

image.png
image.png

執(zhí)行 mysqld --initialize --console (此時會在 mysql 根目錄下生成 data 文件夾)

image.png
image.png

“qZ*Hyh=-u59=” 為 root 賬號初始密碼,記住這個密碼。
如果忘記或者沒記住,刪掉初始化的 data 目錄,再執(zhí)行一遍初始化命令(mysqld --initialize --console),又會重新生成。當(dāng)然也可以使用安全工具強制改密碼,用什么方法,自己隨意。

啟動 MySQL

cmd 中繼續(xù)輸入 net start mysql 啟動 mysql

image.png

停止 MySQL:net stop mysql

修改 MySQL 賬號密碼

登錄(密碼是生成的 “qZ*Hyh=-u59=”)
mysql -uroot -p

image.png

修改密碼執(zhí)行以下命令:
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
flush privileges;

image.png

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容