无法登录 MySQL 服务器 (PhpMyAdmin)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32870637/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 21:18:24  来源:igfitidea点击:

Cannot log in to the MySQL server (PhpMyAdmin)

mysqlphpmyadmin

提问by Alexander

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

我通过 Homebrew 安装了 MySQL 和 PhpMyAdmin。当我尝试使用 root 及其密码登录时出现以下错误:

Cannot log in to the MySQL server

I can log in to MySQL via the terminal with:

我可以通过终端登录到 MySQL:

mysql -u root -p

PhpMyAdmin config:

PhpMyAdmin 配置:

/* 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?

我在apache上运行它。我在 stackoverflow 上尝试了所有解决方案,但它们似乎不起作用。谁能帮我?

回答by tmuecksch

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.

错误“ Cannot Log in to MySQL server”可能有多种原因。这只是意味着,phpMyAdmin 通常无法连接到 MySQL 服务器。

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'.

我也有这个问题 - 就我而言,我刚刚安装了 MySQL。在安装过程中会生成一个新的 root 密码。但是 MySQL Server 会强制您为 root 用户设置新密码,在此之前您无法执行任何查询。遗憾的是 phpMyAdmin 没有正确反映确切原因,只是报告连接失败'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');

  1. 用我的 cli 登录我的 mysql 服务器:

    mysql -u root -p

  2. 更新root密码:

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

回答by Lelio Faieta

You can use both localhostor 127.0.0.1as host declaration.

您可以同时使用两者localhost127.0.0.1作为主机声明。

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

在您的情况下,您可以尝试使用localhost它,它会起作用。