1旅掂、下載解壓
https://dev.mysql.com/downloads/windows/installer/8.0.html
2、配置環(huán)境變量
在path中添加剛才解壓的路徑到bin這個(gè)層級
3、修改my-default.ini,假如以下內(nèi)容
basedir = D:\Software\mysql-5.6.38-winx64
datadir = D:\Software\mysql-5.6.38-winx64\data
4汁蝶、以管理員身份運(yùn)行cmd(注意使用管理員身份,推薦PowerShell)次泽,并且進(jìn)入到解壓路徑的bin目錄下
mysqld --initialize-insecure #初始化數(shù)據(jù)庫穿仪,默認(rèn)密碼為空
mysqld install #為Windows系統(tǒng)安裝MySQL服務(wù)
sc query mysql #可選,查看一下名為mysql的服務(wù)
sc delete mysql #刪除數(shù)據(jù)庫服務(wù)
net start mysql #啟動(dòng)數(shù)據(jù)庫
mysql -u root -p #連進(jìn)數(shù)據(jù)庫
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'yourpassword'; #mysql8需要用到
set password for 'root'@'localhost'=password('password!'); #低于mysql8的可以使用這個(gè)直接設(shè)置
grant all on *.* to root@'%' identified by 'password' with grant option; #允許遠(yuǎn)程連接
flush privileges;