当使用apt-get安装mysql后,ubuntu会自动生成一个用户名和密码。所以在第一次登陆时会报如下错误
ERROR 1045 (28000): Access denied for user ‘db‘@‘localhost‘ (using password: NO)
而真正的用户名和密码在 /etc/mysql/debian.cnf
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = Y3fwpm731BnZtjry
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = Y3fwpm731BnZtjry
socket = /var/run/mysqld/mysqld.sock
basedir = /usr
此时进去后就是DBA 权限,那么就可以修改密码了。