当连接到 MySQL 时根来自 Linux 用户用户
user@computer:~/$ mysql -u root -p
Enter password:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
当做同样的事情,但作为Linux用户根有用。
user@computer:~/$ sudo mysql -u root -p
sudo mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 5.7.12-0ubuntu1.1 (Ubuntu)
Copyright (c) 2000, 2016, 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>
在你提到之前,MySQL 被安装为'根' 或者 MySQL 正在作为 '根' 用户,它被安装apt-get根据 MySQL Docs 的说明,它将强制并始终以“mysql'Linux 用户帐户。
我不知道为什么会发生这种情况。我完全从头开始重新安装了 MySQL,但还是不行。重新启动后,问题依然存在。
MySQL 服务:
user@computer:~/$ service mysql status
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2016-06-27 13:56:42 CDT; 38min ago
Process: 18007 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
Process: 18001 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 18006 (mysqld)
CGroup: /system.slice/mysql.service
└─18006 /usr/sbin/mysqld
Jun 27 13:56:41 d4rkt0p systemd[1]: Starting MySQL Community Server...
Jun 27 13:56:42 d4rkt0p systemd[1]: Started MySQL Community Server.
答案1
根据您上面的帖子,用户第二次无法连接的原因似乎是由于没有收到正确的密码。相关:
用户@计算机:〜/ $ mysql -u newuser -p
输入密码:
错误 1045(28000):拒绝用户“newuser”@“localhost”访问(使用密码:否)
用户@计算机:〜/ $
您需要找出新用户第二次不使用密码的原因,并验证密码是否被第二次使用。