phpMyAdmin Cannot log in to the MySQL server on Centos 7
I was able to resolve this by doing the following: (I should mention that this solution works for MySQL 8.0.13 and phpMyAdmin 4.8.4 - Both, latest version today)
1- I edited config.inc.php
with these server parameters (only):
/*** This is needed for cookie based authentication to encrypt password in
cookie. Needs to be 32 chars long. */
$cfg['blowfish_secret'] = 'generate_your_blowfish_secret_32_chars';
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false;
2- On MySQL terminal
//Create a new user:
mysql> CREATE USER 'user'@'localhost' IDENTIFIED BY 'your_password';
//Grant all privileges:
mysql> GRANT ALL PRIVILEGES ON *.* To 'user'@'localhost' WITH GRANT OPTION;
//Flush all privileges:
mysql> FLUSH PRIVILEGES;
//Change authentication_string with password:
mysql> ALTER USER user IDENTIFIED WITH mysql_native_password BY
'your_password';
//Login with the new user and password!
This should allow you to login into phpMyAdmin. I hope this help!
Related videos on Youtube
Jacman
Updated on June 04, 2022Comments
-
Jacman almost 2 years
I installed
mysql-community-server-8.0.13-1.el7.x86_64
on Centos 7 with Nginx, and added the phpMyAdmin to manage the databases but I keep getting errorCannot log in to the MySQL server
from phpMyAdmin. I've tried the following and have been struggling for a few days now:Changed some of the parameters (suggested on stackoverflow) located on
/etc/phpMyAdmin/config.inc.php
like the following but no luck:$cfg['Servers'][$i]['host'] = 'localhost'; $cfg['Servers'][$i]['connect_type'] = 'socket'; $cfg['Servers'][$i]['socket'] = '/var/lib/mysql/mysql.sock'; $cfg['Servers'][$i]['user'] = 'root'; $cfg['Servers'][$i]['password'] = 'password';
I've tried mysql shell, and I'm able to login with
root
and other users. But, I have no idea why it fails on phpMyAdmin. Please help and thanks!
-
René Höhle over 5 yearsPossible duplicate of Can not login to phpmyadmin with root user
-
Jacman over 5 years@Stony thanks for the help but it didn't worked.
-
Light.G over 5 yearsDoes /var/run/mysqld/mysqlx.sock exist?
-
Jacman over 5 years@Light.G Yes, it's there. I guess my option would be to uninstall and reinstall MySQL
-
Isaac Bennetch over 5 yearsWhen you log in from the command line client, please run the
STATUS;
command to see the connection type (whether some host "via TCP/IP" or "Localhost via UNIX socket"). Also note the path to the UNIX socket if it's provided. How have you installed phpMyAdmin - through the package manager or by downloading and uncompressing it yourself? -
Jacman over 5 years@IsaacBennetch This is what it shows:
Connection:Localhost via UNIX socket
andUNIX socket:/var/lib/mysql/mysql.sock
and I verified all -
Jacman over 5 years@IsaacBennetch I installed it thru package manager. Thanks!