错误 1045 (28000) 用户“root”@“localhost”访问被拒绝(使用密码:YES)

发布于 2025-01-08 07:05:52 字数 447 浏览 1 评论 0原文

请原谅我是一个完全的初学者:

我正在尝试使用 cmd 行登录到我在 Windows 计算机上使用 easyPHP 安装的第一个 mySQL 数据库。我要去 \mysql\bin 并输入命令:

mysql -u root

为了登录,但我收到以下消息:

error 1045 (28000) access denied for user 'root'@'localhost' (using password: YES)

为什么它使用密码“YES”?根本不应该有密码吗?我需要重启mySQL什么的吗?如果是这样,我该怎么做?如果相关的话,我确实尝试使用 phpmyadmin 创建数据库,但在输入列时遇到了一些问题,并决定最好从命令行工作,这样我就可以学习所有命令。

请记住,这是我第一次尝试使用数据库,所以请善待我!

Please forgive me for being a complete beginner:

I am trying to log into my very first mySQL database that I installed using easyPHP on my windows machine, using the cmd line. I am going to the \mysql\bin and entering the command:

mysql -u root

in order to log in, but I am getting the following message:

error 1045 (28000) access denied for user 'root'@'localhost' (using password: YES)

Why is it using the password "YES"? Shouldn't there be no password at all? Do I need to restart mySQL or something? If so, how do I do that? If it's relevant, I did try to create the database using phpmyadmin, but had a few problems entering columns and decided I'd be better off working from the command line so I could learn all the commands as I went along.

Please keep in mind that this is my first time ever trying to work with a database, so be kind to me!

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

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

发布评论

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

评论(4

ぃ弥猫深巷。 2025-01-15 07:05:52

要让 mysql 要求您输入密码,您还需要指定 -p -选项:

mysql -u root -p

To have mysql asking you for a password, you also need to specify the -p-option:

mysql -u root -p
电影里的梦 2025-01-15 07:05:52

使用命令行登录 MYSQL 时,还必须指定密码(如果有)。您的错误消息告诉您用户“root”附加了密码。当您安装 easyPHP 时,密码不一定是“YES”,它应该为您提供默认密码或允许您输入您选择的密码。

根据easyPHP的文档:

[v1.6] 我的脚本与 1.5 完美配合,但现在我收到此错误:警告:当我想连接到 MySql 时,禁止用户访问:'user@localhost'(密码:YES)。

只有root用户(无密码)才有权连接数据库。修改您的脚本以使用它,或者添加您需要的用户(phpMyAdmin/用户和权限:请参阅 phpMyAdmin 的文档以获取更多信息)。

mysql -u root -p

现在,如果您更改了 root 用户密码,则需要在出现提示时指定。否则,只需按键盘上的 即可。

如果您忘记了 root 密码并已更改,则随后必须重新安装 easyPHP。

When logging into MYSQL using the command line, you also have to specify the password if any. Your error message is telling you that the user "root" has a password attached to it. Not necessarily that the password is "YES" when you were installing easyPHP, it should have either provided you with a default password or allowed you to enter a password of your choosing.

According to the documentation of easyPHP:

[v1.6] My scripts worked perfectly with 1.5 but now I get this error : Warning: Forbidden access for user: 'user@localhost' (password: YES) when I want to connect to MySql.

Only the root user (without password) has the rights to connect to the database. Either modify your scripts to use it, or add the user you need (phpMyAdmin/users and privileges: See phpMyAdmin's documentation for more information).

mysql -u root -p

Now if you changed your root user password, you will need to specify that when prompted. Otherwise simply hit <Enter> on your keyboard.

If you FORGOT the password to root, and have changed it, you will have to subsequently reinstall easyPHP.

天暗了我发光 2025-01-15 07:05:52
agk-hp:~/$mysql
ERROR 1045 (28000): Access denied for user 'greg'@'localhost' (using  password: NO)
agk-hp:~/$sudo cat /etc/mysql/debian.cnf|grep password
 password = t7753my3D2x4yfQm

agk-hp:~/$mysql -u debian-sys-maint -p  
Enter password: {t7753my3D2x4yfQm} 
Welcome to the MySQL monitor.  Commands end with ; or \g.

mysql> use mysql;

mysql> grant all privileges on *.* to 'root'@'localhost';
mysql> grant all privileges on *.* to 'greg'@'localhost';


agk-hp:~/$mysql
mysql>
agk-hp:~/$mysql
ERROR 1045 (28000): Access denied for user 'greg'@'localhost' (using  password: NO)
agk-hp:~/$sudo cat /etc/mysql/debian.cnf|grep password
 password = t7753my3D2x4yfQm

agk-hp:~/$mysql -u debian-sys-maint -p  
Enter password: {t7753my3D2x4yfQm} 
Welcome to the MySQL monitor.  Commands end with ; or \g.

mysql> use mysql;

mysql> grant all privileges on *.* to 'root'@'localhost';
mysql> grant all privileges on *.* to 'greg'@'localhost';


agk-hp:~/$mysql
mysql>
凉世弥音 2025-01-15 07:05:52

mac 上 mysql- 5.7.10 的修改 mac el Capitan

  • sudo /usr/local/mysql/support-files/mysql.server stop
  • sudo mysqld_safe --skip-grant-tables

    现在在终端上打开新窗口/选项卡并输入

  • “mysql -u root”
  • use mysql
  • update user setauthentication_string=password ('你的密码') 其中 user='root';

A modification for mysql- 5.7.10 on mac mac el capitan

  • sudo /usr/local/mysql/support-files/mysql.server stop
  • sudo mysqld_safe --skip-grant-tables

    Now open new window/tab on terminal and type

  • "mysql -u root"
  • use mysql
  • update user set authentication_string=password('yourpassword') where user='root';
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文