无法使用 mySQL 的 root 密码登录到 phpMyAdmin(在 Mac OS X Lion 上)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8546669/
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 22:04:36  来源:igfitidea点击:

Cannot log in to phpMyAdmin with my root password for mySQL (on Mac OS X Lion)

mysqlphpmyadminosx-lion

提问by user1072337

So I am trying to log in to phpMyAdmin using my root password (Username: root Password: ******), however, I continue to receive the error: #2002 Cannot log in to the MySQL server

所以我尝试使用我的 root 密码(用户名:root 密码:******)登录 phpMyAdmin,但是,我继续收到错误:#2002 无法登录 MySQL 服务器

I am pretty sure I know the root password, as I have typed into terminal on Mac OS X the line:

我很确定我知道 root 密码,因为我在 Mac OS X 的终端中输入了以下行:

sudo /usr/local/mysql/support-files/mysql.server start

and was prompted with a "Password:"line. I typed the password, and the terminal read:

并被提示"Password:"一行。我输入密码,终端显示:

Starting MySQL...SUCCESS!And thus the server started up. I am not sure why the same password is not working for phpMyAdmin.

Starting MySQL...SUCCESS!这样服务器就启动了。我不确定为什么相同的密码不适用于 phpMyAdmin。

I have tried setting the password in terminal with the command:

我尝试使用以下命令在终端中设置密码:

/usr/local/mysql/bin/mysqladmin -u root password *******

But I receive the output:

但我收到输出:

/usr/local/mysql/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)' 

I would very much appreciate help. I am at my wits end with this. I have tried several websites, and the mySQL instructions are useless on this matter. A detailed explanation on how to solve this problem (on Mac OS X Lion) would be very helpful. Thank you.

我非常感谢帮助。我对此无能为力。我试过好几个网站,mySQL 的说明在这件事上没用。有关如何解决此问题的详细说明(在 Mac OS X Lion 上)将非常有帮助。谢谢你。

Update:

更新:

I've been trying to reset the root password, and have been following these instructions: http://www.coolestguyplanet.net/how-to-change-the-mysql-root-password/

我一直在尝试重置 root 密码,并一直按照以下说明进行操作:http: //www.coolestguyplanet.net/how-to-change-the-mysql-root-password/

However, when I use the command: /usr/local/mysql/bin/mysqld_safe --skip-grant-tables

但是,当我使用命令时:/usr/local/mysql/bin/mysqld_safe --skip-grant-tables

I receive the following output:

我收到以下输出:

111217 10:00:42 mysqld_safe Logging to '/usr/local/mysql/data/******-********-MacBook-Pro.local.err'.
111217 10:00:42 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
/usr/local/mysql/bin/mysqld_safe: line 107: /usr/local/mysql/data/********-********-MacBook-Pro.local.err: Permission denied
/usr/local/mysql/bin/mysqld_safe: line 144: /usr/local/mysql/data/*******-**********-MacBook-Pro.local.err: Permission denied
111217 10:00:42 mysqld_safe mysqld from pid file /usr/local/mysql/data/*********-********-MacBook-Pro.local.pid ended
/usr/local/mysql/bin/mysqld_safe: line 107: /usr/local/mysql/data/*******-*********-MacBook-Pro.local.err: Permission denied
**********-*********-MacBook-Pro:~ myname$ 

Why would my permission be denied??

为什么我的权限会被拒绝??

回答by Sepp

In config.inc.phpchange localhostto 127.0.0.1for $cfg['Servers'][$i]['host']key.

config.inc.php更改localhost127.0.0.1for$cfg['Servers'][$i]['host']键。

回答by delkant

Take a look at this tutorial

看看这个教程

Make sure your password is correct, if you need it you can change it with this

确保你的密码正确,如果你需要它,你可以用这个来改变它

/usr/local/mysql/bin/mysqladmin -u root -p password

When it asks for a password, do not enter anything, just hit enter. It will then ask you to enter new password, then confirm. Finished.

当它要求输入密码时,不要输入任何内容,只需按 Enter。然后它会要求您输入新密码,然后确认。完成的。

Then you will need also to do this.

那么你也需要这样做。

sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

回答by lbsweek

  1. Change phpMyAdmin/config.sample.inc.phpto phpMyAdmin/config.inc.php;
  2. In config.inc.php, change localhostto 127.0.0.1;
  3. There is another config.inc.phpin phpMyAdmin/setup/frames/config.inc.php, please ignore it.
  1. 更改phpMyAdmin/config.sample.inc.phpphpMyAdmin/config.inc.php;
  2. config.inc.php,localhost改为127.0.0.1;
  3. 还有一种config.inc.phpphpMyAdmin/setup/frames/config.inc.php,请忽略它。

回答by MehdiPRG

Hey I had this problem but I fixed this. I just created a new user for mysql and then you can just login to your phpmyadmin.

嘿,我遇到了这个问题,但我解决了这个问题。我刚刚为 mysql 创建了一个新用户,然后您就可以登录到您的 phpmyadmin。

Do the following things:

做以下几件事:

mysql -u root -p

and then enter your password:

然后输入您的密码:

CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'enter your password just right here';

and set the all permissions for your new user.

并为您的新用户设置所有权限。

GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';

and then

进而

FLUSH PRIVILEGES;

Thank you.

谢谢你。

回答by sherman

In addition to Sepp's answer, I would also like to point out that if you have set MySQL port to another port (i.e. 3307) , you can append the port number like this:

除了 Sepp 的回答之外,我还想指出,如果您已将 MySQL 端口设置为另一个端口(即 3307),则可以像这样附加端口号:

$cfg['Servers'][$i]['host'] = '127.0.0.1:3307';

to the config.inc.phpfile

config.inc.php文件

I hope anyone who used a different port number can benefit from my answer

我希望使用不同端口号的任何人都可以从我的回答中受益

回答by kba

When it says (using password: NO)it means that it isn't receiving a password.

当它说(using password: NO)这意味着它没有收到密码。

Use /usr/local/mysql/bin/mysqladmin -u root -p *******

/usr/local/mysql/bin/mysqladmin -u root -p *******

回答by sandino

Best way to do this is:

最好的方法是:

Set / change / reset the MySQL root password on Ubuntu Linux. Enter the following lines in your terminal.

在 Ubuntu Linux 上设置/更改/重置 MySQL 根密码。在终端中输入以下行。

Stop the MySQL Server.

停止 MySQL 服务器。

sudo /etc/init.d/mysql stop

Start the mysqld configuration.

启动mysqld配置。

sudo mysqld --skip-grant-tables &

Login to MySQL as root.

以 root 身份登录 MySQL。

mysql -u root mysql

Replace YOURNEWPASSWORD with your new password!

用您的新密码替换 YOURNEWPASSWORD!

UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root'; FLUSH PRIVILEGES; exit;

hope this help someoneelse..it worked for me!!

希望这对其他人有帮助..它对我有用!!

回答by user6031348

And check this mysql config file -

并检查这个 mysql 配置文件 -

[mysqld] default_password_lifetime=0

[mysqld] default_password_lifetime=0

https://dev.mysql.com/doc/refman/5.7/en/password-expiration-policy.html

https://dev.mysql.com/doc/refman/5.7/en/password-expiration-policy.html