XAMPP MySQL 说:无法连接:无效设置

Posted

技术标签:

【中文标题】XAMPP MySQL 说:无法连接:无效设置【英文标题】:XAMPP MySQL said: Cannot connect: invalid settings 【发布时间】:2019-11-19 18:06:40 【问题描述】:

mysql 工作正常,然后每当我打开 http://localhost/phpmyadmin/ 时,我就会无缘无故地开始收到此错误

我在这里花了几个小时试图找到解决方案,但我尝试过的所有方法都没有奏效。

有人可以帮帮我吗?

我正在使用:XAMPP 版本:7.3.6

谢谢

config.inc.php 文件内容

<?php
/*
 * This is needed for cookie based authentication to encrypt password in
 * cookie
 */
$cfg['blowfish_secret'] = 'xampp'; /* YOU SHOULD CHANGE THIS FOR A MORE SECURE COOKIE AUTH! */

/*
 * Servers configuration
 */
$i = 0;

/*
 * First server
 */
$i++;

/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Lang'] = '';

/* Bind to the localhost ipv4 address and tcp */
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['connect_type'] = 'tcp';

/* User for advanced features */
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = '';

/* Advanced phpMyAdmin features */
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
$cfg['Servers'][$i]['relation'] = 'pma__relation';
$cfg['Servers'][$i]['table_info'] = 'pma__table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma__column_info';
$cfg['Servers'][$i]['history'] = 'pma__history';
$cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords';
$cfg['Servers'][$i]['tracking'] = 'pma__tracking';
$cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
$cfg['Servers'][$i]['recent'] = 'pma__recent';
$cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
$cfg['Servers'][$i]['users'] = 'pma__users';
$cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
$cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
$cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';
$cfg['Servers'][$i]['central_columns'] = 'pma__central_columns';
$cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings';
$cfg['Servers'][$i]['export_templates'] = 'pma__export_templates';
$cfg['Servers'][$i]['favorite'] = 'pma__favorite';

/*
 * End of servers configuration
 */

?>

【问题讨论】:

请重启你的机器并打开phpmyadmin @SAVe 做到了,但没有解决问题 仅供参考,我再次卸载并重新安装 MySQL,同样的事情不断发生 你试过把$cfg['Servers'][$i]['host'] = '127.0.0.1';改成… = 'localhost';吗? 如果您可以进入命令行检查哪些用户可用,那么运行SELECT User, Host FROM mysql.user 可能是值得的 【参考方案1】:

运行此命令

 mysqladmin -u root password 'mynewpassword'

【讨论】:

这是我得到的:mysqladmin: connect to server at 'localhost' failed error: 'Host 'localhost' is not allowed to connect to this MariaDB server'【参考方案2】:
$cfg['Servers'][$i]['AllowNoPassword'] = true;   <--- change this
$cfg['Servers'][$i]['AllowNoPassword'] = false;  <--- to this fixed the problem.

注意:本地主机中还有其他区域您必须手动更改密码。例如在“CD Collection”示例中。密码在那里是硬编码的,而不是从 config.inc.php 中获取。

【讨论】:

将 AllowNoPassword 更改为 false 时出现 2 个错误:无法连接:无效设置。 和 phpMyAdmin 尝试连接到 MySQL 服务器,但服务器拒绝了连接。您应该检查配置中的主机、用户名和密码,并确保它们与 MySQL 服务器管理员提供的信息相对应。【参考方案3】:

我不知道为什么,但由于某些原因,当我以管理员身份启动 XAMPP 控制面板时,我可以毫无问题地连接到 phpMyAdmin

【讨论】:

【参考方案4】:

错误消息有点令人困惑,因为它提到了 MariaDb 服务器。最近对 WAMP 服务器进行了更改以允许 MariaDb,不知道 XAMPP 是否也这样做了。 WAMP server switch MySQL to MariaDB

鉴于它在您以管理员身份运行时有效,我想说它在正常运行时无法访问设置文件。你能检查一下config.inc.php的权限吗?

当它以管理员身份连接时: 您必须输入您的 mySql 用户名和密码吗? 您在数据库面板中看到了什么? 服务器:本地数据库(127.0.0.1 通过 TCP/IP) 服务器类型:MySQL 服务器版本:5.7.14 - MySQL 社区服务器 (GPL) 协议版本:10 用户:root@localhost 服务器字符集:UTF-8 Unicode (utf8),例如:

【讨论】:

【参考方案5】:

可能是一种安全预防措施。您可以尝试添加一个新的管理员帐户:

mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
    ->     WITH GRANT OPTION;
mysql> CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
    ->     WITH GRANT OPTION;

https://***.com/a/1559992/7528823

【讨论】:

【参考方案6】:

几分钟前我刚遇到同样的问题,我确定我不需要任何配置更改,所以我所做的是从 127.0.0.1 清除 cookie 和站点数据(在你的情况下可能是 localhost),它是解决了!

【讨论】:

以上是关于XAMPP MySQL 说:无法连接:无效设置的主要内容,如果未能解决你的问题,请参考以下文章

MySQL说:无法连接:无效设置

XAMPP MySQL无法连接:无效设置

phpmyadmin 错误,无法连接:xampp 中的设置无效

phpmyadmin - 无法连接:无效设置

错误 MySQL 说:文档无法连接:无效设置。 [Ubuntu] [关闭]

无法连接 - 无效设置