我无法访问XAMPP phpMyAdmin; 它说:错误MySQL说:文档无法连接:无效设置

Bri*_*ian 1 php mysql xampp database-connection phpmyadmin

完整的错误消息:

Error
MySQL said: Documentation
Cannot connect: invalid settings. 
Connection for controluser as defined in your configuration failed.
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.
Run Code Online (Sandbox Code Playgroud)

到目前为止,我一直在使用网站托管网站服务器; 这可能搞砸了我的xampp连接.我的phpMyAdmin"config.in.php"文件设置如下:

/* 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';
Run Code Online (Sandbox Code Playgroud)

我可以在"localhost:8080"上运行我用xampp创建的php代码,但是我无法访问mysql.我的数据库连接配置如下:

// Databse Connection Constants
define('DB_HOST','localhost');
define('DB_USER','root');
define('DB_PASS',','');
define('DB_NAME','gallery_db');
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?谢谢.

Bri*_*ian 10

我在StackOverflow中找到了答案.在"config.inc.php"文件中,我将"config"更改为"cookie".以下是StackOverflow引用的答案:

步骤1:

找到phpMyAdmin安装路径.

第2步:

在您喜欢的文本编辑器中打开phpMyAdmin> config.inc.php.

第3步:

搜索 $cfg['Servers'][$i]['auth_type'] = 'config';

替换为 $cfg['Servers'][$i]['auth_type'] = 'cookie';