目录
win安装绿色版 MySQL 5.7
一、下载安装服务
1.1. 下载解压
我的解压路径为:
D:EnvMySQLmysql-5.7.24-winx64
1.2. 配置环境变量
- 变量名:
MYSQL_HOME
- 变量值:
D:EnvMySQLmysql-5.7.24-winx64
- path里添加:
%MYSQL_HOME%in
1.3. 新建my.ini
文件
[mysql]
default-character-set=utf8
[mysqld]
basedir=D:EnvMySQLmysql-5.7.24-winx64
datadir=D:DataBaseMySQLData
port=3306
max_connections=200
character-set-server=utf8
default-storage-engine=INNODB
skip-grant-tables
1.4. 安装服务命令
管理员打开CMD:
# 初始化
mysqld --initialize
# 安装卸载服务
mysqld -install
mysqld -remove
# 启动停止mysql
net start mysql
net stop mysql
二、登陆创建密码
2.1. 登陆mysql
>mysql -uroot -p #无密码
mysql> update mysql.user set authentication_string=password('123456') where user='root'; # 修改密码
mysql> flush privileges; ##刷新权限
mysql> q
2.2. 注释掉my.ini
免密检查
[mysql]
default-character-set=utf8
[mysqld]
basedir=D:EnvMySQLmysql-5.7.24-winx64
datadir=D:DataBaseMySQLData
port=3306
max_connections=200
character-set-server=utf8
default-storage-engine=INNODB
#skip-grant-tables
2.3. 重新登陆【完成安装】
mysql> alter user user() identified by "123456";
三、配置无密码登陆
[client]
port = 3306
default-character-set=utf8
host=127.0.0.1
user=root
password=123456
四、忘记密码修改
4.1. 关闭mysql密码检查
net stop mysql
mysqld --skip-grant-tables
4.2.多开一个cmd窗口,登陆mysq
4.3.修改密码重启电脑
mysql> update mysql.user set authentication_string=password('123456') where user='root';
mysql> flush privileges;
mysql> q
4.4.登陆测试
>mysql -uroot -p
4.5.解决错误
mysql> alter user user() identified by "123456";
五、错误问题
5.1. msvcr120.dll丢失
安装Visual C++ Redistributable Packages
安装完成后重新执行上述步骤
5.2. ERROR 1820 (HY000)
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
声明密码
mysql> alter user user() identified by "123456";
六、版本差异
6.1.改密码
新版:
update mysql.user set authentication_string=password('123456') where user='root';
老版:
update user set password=password('新密码') where user='root'