配置环境变量,在环境变量Path中添加
C:\Program Files\MySQL\mysql-8.0.19\bin
管理员模式打开命令行
mysqld install mysql # 安装mysql,默认
mysqld --initialize --console # 初始化data文件(数据库的存放文件),--console可以显示过程,其中含有初始化的root密码;不要自己创建data文件
net start mysql
进入mysql
mysql -uroot -p # 回车
# 输入上面初始化的密码
进行操作之前改密码
alter user 'root'@'localhost' identified by "password";
改变root的plugin(选做)
alter user 'root'@'localhost' identified with mysql_native_password by "root";
alter user 'root'@'localhost' identified with caching_sha2_password by "root";
MySQL8默认的认证插件是caching_sha2_password,很多客户端都不支持,可将默认的认证插件修改为mysql_native_password,在配置文件中配置default_authentication_plugin=mysql_native_password。
我下载的8.0.19找不到my.ini的配置文件,无论是在mysql目下,mysql/data目录下,还是ProgramData目录下,即使是在显示隐藏文件的情况下,不过在mysql下放置一个my.ini进行配置是能被识别的,有必要的话可以自己创建一个。