phpmyadimin连接mysql8.0

在尝试使用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。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在安装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都可
找到— c f g [ ′ S e r v e r s ′ ] [ cfg['Servers'][ cfg[Servers][i][‘host’] = ‘localhost’;
改成— c f g [ ′ S e r v e r s ′ ] [ 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‘@’%’

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值