[英]root user "locked" phpmyadmin in localhost
in localhost i have mistakenly click on "lock" option of "root" user of phpmyadmin then im getting " mysqli::real_connect(): (HY000/4151): Access denied, this account is locked" issue while trying to connect "localhost/phpmyadmin" again?在本地主机中,我错误地单击了 phpmyadmin 的“根”用户的“锁定”选项,然后我收到“mysqli::real_connect(): (HY000/4151): 访问被拒绝,此帐户被锁定”的问题,同时尝试连接“本地主机” /phpmyadmin”又来了? how can i resolve this issue?
我该如何解决这个问题? Thanks
谢谢
I have tried by changing "user" "password" "hostname" in "config.inc.php" file but nothing works!我尝试通过更改“config.inc.php”文件中的“用户”“密码”“主机名”但没有任何效果!
how can i resolve this issue?我该如何解决这个问题?
If you are running MySQL on a Mac or Linux variant, depending on which account is locked, you may still be able to connect with sudo mysql
.如果您在 Mac 上运行 MySQL 或 Linux 变体,根据锁定的帐户,您可能仍然可以使用
sudo mysql
进行连接。 If so, you can run the UPDATE query (further down) to unlock the root account.如果是这样,您可以运行 UPDATE 查询(进一步向下)以解锁根帐户。 You will need to run
FLUSH PRIVILEGES;
您将需要运行
FLUSH PRIVILEGES;
or restart MySQL service for the change to take effect.或重启 MySQL 服务使修改生效。
If that does not work, or you are on Windows, you can use skip-grant-tables to start the service with the authentication disabled.如果这不起作用,或者您使用的是 Windows,则可以使用 skip-grant-tables 在禁用身份验证的情况下启动服务。 The location of the relevant configuration file varies with version and OS.
相关配置文件的位置因版本和操作系统而异。
Typical location of configuration file for MySQL 8.0 on Windows - Windows 上 MySQL 8.0 配置文件的典型位置 -
C:\ProgramData\MySQL\MySQL Server 8.0\my.ini
MySQL on many Linux variants will check for -许多 Linux 变体上的 MySQL 将检查 -
/etc/my.cnf
If it does not exist check the typical location for your Linux variant.如果它不存在,请检查您的 Linux 变体的典型位置。 Add the
skip-grant-tables
option in the mysqld
section -在
mysqld
部分添加skip-grant-tables
选项 -
[mysqld]
skip-grant-tables
Now you need to restart the MySQL service -现在你需要重启 MySQL 服务 -
# On Windows (cmd as admin)
net stop MYSQL80
net start MYSQL80
# or PowerShell as admin
Restart-Service -Name MYSQL80
# On Linux
sudo service mysql restart
You should now be able to connect to MySQL without needing credentials, and you can pass the UPDATE query in directly with --execute
or -e
.您现在应该能够连接到 MySQL 而无需凭据,并且您可以直接使用
--execute
或-e
传递 UPDATE 查询。
mysql -e "UPDATE `mysql`.`user` SET `account_locked` = 'N' WHERE `User` = 'root';"
And now you can reverse the configuration changes made above and restart MySQL service again.现在您可以撤销上面所做的配置更改并再次重新启动 MySQL 服务。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.