我一直在按照手册在Ubuntu上安装软件套件。我完全不了解MySQL。我已经在我的Ubuntu上完成了以下安装。

sudo apt-get update
sudo apt-get install mysql-server-5.5
sudo apt-get install mysql-client-5.5
sudo apt-get install mysql-common
sudo apt-get install glade
sudo apt-get install ntp

然后我做了

cd ~/Desktop/iPDC-v1.3.1/DBServer-1.1
mysql -uroot -proot <"Db.sql"

我最终得到以下错误消息。

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

我该如何修复它并继续?


当前回答

我最近也遇到了同样的问题,但就我而言,我记得我的密码很好,但它一直给我同样的错误。我尝试了很多方法,但是没有一个有用。然后我试了一下:

mysql -u root -p

然后它会要求你输入密码,就像这样

Enter password:

然后我输入了我用的密码。这是所有。

其他回答

一句话就解决了我的问题。

sudo dpkg-reconfigure mysql-server-5.5

我遇到了这个非常烦人的问题,并且找到了许多不管用的答案。我遇到的最好的解决方案是完全卸载MySQL并重新安装。重新安装时,您设置了根密码,这就解决了这个问题。

sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-5.5 mysql-client-core-5.5
sudo rm -rf /etc/mysql /var/lib/mysql
sudo apt-get autoremove
sudo apt-get autoclean

这段代码是我在其他地方找到的,所以我没有任何功劳。但它确实有效。要在卸载MySQL后安装它,我认为DigitalOcean有一个很好的教程。看看我的要点。

如何在Ubuntu上安装MySQL

我所面临的错误是:

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

这是一个端口运行的问题。

默认情况下,MySQL运行在3306端口上。

你可以通过运行来检查

在32位系统中: sudo / opt / lampp / manager-linux.run 在64位系统中: sudo / opt / lampp / manager-linux-x64.run

然后点击Configure按钮。

在我的示例中,端口运行在3307上,我使用了该命令

mysql -u root -p -P 3307 -h 127.0.0.1

我以root用户($SUDO)安装MySQL,得到了同样的问题

以下是我的解决方法:

sudo cat /etc/mysql/debian.cnf This will show details as: # Automatically generated for Debian scripts. DO NOT TOUCH! [client] host = localhost user = debian-sys-maint password = GUx0RblkD3sPhHL5 socket = /var/run/mysqld/mysqld.sock [mysql_upgrade] host = localhost user = debian-sys-maint password = GUx0RblkD3sPhHL5 socket = /var/run/mysqld/mysqld.sock Above we can see the password. But we are just going to use(GUx0RblkD3sPhHL5) that in the prompt. `mysql -u debian-sys-maint -p Enter password: ` Now provide the password (GUx0RblkD3sPhHL5). Now exit from MySQL and log in again as: `mysql -u root -p Enter password: `

现在提供新密码。这是所有。我们有新密码供以后使用。

这对我很管用。

在我的情况下,我发现我的根密码在日志文件“mysqld.log”,路径“/var/log”。

在我运行命令“mysql -u root -p”后,我输入我的root密码,我在/var/log/mysql .log中找到。