1.下载Mysql,5.7版本,将zip包解压到某个安装目录下面,最好不要放C盘,选择一个容量大的磁盘。下载地址:https://dev.mysql.com/downloads/mysql/
2.进入解压后的目录,找到my.ini文件,修改basedir与datadir两个参数,本例如下:
basedir = D:MySQLmysql-5.7.15
datadir = D:MySQLmysql-5.7.15data
- 1
- 2
3.打开命令行窗口,进入D:MySQLmysql-5.7.15in下,依次运行
mysqld.exe --install MySQL
mysqld.exe --initialize
net start mysql
- 1
- 2
- 3
4.Mysql启动成功,root初始密码保存在datadir 配置的目录下后缀名为err的文件中
5.运行下面命令进入mysql命令行
mysql -u root -p
- 1
6.修改root密码
alter user 'root'@'localhost' identified by 'root';
- 1
在5.6后,mysql内置密码增强机制,低强度密码会报错:
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
7.配置root远程登录
use mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;