ERROR 1045(28000):用户'root'@'localhost'拒绝访问(使用密码:NO)

时间:2021-10-11 20:18:59

I lost the access onto MySQL v. 5.6.14. I had access and suddenly I lost it.

我无法访问MySQL v.5.6.14。我有权进入,突然间我失去了它。

Looking for notes I found out the url below. I did the steps, but not success. http://dev.mysql.com/doc/refman/5.5/en/resetting-permissions.html

寻找笔记我发现了下面的网址。我做了一些步骤,但没有成功。 http://dev.mysql.com/doc/refman/5.5/en/resetting-permissions.html

C:\Program Files\MySQL\bin>mysqld

C:\ Program Files \ MySQL \ bin> mysqld

2013-11-14 19:46:01 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details)

2013-11-14 19:46:01 0 [警告]不推荐使用具有隐式DEFAULT值的TIMESTAMP。请使用--explicit_defaults_for_timestamp服务器选项(有关更多详细信息,请参阅文档)

C:\Program Files\MySQL\bin>mysql -u root mysql1

C:\ Program Files \ MySQL \ bin> mysql -u root mysql1

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

ERROR 1045(28000):用户'root'@'localhost'拒绝访问(使用密码:NO)

Notice: I don't have mysqld_safe or safe_mysqld files in MySQL version

注意:MySQL版本中没有mysqld_safe或safe_mysqld文件

Could you please help me? Below you can see the dump file generated by the command:

你可以帮我吗?您可以在下面看到该命令生成的转储文件:

C:\mysqld --init-file=C:\\mysql-init.txt

C:\Program Files\MySQL\bin>mysqld --init-file=C:\\mysql-init.txt --console

2013-11-14 17:57:20 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated.     Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2013-11-14 17:57:20 5180 [Note] Plugin 'FEDERATED' is disabled.
2013-11-14 17:57:20 5180 [Note] InnoDB: The InnoDB memory heap is disabled
2013-11-14 17:57:20 5180 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked     functions
2013-11-14 17:57:20 5180 [Note] InnoDB: Compressed tables use zlib 1.2.3
2013-11-14 17:57:20 5180 [Note] InnoDB: Not using CPU crc32 instructions
2013-11-14 17:57:20 5180 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2013-11-14 17:57:20 5180 [Note] InnoDB: Completed initialization of buffer pool
2013-11-14 17:57:20 5180 [ERROR] InnoDB: .\ibdata1 can't be opened in read-write mode
2013-11-14 17:57:20 5180 [ERROR] InnoDB: The system tablespace must be writable!
2013-11-14 17:57:20 5180 [ERROR] Plugin 'InnoDB' init function returned error.
2013-11-14 17:57:20 5180 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2013-11-14 17:57:20 5180 [ERROR] Unknown/unsupported storage engine: InnoDB
2013-11-14 17:57:20 5180 [ERROR] Aborting
2013-11-14 17:57:20 5180 [Note] Binlog end
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'partition'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_METRICS'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_CMPMEM'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_CMP'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_LOCKS'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'INNODB_TRX'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'BLACKHOLE'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'ARCHIVE'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'MRG_MYISAM'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'MyISAM'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'MEMORY'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'CSV'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'sha256_password'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'mysql_old_password'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'mysql_native_password'
2013-11-14 17:57:20 5180 [Note] Shutting down plugin 'binlog'
2013-11-14 17:57:20 5180 [Note] mysqld: Shutdown complete

C:\Program Files\MySQL\bin>

5 个解决方案

#1


1  

Your problem is here:

你的问题在这里:

2013-11-14 17:57:20 5180 [ERROR] InnoDB: .\ibdata1 can't be opened in read-write mode

There's some problem with the ibdata1 file - maybe the permissions have changed on it? Perhaps some other process has it open. Does it even exist?

ibdata1文件存在一些问题 - 可能是权限已经改变了吗?也许其他一些过程开放了。它甚至存在吗?

Fix this and possibly everything else will fall into place.

解决这个问题,可能还有其他一切都会到位。

#2


12  

I had the same problem. mysql -u root -p worked for me. It later asks you for a password. You should then enter the password that you had set for mysql. The default password could be password, if you did not set one. More info here.

我有同样的问题。 mysql -u root -p为我工作。它稍后会要求您输入密码。然后,您应输入为mysql设置的密码。如果您没有设置密码,则默认密码可以是密码。更多信息在这里。

#3


8  

Follow the steps given below:

请按照以下步骤操作:

  1. Stop your MySQL server completely. This can be done by accessing the Services window inside Windows XP and Windows Server 2003, where you can stop the MySQL service.

    完全停止MySQL服务器。这可以通过访问Windows XP和Windows Server 2003中的“服务”窗口来完成,您可以在其中停止MySQL服务。

  2. Open your MS-DOS command prompt using "cmd" inside the Run window. Inside it navigate to your MySQL bin folder, such as C:\MySQL\bin using the cd command.

    在“运行”窗口中使用“cmd”打开MS-DOS命令提示符。在里面它使用cd命令导航到你的MySQL bin文件夹,例如C:\ MySQL \ bin。

  3. Execute the following command in the command prompt: mysqld.exe -u root --skip-grant-tables

    在命令提示符中执行以下命令:mysqld.exe -u root --skip-grant-tables

  4. Leave the current MS-DOS command prompt as it is, and open a new MS-DOS command prompt window.

    保持当前的MS-DOS命令提示符,并打开一个新的MS-DOS命令提示符窗口。

  5. Navigate to your MySQL bin folder, such as C:\MySQL\bin using the cd command.

    使用cd命令导航到您的MySQL bin文件夹,例如C:\ MySQL \ bin。

  6. Enter mysql and press enter.

    输入mysql并按Enter键。

  7. You should now have the MySQL command prompt working. Type use mysql; so that we switch to the "mysql" database.

    您现在应该可以使用MySQL命令提示符。输入mysql;这样我们就切换到了“mysql”数据库。

  8. Execute the following command to update the password:

    执行以下命令更新密码:

    UPDATE user SET Password = PASSWORD('NEW_PASSWORD') WHERE User = 'root'; 
    

However, you can now run any SQL command that you wish.

但是,您现在可以运行任何您希望的SQL命令。

After you are finished close the first command prompt and type exit; in the second command prompt windows to disconnect successfully. You can now start the MySQL service.

完成后,关闭第一个命令提示符并键入exit;在第二个命令提示符窗口中成功断开连接。您现在可以启动MySQL服务。

#4


1  

I encountered the same problem, probably when I uninstalled it and tried to install it again. This happens because of the database file containing login details is still stored in the pc, and the new password will not match the older one. So you can solve this by just uninstalling mysql, and then removing the left over folder from the C: drive (or wherever you must have installed).

我遇到了同样的问题,可能是我卸载它并尝试再次安装它。发生这种情况是因为包含登录详细信息的数据库文件仍存储在PC中,并且新密码与旧密码不匹配。所以你可以通过卸载mysql,然后从C:驱动器(或者你必须安装的任何地方)删除左侧文件夹来解决这个问题。

#5


1  

The following steps are to reset the password for a user in case you forgot, this would also solve your mentioned error.

以下步骤是重置用户的密码,以防您忘记,这也将解决您提到的错误。

First, stop your MySQL:

首先,停止你的MySQL:

sudo /etc/init.d/mysql stop

Now start up MySQL in safe mode and skip the privileges table:

现在以安全模式启动MySQL并跳过权限表:

sudo mysqld_safe --skip-grant-tables &

Login with root:

用root登录:

mysql -uroot

And assign the DB that needs to be used:

并分配需要使用的数据库:

use mysql;

Now all you have to do is reset your root password of the MySQL user and restart the MySQL service:

现在您要做的就是重置MySQL用户的root密码并重启MySQL服务:

update user set password=PASSWORD("YOURPASSWORDHERE") where User='root';

flush privileges;

quit and restart MySQL:

退出并重启MySQL:

quit

sudo /etc/init.d/mysql stop sudo /etc/init.d/mysql start Now your root password should be working with the one you just set, check it with:

sudo /etc/init.d/mysql stop sudo /etc/init.d/mysql start现在你的root密码应该与你刚设置的密码一起使用,检查一下:

mysql -u root -p

#1


1  

Your problem is here:

你的问题在这里:

2013-11-14 17:57:20 5180 [ERROR] InnoDB: .\ibdata1 can't be opened in read-write mode

There's some problem with the ibdata1 file - maybe the permissions have changed on it? Perhaps some other process has it open. Does it even exist?

ibdata1文件存在一些问题 - 可能是权限已经改变了吗?也许其他一些过程开放了。它甚至存在吗?

Fix this and possibly everything else will fall into place.

解决这个问题,可能还有其他一切都会到位。

#2


12  

I had the same problem. mysql -u root -p worked for me. It later asks you for a password. You should then enter the password that you had set for mysql. The default password could be password, if you did not set one. More info here.

我有同样的问题。 mysql -u root -p为我工作。它稍后会要求您输入密码。然后,您应输入为mysql设置的密码。如果您没有设置密码,则默认密码可以是密码。更多信息在这里。

#3


8  

Follow the steps given below:

请按照以下步骤操作:

  1. Stop your MySQL server completely. This can be done by accessing the Services window inside Windows XP and Windows Server 2003, where you can stop the MySQL service.

    完全停止MySQL服务器。这可以通过访问Windows XP和Windows Server 2003中的“服务”窗口来完成,您可以在其中停止MySQL服务。

  2. Open your MS-DOS command prompt using "cmd" inside the Run window. Inside it navigate to your MySQL bin folder, such as C:\MySQL\bin using the cd command.

    在“运行”窗口中使用“cmd”打开MS-DOS命令提示符。在里面它使用cd命令导航到你的MySQL bin文件夹,例如C:\ MySQL \ bin。

  3. Execute the following command in the command prompt: mysqld.exe -u root --skip-grant-tables

    在命令提示符中执行以下命令:mysqld.exe -u root --skip-grant-tables

  4. Leave the current MS-DOS command prompt as it is, and open a new MS-DOS command prompt window.

    保持当前的MS-DOS命令提示符,并打开一个新的MS-DOS命令提示符窗口。

  5. Navigate to your MySQL bin folder, such as C:\MySQL\bin using the cd command.

    使用cd命令导航到您的MySQL bin文件夹,例如C:\ MySQL \ bin。

  6. Enter mysql and press enter.

    输入mysql并按Enter键。

  7. You should now have the MySQL command prompt working. Type use mysql; so that we switch to the "mysql" database.

    您现在应该可以使用MySQL命令提示符。输入mysql;这样我们就切换到了“mysql”数据库。

  8. Execute the following command to update the password:

    执行以下命令更新密码:

    UPDATE user SET Password = PASSWORD('NEW_PASSWORD') WHERE User = 'root'; 
    

However, you can now run any SQL command that you wish.

但是,您现在可以运行任何您希望的SQL命令。

After you are finished close the first command prompt and type exit; in the second command prompt windows to disconnect successfully. You can now start the MySQL service.

完成后,关闭第一个命令提示符并键入exit;在第二个命令提示符窗口中成功断开连接。您现在可以启动MySQL服务。

#4


1  

I encountered the same problem, probably when I uninstalled it and tried to install it again. This happens because of the database file containing login details is still stored in the pc, and the new password will not match the older one. So you can solve this by just uninstalling mysql, and then removing the left over folder from the C: drive (or wherever you must have installed).

我遇到了同样的问题,可能是我卸载它并尝试再次安装它。发生这种情况是因为包含登录详细信息的数据库文件仍存储在PC中,并且新密码与旧密码不匹配。所以你可以通过卸载mysql,然后从C:驱动器(或者你必须安装的任何地方)删除左侧文件夹来解决这个问题。

#5


1  

The following steps are to reset the password for a user in case you forgot, this would also solve your mentioned error.

以下步骤是重置用户的密码,以防您忘记,这也将解决您提到的错误。

First, stop your MySQL:

首先,停止你的MySQL:

sudo /etc/init.d/mysql stop

Now start up MySQL in safe mode and skip the privileges table:

现在以安全模式启动MySQL并跳过权限表:

sudo mysqld_safe --skip-grant-tables &

Login with root:

用root登录:

mysql -uroot

And assign the DB that needs to be used:

并分配需要使用的数据库:

use mysql;

Now all you have to do is reset your root password of the MySQL user and restart the MySQL service:

现在您要做的就是重置MySQL用户的root密码并重启MySQL服务:

update user set password=PASSWORD("YOURPASSWORDHERE") where User='root';

flush privileges;

quit and restart MySQL:

退出并重启MySQL:

quit

sudo /etc/init.d/mysql stop sudo /etc/init.d/mysql start Now your root password should be working with the one you just set, check it with:

sudo /etc/init.d/mysql stop sudo /etc/init.d/mysql start现在你的root密码应该与你刚设置的密码一起使用,检查一下:

mysql -u root -p