php后台接不上mysql数据库,查看phpinfo,mysql驱动正常。
查看日志
发现配置正确,连接被拒,猜想可能是用户权限的问题
进入数据库查看用户和权限
[[email protected] wezchina]# mysql -h 192.168.2.100 -P 3306 -uSbsBL6tnULzkI21 -p Enter password: ERROR 1045 (28000): Access denied for user ‘user‘@‘MyCloudServer‘ (using password: YES) [[email protected] wezchina]# mysql -u root -p 发现ip地址被解析为主机名并被拒
mysql> select user,host from mysql.user; +-----------------+---------------+ | user | host | +-----------------+---------------+ | SbsBL6tnULzkI21 | % | | root | 127.0.0.1 | | SbsBL6tnULzkI21 | 192.168.2.* | | root | ::1 | | | localhost | | SbsBL6tnULzkI21 | localhost | | root | localhost | | | mycloudserver | | SbsBL6tnULzkI21 | mycloudserver | | root | mycloudserver | +-----------------+---------------+ 10 rows in set (0.00 sec) 查看用户host,发现主机名是小写 在/etc/hosts文件添加以下解析 192.168.2.100 mycloudserver MyCloudServer 登录 正常
时间: 2024-11-03 03:24:13