Mysql root 密码问题

发布于 2024-11-23 17:03:24 字数 338 浏览 0 评论 0原文

我已经在 mac 10.7 上安装了 mysql,我正在使用 phpmyadmin 访问 mysql 数据库,但是当我尝试使用用户名 root 登录时出现错误而被锁定,没有密码

Login without a password is forbidden by configuration (see AllowNoPassword)

当我使用相同的用户名输入密码 root 时,我得到错误,

#2002 Cannot log in to the MySQL server

mysql 中的 root 密码是什么以及如何更改它。

I have installed mysql on a mac 10.7, I am using phpmyadmin to access the mysql database but am getting locked out with an error when i try to login with a username root no password

Login without a password is forbidden by configuration (see AllowNoPassword)

when i put a password root with the same username, i get an error,

#2002 Cannot log in to the MySQL server

What is the root password in mysql and how can i change it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我只土不豪 2024-11-30 17:03:25

正如@Jacob 提到的,出于安全原因,您需要设置密码,但我使用 phpmyadmin 进行学习,所以我更改了一些对我有用的设置。

Step 1: Change config.sample.inc.php to config.inc.php

Step 2: Find the line  $cfg['Servers'][$i]['host'] = 'localhost';
                 and change it to 
          $cfg['Servers'][$i]['host'] = '127.0.0.1';

Step 3: Find the line that says 
        $cfg['Servers'][$i]['AllowNoPassword'] = false;
                and change it to 
         $cfg['Servers'][$i]['AllowNoPassword'] = true;

希望有帮助。但请记住,在使用数据库时始终要考虑数据的安全性。所以我建议您设置密码并确保安全。

干杯

As @Jacob mention you need to set you password for security reason but I am using phpmyadmin for study purpose so I change few settings which works for me.

Step 1: Change config.sample.inc.php to config.inc.php

Step 2: Find the line  $cfg['Servers'][$i]['host'] = 'localhost';
                 and change it to 
          $cfg['Servers'][$i]['host'] = '127.0.0.1';

Step 3: Find the line that says 
        $cfg['Servers'][$i]['AllowNoPassword'] = false;
                and change it to 
         $cfg['Servers'][$i]['AllowNoPassword'] = true;

hope that helps. But remember while working with DB always think about the security of you data. So i suggest you to set password and be safe.

Cheers

美人骨 2024-11-30 17:03:25
/usr/local/mysql/bin/mysqladmin -u root password new_password_here

在全新安装中将密码更改为 new_password_here
然后您可以使用 thtat 登录 phpMyAdmin。

出于安全原因,phpMyAdmin 默认将 AllowNoPassword 设置为 false。所以你必须先设置一个密码。

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

To change the password to new_password_here in a fresh install.
You can then use thtat to login to phpMyAdmin.

phpMyAdmin default is to set AllowNoPassword to false, for security reasons. So you have to set a password first.

一百个冬季 2024-11-30 17:03:25

这是 PHPMyAdmin 中反复出现的问题。今天我安装了 Ubuntu 18.04、MariaDB 和 PHPMyAdmin 4.6.6deb5。这是我在安装 PHPMyAdmin 之前应该获得的信息。虽然我使用了 MariaDB,但我认为这也适用于 MySQL。

诀窍是在安装 MariaDB 之后并在运行 mysql_secure_installation 之前安装 PHPMyAdmin。在此状态下,MariaDB root 密码为空。但是 PHPMyAdmin 不允许您使用空密码以 root 身份登录,因此您必须从终端运行 mysql_secure_installation 并为 MariaDB 设置 root 密码。

根据我的经验,如果您在安装 PHPMyAdmin 之前已经拥有 MariaDB 的 root 密码,那么您可能必须(不必)将数据库 root 密码重置为 [NULL]。 >。如果您已经有 MariaDB 的 root 密码,则必须使用 mysql -u root -p 从终端登录并输入 root 密码。然后,您必须执行此查询才能将数据库 root 密码设置为空:

SET PASSWORD FOR root@localhost = PASSWORD('');

并且只有在将 MariaDB 密码设置为 null 后才安装 PHPMyAdmin零。然后,您必须再次以 root 身份执行 mysql_secure_installation ,以便为 MariaDB 设置强密码。

我怀疑 PHPMyAdmin 密码的许多混乱似乎源于用户没有意识到 PHPMyAdmin 所指的用户名/密码是 MySQL/MariaDB 数据库用户名和密码,而不是特定于 PHPMyAdmin 的任何密码。

This is a recurring question/problem with PHPMyAdmin. Today I installed Ubuntu 18.04 with MariaDB and PHPMyAdmin 4.6.6deb5. This is the info that I should have had before my installation of PHPMyAdmin. Though I used MariaDB, I presume this would also apply to MySQL.

The trick is to install PHPMyAdmin after installing MariaDB and BEFORE running mysql_secure_installation. At this state the MariaDB root password is empty. However PHPMyAdmin will not allow you to login as root with an empty password, therefore you have to run mysql_secure_installation from the terminal and set a root password for MariaDB.

In my experience you may have to, no make that WILL HAVE TO, reset the database root password to [NULL] if you already have an existing root password for MariaDB before installing PHPMyAdmin. If you already have a root password for MariaDB, you will have to login from a terminal with mysql -u root -p and enter the root password. Then you have to execute this query in order to set the database root password to null:

SET PASSWORD FOR root@localhost = PASSWORD('');

and only install PHPMyAdmin once the MariaDB password has been set to zero. Then you will again have to execute mysql_secure_installation as root in order to set a strong password for MariaDB.

I suspect that a lot of the confusion with PHPMyAdmin passwords seems to originate due to users not realising that the username/password that PHPMyAdmin refers to are the MySQL/MariaDB database user names and passwords and not any password specific to PHPMyAdmin.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文