一.下载
下载地址:点击进入
二. 安装
1.解压
2.添加环境变量
我的电脑->属性->高级系统设置->高级->环境变量->系统变量
3. 在安装目录下创建my.ini文件
4.编辑my.ini,写入以下代码:
复制:
[mysqld]
basedir=D:\mysql-8.0\
datadir=D:\mysql-8.0\data\
port=3306
保存,退出!
5.管理员运行命令行
6. 删除mysql服务(避免有安装过,或者安装失败过等问题,不管成功与否都可以)
sc delete mysql
7.切换路径到mysql的安装目录(如果不能直接cd到bin目录的话,就先切到D盘,再切bin目录)
一行行复制按回车
d: //切换盘符到D
cd mysql-8.0\bin //切换到bin目录下
mysqld –install //安装mysql
mysqld --initialize-insecure --user=mysql //初始化数据文件
net start mysql //启动mysql服务
结果如下图:
8.进入管理界面
mysql –u root –p //进入mysql管理界面(密码不用写),再按回车
9.继续输入
update mysql.user set authentication_string=password('123456') where user='root' and Host = 'localhost';
如果报
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘(“123456”) where user=“root”’ at line 1
这个错误的话运行以下代码:
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
ok