Cannot log in to the MySQL server (PhpMyAdmin)

2019-01-27 11:03发布

I installed both MySQL and PhpMyAdmin via Homebrew. I get the following error when I try to login with root and its password:

Cannot log in to the MySQL server

I can log in to MySQL via the terminal with:

mysql -u root -p

PhpMyAdmin config:

/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'pass';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false;

I'm running this on apache. I tried all the solutions on stackoverflow but they don't seem to work. Can anyone help me?

2条回答
We Are One
2楼-- · 2019-01-27 11:15

The error "Cannot Log in to MySQL server" can have multiple causes. It simply means, that phpMyAdmin is not able to connect to the MySQL Server in general.

I had this issue too - in my case I've freshly installed MySQL. During the installation process a new root password is generated. But the MySQL Server forces you to set a new password for the root user, before that you can't execute any query. Sadly phpMyAdmin does not reflect the exact cause properly and just reports a failed connection 'Cannot log in to the MySQL server'.

I fixed it by

  1. logging into my mysql server with my cli:

    mysql -u root -p

  2. update root password:

    SET PASSWORD FOR 'root'@'localhost' = PASSWORD('YOUR NEW PASSWORD HERE');

查看更多
迷人小祖宗
3楼-- · 2019-01-27 11:24

You can use both localhost or 127.0.0.1 as host declaration.

In your case you can try to use localhost and it will work.

查看更多
登录 后发表回答