错误1045(28000):用户'root'@'localhost'的访问被拒绝(使用密码:是)
我是一名电气工程师,主要研究电源系统而不是编程.最近,我一直在按照手册在Ubuntu上安装软件套件.实际上,我完全不了解mySQL
.我已经在Ubuntu上完成了以下安装.
I am an electrical engineer who mainly plays around with power systems instead of programming. Recently, I have been following a manual to install a software suite on Ubuntu. I have no knowledge of mySQL
at all, actually. I have done the following installations on my 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
然后我做
me@ubuntu:~/Desktop/iPDC-v1.3.1/DBServer-1.1$ mysql -uroot -proot <"Db.sql"
我最终收到以下错误消息.
I ended up with the following error message.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
我该如何修复并继续?
注意:对于 MySQL 5.7 + ,请参见 @Lahiru 回答这个问题.其中包含更多当前信息.
Note: For MySQL 5.7+ please see answer from @Lahiru to this question. That contains more current information.
对于MySQL< 5.7:
For MySQL < 5.7:
默认的root密码为空白(即空字符串),而不是root
.这样您就可以登录为:
The default root password is blank (i.e. empty string) not root
. So you can just login as:
mysql -u root
您显然应该在安装后更改root密码
You should obviously change your root password after installation
mysqladmin -u root password [newpassword]
在大多数情况下,在广泛使用数据库之前,您还应该设置单个用户帐户.
In most cases you should also set up individual user accounts before working extensively with the DB as well.