windows下安装MysqL
1,下载解压MysqL压缩包到指定目录
2,使用命令(执行这个命令不使用管理员身份打开)MysqLd --initialize --console
完成初始化操作,这部会出现一个root账户的临时密码(在win7下,光标选中就是已经复制到了剪贴板,在文本编辑器中打开就好了)
3,使用命令(使用管理员身份打开才能执行否则会报Install/Remove of the Service Denied)MysqLd -install
安装MysqL
4,使用命令net start MysqL
开启数据库服务
5,使用第3步的临时密码登录数据库
6,使用命令ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘[email protected]‘;
来修改root密码,MysqL8设定必须是强密码(包含大小字母,数字,特殊符号)
7,flush privileges
按照顺序也没添加my.ini文件
注意:修改后输入MysqL密码的时候不要用小键盘输入,可能被误认为是方向操作
完成,localhost就可以正常使用了
使用其他机器连接not allowed to connect to this MysqL server错误
1,在安装MysqL数据库的主机上登录root用户:MysqL -u root -p
2,依次执行如下命令:
use mysq; select host from user where user=‘root‘;
可以看到当前主机配置信息为localhost.
3,执行update user set host = ‘%‘ where user =‘root‘;
将Host设置为通配符%,Host设置了“%”后便可以允许远程访问。
4,Host修改完成后记得执行flush privilegs
使配置立即生效。
使用Navicat连接时报错信息:MysqL 8 plugin caching_sha2_password could not be loaded
原因,认证方面问题,使用root登录,执行:
alter user ‘root‘@‘%‘ identified by ‘[email protected]‘ password expire never; alter user ‘root‘@‘%‘ identified with MysqL_native_password by ‘[email protected]‘; flush privileges; alter user ‘root‘@‘%‘ identified by ‘[email protected]‘;
官方说明:https://dev.MysqL.com/doc/refman/8.0/en/upgrading-from-prev@R_404_437@s-series.html#upgrade-caching-sha2-password