测试使用操作系统为Win10 x64
1.下载
前往官网下载MySQL Server(https://dev.mysql.com/downloads/mysql/)
下载完成后解压到自定义目录

2.设置环境变量
将mysql8 的bin目录的绝对路径添加到path环境变量

3.执行初始化命令
以管理员身份在mysql的bin命令下执行mysqld --initialize --console
执行成功后会给mysql的root用户分配默认密码

执行成功后会在mysql目录中初始化个data目录

4.注册于启动mysql服务
- 注册服务使用
mysqld -install
删除则是mysqld -remove
- 启动服务使用
net start mysql
停止则是net stop mysql

5.连接mysql
我这里用Navicat来连接mysql
输入相关信息后连接mysql

第一次连接可能会提示重新修改密码

6.关于修改root密码
在mysql8.0.4开始修改密码使用
ALTER USER ['root'@'localhost'](mailto:'root'@'localhost') IDENTIFITED BY 'newpassword'
因为之前,MySQL的密码认证插件是mysql_native_password,而现在使用的是caching_sha2_password。
所以注意不要采取如下形式该密码
update user set authentication_string="newpassword" where user="root";
`
当然啦你也可以创建用户将密码认证方式设置成mysql_native_password

网友评论