mysql - 错误 1045 (28000) : Access denied for user 'root' @'localhost' (using password: YES) -Ubuntu

标签 mysql ubuntu access-denied

我无法登录 MySQL。我以为是密码错误,我尝试更改密码..

无需修改密码。因为密码是对的。密码是对的,可是还是登不上mysql。为什么?请帮助我,谢谢。我试过很多方法。

    root@PC:/home/PC# sudo /etc/init.d/mysql stop
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql stop

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) utility, e.g. stop mysql
mysql stop/waiting
root@PC:/home/PC# pkill -9 mysql
root@PC:/home/PC# pkill -9 mysqld
root@PC:/home/PC# pkill -9 mysqld_safe
root@PC:/home/PC# ps -ef |grep mysql
root 27690 25962 0 19:51 pts/1 00:00:00 grep --color=auto mysql
root@PC:/home/PC# kill 27690
bash: kill: (27690) - No such process
root@PC:/home/PC# kill 25962
root@PC:/home/PC# ps uaxww | grep -i mysql
PC 24175 0.7 3.8 818760 156020 ? Sl 19:29 0:10 /usr/lib/firefox/firefox /media/DA94-D856/c/How to Recover_Reset forgotten MySQL root Password on Linux _ 2daygeek.htm
root 27695 0.0 0.0 13588 944 pts/1 S+ 19:52 0:00 grep --color=auto -i mysql
root@PC:/home/PC# kill 27695
bash: kill: (27695) - No such process
root@PC:/home/PC# kill 13588
bash: kill: (13588) - No such process
root@PC:/home/PC# sudo mysqld_safe --skip-grant-tables &
[1] 27701
root@PC:/home/PC# 160518 19:53:57 mysqld_safe Can't log to error log and syslog at the same time. Remove all --log-error configuration options for --syslog to take effect.
160518 19:53:57 mysqld_safe Logging to '/var/log/mysql/error.log'.
160518 19:53:57 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
root@PC:/home/PC# mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.34-0ubuntu0.12.04.1 (Ubuntu)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set password=PASSWORD("mypw") where User='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 3 Changed: 0 Warnings: 0

mysql> update user set password=PASSWORD("newpw") where User='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
root@PC:/home/PC# sudo /etc/init.d/mysql stop
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql stop

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) utility, e.g. stop mysql
root@PC:/home/PC# sudo /etc/init.d/mysql start
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql start

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start mysql
mysql start/running, process 28137
root@PC:/home/PC# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 

(或 dpkg-reconfigure mysql-server-5.5)

    PC@PC:~$ sudo dpkg-reconfigure mysql-server-5.5
[sudo] password for PC:
mysql stop/waiting
160513 7:09:38 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
mysql start/running, process 4046
PC@PC:~$ mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
PC@PC:~$ 
sudo /etc/init.d/mysql stop
sudo mysqld_safe --skip-grant-tables &
mysql -uroot
use mysql;
update user set password=PASSWORD("newpw") where User='root';
flush privileges;
quit
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start

错误日志 http://pastebin.com/HN2tGhJJ

etc/mysql/my.cf http://pastebin.com/cMSdGUei

我试过了,但没有成功。 root 权限可能已被删除。 使用 MySQL; 将 . 上的所有内容授予 'root'@'localhost';

[sudo] password for PC-2:
root@PC-2:/home/PC-2# mysql -u root -pFalanca_mypw
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
root@PC-2:/home/PC-2# grep password /etc/mysql/debian.cnf
password = vwSY1PE7GgDRUbB7
password = vwSY1PE7GgDRUbB7
root@PC-2:/home/PC-2# mysql -u debian-sys-maint -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 71
Server version: 5.5.34-0ubuntu0.12.04.1 (Ubuntu)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> grant all on *.* to 'root'@'localhost';
ERROR 1045 (28000): Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)  https://www.ozgurbilgi.net

最佳答案

在MySql的config(.cnf)文件中,设置如下属性,

bind-address = 0.0.0.0

默认值为 127.0.0.1。改成0.0.0.0就可以访问了。否则,它只允许通过 ssh 通过本地主机。

关于mysql - 错误 1045 (28000) : Access denied for user 'root' @'localhost' (using password: YES) -Ubuntu,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37547568/

相关文章:

php - 为什么这段 PHP 代码在一台机器上运行而在另一台机器上失败?

linux - [unixODBC][驱动程序管理器]无法打开 lib '/usr/lib/x86_64-linux-gnu/odbc/psqlodbca.so' : file not found

c# - 访问被拒绝 - 尝试从地址栏的句柄获取 url(文本)时

mysql - 数据未插入 Node.js 实时通知应用程序中的 Mysql 数据库中

mysql - 由于最大执行时间,复制 MySQL 数据库失败

bash - Qt没有找到bash中设置的环境变量

asp.net - 使用 ASP 启动/停止 Windows 服务时访问被拒绝

mysql - 可以删除 MySQL 字段中 'space' 之后的所有内容吗?

php - 如何更改codeigniter中的mysql查询

python - 为什么我在使用 mrjob 运行 python 文件时得到 "WindowsError [Error5] Access is denied"