[mysqld] #skip-grant-tables # These are commonly set, remove the # and set as required. basedir=D:/mysql datadir=D:/mysql/data tmpdir=D:/mysql/data port = 3306
4. 以管理员身份运行CMD,运行:D:\mysql\bin\mysqld install
5. 初始化data目录(运行此命令前,不要建立data目录):D:\mysql\bin\mysqld--initialize
6. 将mysql 安装为服务: D:\mysql\bin\mysqld install
7. 运行mysql服务:net start mysql
8. \bin目录下输入mysql -uroot -p ,默认是没有密码的,出现ERROR 1045 (28000): Access denied for user'root'@'localhost'(using password: YES)的错误。
解决办法:将my.ini中mysql
#skip-grant-tables
更改成:sql
skip-grant-tables
重启mysql服务,就能够进入。ui
9. 修改密码:
MySQL 5.7.6以及最新版本:spa
# mysql> UPDATE USER SET authentication_string=PASSWORD('123456'),`password_expired`='N' WHERE USER='root';
Mysql 5.7.5或更早版本:code
# mysql> update user set password=PASSWORD('newpass') where User='root';
10. 还原第8步的更改,重启mysql服务。ip