无法连接到 mysql 数据库。拒绝用户“root”@“localhost”访问

无法连接到 mysql 数据库。拒绝用户“root”@“localhost”访问

我安装了 mysql-server sudo apt-get install mysql-server,然后进行了安全安装sudo mysql_secure_installation并将密码设置为12345。但我无法连接到它。

felix@felix:/var/www/html/test$ systemctl status mysql.service
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: active (running) since sön 2017-02-19 22:19:38 CET; 3 days ago
 Main PID: 18502 (mysqld)
   CGroup: /system.slice/mysql.service
           └─18502 /usr/sbin/mysqld

feb 19 22:19:37 felix systemd[1]: Starting MySQL Community Server...
feb 19 22:19:38 felix systemd[1]: Started MySQL Community Server.

felix@felix:/var/www/html/test$ mysqladmin -p -u root version
Enter password: 
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost''

felix@felix:/var/www/html/test$ mysql -u root -p
Enter password: 
ERROR 1698 (28000): Access denied for user 'root'@'localhost'

这是什么原因造成的?我谷歌搜索的结果都是不知道密码的人。

相关内容