在安装mysql8.0并配置以后,使用phpmyadimin连接mysql会有以下两种常见的错误:
1.mysqli_real_connect(): (HY000/2002): No such file or directory
这是因为不能使用localhost要用ip登陆
*解决方法:
1)phpmyadmin的配置文件【config.sample.inc.php】改成【config.inc.php】
2)用终端或者sublime都可
找到— cfg[′Servers′][cfg['Servers'][cfg[′Servers′][i][‘host’] = ‘localhost’;
改成— cfg[′Servers′][cfg['Servers'][cfg[′Servers′][i][‘host’] = ‘127.0.0.1’;
这个时候如果安装的是mysql8.0以上的版本就会出现另两个个问题:
2.mysqli_real_connect(): The server requested authentication method unknown to the client [caching_sha2_password]
3.mysqli_real_connect(): (HY000/2054): The server requested authentication method unknown to the client
这是因为无法请求身份验证
*解决方法:
1)先用终端打开mysql
2)查看host
当中root的host为localhost
3)使用密码更改身份验证插件
以下示范了错误和正确的用法:
语法规则:
alter user ‘root’@‘localhost’ identified with mysql_native_password by ‘自己设置的数据库密码’
*如果在2)步中的查询root的host为"%"

则‘root‘@’localhost’ ➡️ ‘root‘@’%’
在尝试使用phpmyadmin连接mysql8.0时,可能会遇到'No such file or directory'和'身份验证方法未知'的错误。解决方法包括将config.sample.inc.php更改为config.inc.php,并将localhost替换为127.0.0.1。对于身份验证问题,可以使用ALTER USER语句更改root用户的认证插件为mysql_native_password。
1万+

被折叠的 条评论
为什么被折叠?



