将 MySQL 根密码重置为“默认”-MAMP

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

Reset MySQL root password to "default" - MAMP

mysqlphpmyadminterminalmamp

提问by m33bo

I changed my root level password on phpMyAdmin. I was unsure where to enter the password itself, as it did not give me the option (login form). I wondered if it was the php.ini file but users with read privileges could read it if I placed the password in there.

我在 phpMyAdmin 上更改了我的 root 级别密码。我不确定在哪里输入密码本身,因为它没有给我选项(登录表单)。我想知道它是否是 php.ini 文件,但如果我将密码放在那里,则具有读取权限的用户可以读取它。

Now, the mysql doesn't run as I tried various online resources to fix the problem. If needs be I would delete mamp and re-install but I do not want to lose my database files. Ideally I would revert the password to default, which I believe was nothing, except now I cannot connect to phpmyadmin, or the mamp start page:

现在,当我尝试各种在线资源来解决问题时,mysql 无法运行。如果需要,我会删除 mamp 并重新安装,但我不想丢失我的数据库文件。理想情况下,我会将密码恢复为默认值,我认为这没什么,除了现在我无法连接到 phpmyadmin 或 mamp 起始页:

Error: Could not connect to MySQL server!

Any help would be great.

任何帮助都会很棒。

UPDATE -

更新 -

Error message from mamp:

来自 mamp 的错误消息:

/Applications/MAMP/Library/bin/mysqlcheck: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) when trying to connect

回答by m33bo

This seemed to have fixed it when using terminal to reset the password:

这似乎在使用终端重置密码时已修复:

/Applications/MAMP/Library/bin/mysqladmin -u root -p password newpassword

Found on mamp faq.

mamp 常见问题解答上找到。

回答by Christoffer

Look in the files:

查看文件:

  • checkMysql.sh
  • quickCheckMysqlUpgrade.sh
  • repairMysql.sh
  • stopMysql.sh
  • 检查Mysql.sh
  • quickCheckMysqlUpgrade.sh
  • 修复Mysql.sh
  • 停止Mysql.sh

The important one in this case is "quickCheckMysqlUpgrade.sh". All the files are located in the /Applications/MAMP/bin/directory.

在这种情况下,重要的是“quickCheckMysqlUpgrade.sh”。所有文件都位于/Applications/MAMP/bin/目录中。

In these files you'll find something like

在这些文件中,您会发现类似

# /bin/sh
/Applications/MAMP/Library/bin/mysqlcheck --quick --check-upgrade -u root -proot --socket=/Applications/MAMP/tmp/mysql/mysql.sock mysql

When you see -prootthat is the password MAMP will try to use, -p{password}.

当您看到-proot是 MAMP 将尝试使用的密码时,-p{password}。

-p means "password" and whatever comes after is the password. So change "-proot" to eg. "-pmysecret" or whatever your password is.

-p 表示“密码”,后面的就是密码。所以将“-proot”更改为例如。“-pmysecret”或任何您的密码。

回答by Rich R

I was being annoyed by the startup "access denied" error MAMP would show, even though I was able to access my site using phpMyAdmin or other SQL tools. I even found/updated the password in checkMysql.sh, repairMysql.sh, and upgradeMysql.sh. I did not notice the script called quickCheckMysqlUpgrade.sh and correcting the password in that fixed the startup error for me.

我对 MAMP 会显示的启动“拒绝访问”错误感到恼火,即使我能够使用 phpMyAdmin 或其他 SQL 工具访问我的网站。我什至在 checkMysql.sh、repairMysql.sh 和 upgradeMysql.sh 中找到/更新了密码。我没有注意到名为 quickCheckMysqlUpgrade.sh 的脚本和更正密码,它为我修复了启动错误。

回答by LAOMUSIC ARTS

I just solved this issue on my MBP! In MAMP Pro (v352), go to the MySQL tab and press "Change Password".

我刚刚在我的 MBP 上解决了这个问题!在 MAMP Pro (v352) 中,转到 MySQL 选项卡并按“更改密码”。