Home > Database > phpMyAdmin > body text

phpmyadmin cannot connect to mysql server

王林
Release: 2019-12-13 09:30:47
Original
10460 people have browsed it

phpmyadmin cannot connect to mysql server

Question:

Error:

MySQL returned: Document

Unable to connect: Invalid settings.

phpMyAdmin tried to connect to the MySQL server, but the server refused the connection. You should check the host, username, and password in the configuration file and confirm that the information matches the information given by the MySQL server administrator.

Cause of the problem:

I found that the default mysql account of xampp actually had an empty password. Although it was just a local debugging environment, it was still not comfortable, so I changed the password and accessed phpmyadmin again. This error occurred.

This is because the default login method of phpmyadmin in xampp is to log in directly through the account and password recorded in the configuration file instead of logging in through the login interface. However, after the password is modified, it does not match the account and password in the configuration file. , hence the error.

Solution:

1. To set a password for the "root" user in MySQL (for example: the local MySQL password is 123456), please use the "mysqladmin" command in the console. For example:

d:\xampp0\mysql\bin\mysqladmin.exe  -u  root  password  123456
Copy after login

In addition, if there is a previous password, the modification command is:

d:\xampp0\mysql\bin\mysqladmin.exe -u root -p password 123456
Copy after login

After pressing Enter, you will be prompted to enter the password, just enter the "old password".

2. Find the configuration file information of config.inc.php under phpMyAdmin under xampp

Modify it to the following content

 /* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '123456';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
Copy after login
$cfg['Servers'][$i]['auth_type'] = 'config';这里config改为$cfg['Servers'][$i]['auth_type'] = 'cookie';
Copy after login

From now on, it needs to be correct Enter the "root" password to start PHPMyAdmin.

Then click phpmyadmin and set the mysql password to 123456 in the graphical operation interface. problem solved.

The new password will take effect after restarting the MySQL service!

Recommended related articles and tutorials: phpmyadmin tutorial

The above is the detailed content of phpmyadmin cannot connect to mysql server. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!