在 centOS 上安装 mysql 总是 return 错误的 root 凭据

Install mysql on centOS always return wrong root credentials

我已经在 CentOS 上安装了 mysql,如 https://www.linode.com/docs/databases/mysql/how-to-install-mysql-on-centos-7

中所述

总是在第一次安装时,我在命令后收到一条消息:

sudo mysql_secure_installation

Error: Access denied for user 'root'@'localhost' (using password: NO)

以下是一些信息: 命令 + 结果

cat /etc/*-release

CentOS Linux release 7.3.1611 (Core) NAME="CentOS Linux" VERSION="7 (Core)" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="7" PRETTY_NAME="CentOS Linux 7 (Core)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:centos:centos:7" HOME_URL="https://www.centos.org/" BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7" CENTOS_MANTISBT_PROJECT_VERSION="7" REDHAT_SUPPORT_PRODUCT="centos" REDHAT_SUPPORT_PRODUCT_VERSION="7"

CentOS Linux release 7.3.1611 (Core) CentOS Linux release 7.3.1611 (Core)

猫/etc/redhat-release

CentOS Linux release 7.3.1611 (Core)

猫/proc/version

Linux version 3.10.0-327.28.2.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) #1 SMP Wed Aug 3 11:11:39 UTC 2016

我的主机名不是 localhost,但 root 始终配置为 'localhost'。 另外,我有 'root' 用户用于 linux(与 mysql 同名)——我已经尝试了 linux root 用户和空白密码的密码,但仍然得到相同的结果错误。

我重新安装了 mysql,但还是出现同样的错误。

拜托,帮忙。

谢谢。

正如我在

中看到的

步骤:

1.Add skip-grant-tables under [mysqld] (nano etc/my.cnf) 
2.service restart.
3.flush privileges;
4.change root password (root) ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword';
5.Go back to /etc/my.cnf and remove/comment skip-grant-tables
6.Restart Mysql

之后,我通过命令行查看: telnet 3306,好像是对的