0

我试图为我做的第二个 Wordpress 博客设置新数据库

root@TheLove:/# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 108


mysql> CREATE DATABASE wp_name CHARACTER SET utf8 COLLATE utf8_general_ci;
Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON wp_name.* TO name@name.com IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> 
mysql> quit
Bye    

之后,当我想停止/重新启动/身份验证时出现此错误

mysql -uroot
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

/etc/init.d/mysql stop
Stopping MySQL database server: mysqld failed!

mysqld --skip-grant-tables
130126  0:23:57 [Note] Plugin 'FEDERATED' is disabled.
130126  0:23:57  InnoDB: Initializing buffer pool, size = 8.0M
130126  0:23:57  InnoDB: Completed initialization of buffer pool
InnoDB: Unable to lock ./ibdata1, error: 11
InnoDB: Check that you do not already have another mysqld process
InnoDB: using the same InnoDB data or log files.
130126  0:23:57  InnoDB: Retrying to lock the first data file
InnoDB: Unable to lock ./ibdata1, error: 11
InnoDB: Check that you do not already have another mysqld process
InnoDB: using the same InnoDB data or log files.

所以我做了

pkill mysql
/etc/init.d/mysql start

Starting MySQL database server: mysqld.
Checking for corrupt, not cleanly closed and upgrade needing tables..
root@TheLove:/# ERROR 1045 (28000): Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)

还尝试了位于 cat /etc/mysql/debian.cnf 的密码

Starting MySQL database server: mysqld.
Checking for corrupt, not cleanly closed and upgrade needing tables..
root@TheLove:/# ERROR 1045 (28000): Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)
cat /etc/mysql/debian.cnf

在阅读了很多教程后我无法弄清楚这一点也发现有些人以前遇到过这个问题并且他们无法解决它

4

1 回答 1

0

尝试再次关闭您的 MySQL(或干脆杀死它)。现在您可以使用跳过的授权表手动启动 mysqld。然后你可以重置你的密码

shell> mysqld --skip-grant-tables & 
shell> mysql 
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpassw0rd'); 
mysql> flush privileges;

在我看来,您最近使用mysql.user表中的不同凭据从 mysqldump 恢复或迁移了数据库。在您使用之前,这通常没有影响flush privileges;

于 2013-01-26T09:40:13.187 回答