'phpMyAdmin ERROR: mysqli_real_connect(): (HY000/1045): Access denied for user 'pma'@'localhost' (using password: NO)
I keep getting the following errors with mysql connection through XAMPP and I don't know what to do:
That's the code in the 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
*/
?>
I've already reset the password from MySql from the command line two times and added the changes to this code above and to the php.ini file, but at each time it goes back to the error. Any help?
Solution 1:[1]
yo need create the user "pma" in mysql or change this lines(user and password for mysql):
/* User for advanced features */
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = '';
Linux: /etc/phpmyadmin/config.inc.php
Solution 2:[2]
Add this line to the file xampp\phpMyAdmin\config.inc
:
$cfg['Servers'][$i]['port'] = '3307';
Here, my port is 3307
, you can change it to yours.
Solution 3:[3]
In terminal, log into MySQL as root. You may have created a root password when you installed MySQL for the first time or the password could be blank, in which case you can just press ENTER when prompted for a password.
sudo mysql -p -u root
Now add a new MySQL user with the username of your choice. In this example we are calling it pmauser (for phpmyadmin user). Make sure to replace password_here with your own. You can generate a password here. The % symbol here tells MySQL to allow this user to log in from anywhere remotely. If you wanted heightened security, you could replace this with an IP address.
CREATE USER 'pmauser'@'%' IDENTIFIED BY 'password_here';
Now we will grant superuser privilege to our new user.
GRANT ALL PRIVILEGES ON *.* TO 'pmauser'@'%' WITH GRANT OPTION;
Then go to config.inc.php ( in ubuntu, /etc/phpmyadmin/config.inc.php )
/* User for advanced features */
$cfg['Servers'][$i]['controluser'] = 'pmauser';
$cfg['Servers'][$i]['controlpass'] = 'password_here';
Solution 4:[4]
Add these lines to the file xampp\phpMyAdmin\config.inc
:
$cfg['Servers'][$i]['controluser'] = 'root';
$cfg['Servers'][$i]['controlpass'] = '';
Solution 5:[5]
My default 3306 port was in use, so I changed it to 8111, and then I had this error. I've fixed it by adding
$cfg['Servers'][$i]['port'] = '8111';
into config.inc.php. If you are using a different port number then set yours.
Solution 6:[6]
Linux / Ubuntu:
If installed phpmyadmin via apt:
sudo apt-get install phpmyadmin php-mbstring
Can check /etc/phpmyadmin/config-db.php
for changing the user credentials.
$dbuser='pma';
$dbpass='my_pass';
$basepath='';
$dbname='phpmyadmin';
$dbserver='localhost';
$dbport='3306';
$dbtype='mysql';
Solution 7:[7]
The Connection for controluser as defined in your configuration failed, right after:
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = 'you_password';
Solution 8:[8]
I solved the problem by adding the line skip-grant-tables
to the my.ini:
# The MySQL server
[mysqld]
skip-grant-tables
port= 3306
...
Under XAMPP Control Panel > Section "MySQL" > Config > my.ini
Solution 9:[9]
I experienced the same errors on a fresh install of VestaCP. I solved the issues by following the instructions on this video.
- Go to phpmyadmin-fixer and run the appropriate command.
- Restart Apache, NGINX and MySQL servers.
- That's it!
Solution 10:[10]
Might be late to the party - also, this answer is for LAMP users who got to this thread from google, like me.
Basically, the problem is PMA is trying to connect to SQL with a user that doesn't exist.
At /etc/phpmyadmin/config-db.php, you will find 2 variables: $dbuser, and $dbpass. Those specify the MySQL user and Password that PMA is trying to connect with.
Now, connect with some username/password that work (or just "root" if you are connecting from localhost), create a new user with global priviliges (e.g - %PMA User% with password %Some Random Password%), then in the above mentioned file set:
$dbuser = %PMA User% ;
$dbpass = %Some Random Password%;
You might also change other stuff there, like the server address ($dbserver), the port ($dbport, which might not be the default one on your machine), and more.
Solution 11:[11]
I just finished setting up my XAMPP on the MAC and had the same trouble. I just fixed it. It is not quite clear what OS you're using but you need to run the XAMPP security. You indicate you've done that, but here it is anyway for the MAC
sudo /Applications/XAMPP/xamppfiles/xampp security
Set your password on the questions you get.
In you're phpmyadmin import the "create_tables.sql" .. Which can be found in the ./phpmyadmin/sql folder.
Next open the config.inc.php
file inside the ./phpmyadmin
folder.
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = 'you_password';
Make sure to log out and log in to reflect the changes within phpmyadmin
Solution 12:[12]
I changed in file config.inc.php
$cfg['Servers'][$i]['host'] = '127.0.0.1';
to
$cfg['Servers'][$i]['host'] = 'localhost';
and it worked!
Solution 13:[13]
consider changing host entry 127.0.0.1
to localhost
or even the IP address of the server.
$cfg['Servers'][$i]['host']
Solution 14:[14]
This error is caused by a line of code in /usr/share/phpmyadmin/libraries/sql.lib.php.
It seems when I installed phpMyAdmin using apt, the version in the repository (phpMyAdmin v4.6.6) is not fully compatible with PHP 7.2. There is a newer version available on the official website (v4.8 as of writing), which fixes these compatibility issues with PHP 7.2.
You can download the latest version and install it manually or wait for the repositories to update with the newer version.
Alternatively, you can make a small change to sql.lib.php to fix the error.
Firstly, backup sql.lib.php before editing.
1-interminal:
sudo cp /usr/share/phpmyadmin/libraries/sql.lib.php /usr/share/phpmyadmin/libraries/sql.lib.php.bak
2-Edit sql.lib.php. Using vi:
sudo vi /usr/share/phpmyadmin/libraries/sql.lib.php
OR Using nano:
sudo nano /usr/share/phpmyadmin/libraries/sql.lib.php
Press CTRL + W (for nano) or ? (for vi/vim) and search for (count($analyzed_sql_results['select_expr'] == 1)
Replace it with ((count($analyzed_sql_results['select_expr']) == 1)
Save file and exit. (Press CTRL + X, press Y and then press ENTER for nano users / (for vi/vim) hit ESC then type :wq and press ENTER)
Solution 15:[15]
I am using UniServer Zero XIV 13.x.x UniController XIV V2.3.1:
From the command line I did this:
mysql> CREATE USER 'pmauser'@'%' IDENTIFIED BY 'MyPasswordHere!';
Query OK, 0 rows affected (0.07 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'pmauser'@'%' WITH GRANT OPTION;
Query OK, 0 rows affected (0.02 sec)
Then I went to C:\...\wamp\ZeroXIV_unicontroller_2_3_1\UniServerZ\home\us_opt1\config.inc.php
and modified the file to have this:
/* PMA User advanced features */
//////////$cfg['Servers'][$i]['controluser'] = 'pma';
//////////$cfg['Servers'][$i]['controlpass'] = $password;
$cfg['Servers'][$i]['controluser'] = 'pmauser';
$cfg['Servers'][$i]['controlpass'] = 'MyPasswordHere!';
I restarted Apache and MySQL. The error is gone!
Solution 16:[16]
clear site data in your browser. and it will be fixed. sometimes when you run proxies, vpns or some other programs this error happens.
Solution 17:[17]
change the port number. I followed these steps and it worked for me
Port number in XAMPP can be easily changed by following this 5 steps:
step 1: stop the xampp server, if it is already running.(to avoid collapse)
step 2: run your notepad as administrator and open this 3 files:
xampp/properties.ini
xampp/mysql/bin/my.ini
xampp/php/php.ini
step 3: Press ctrl+F and replace all 3306 ( port number ) with 3308(it can be anything like 3307 or 3309) .( Use ctrl+F so that you don’t miss out any 3306 port unchanged. Otherwise it won’t work)
step 4 : save all the files.
step 5 : Now restart your apache and mysql. It will work :)
Solution 18:[18]
you have to change three places first you have password so please type your password of the server in $['password'] , $['controlpass']
here I believe these codes help you
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'yourPassword of server;
$cfg['Servers'][$i]['host'] = 'localhost:yourPort';
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = 'yourPassword of server';
Solution 19:[19]
It is usually happens when you are facing problem when starting xampp server. The problem is some how like this....
Problem detected! 2:06:05 AM [mysql] Port 3306 in use by "Unable to open process"! 2:06:05 AM [mysql] MySQL WILL NOT start without the configured ports free! 2:06:05 AM [mysql] You need to uninstall/disable/reconfigure the blocking application 2:06:05 AM [mysql] or reconfigure MySQL and the Control Panel to listen on a different port
So first you have to change your port 3306 to 8111. how will you change it? simple go to my.ini file inside xampp/mysql/data and open it with note pad and change it.
After that if you try to start phpmyadmin you will face error access denied.
Now you also have to your port setting in your config.inc file. You will find it in xampp/PHPMyAdmin/Config.inc
$cfg['Servers'][$i]['port'] = '8111';
after that start you xampp server again and refresh you web page it will work.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow