mysql - MySQL CentOS 6 无法设置根密码

标签 mysql linux centos6

概述

嗨!我是 Linux 新手,但我能够在多个 VPS 上安装并运行 MySQL;但是,我最近通过重新安装 CentOS 6 重置了我的 VPS。我遇到了有关 MySQL 的问题,它不允许我登录或设置密码。我以前从未遇到过这个问题,所以我希望有人能帮我解决。

重现问题的步骤

yum install wget
wget http://dev.mysql.com/get/mysql57-community-release-el6-8.noarch.rpm
sudo yum localinstall mysql57-community-release-el6-8.noarch.rpm
yum install mysql mysql-server
/etc/init.d/mysqld start
mysqladmin -u root -p "setpasswordhere"

在最后一步,它不允许我输入当前的 root 密码,但在第一种情况下从未提示我设置密码。我现在已经重新安装了 VPS 2-3 次,并执行了相同的过程,但在过去并没有给我带来问题。尽管重新安装整个 VPS 并不是最好的事情,但当我完全迷失并且对某些东西不熟悉时,重新安装并从头开始只需要大约 5-10 分钟。

研究: 我按照一些步骤在这里安装 MySQL:https://dev.mysql.com/doc/mysql-repo-excerpt/5.6/en/linux-installation-yum-repo.html

错误信息是:

mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

或者

mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'

很明显,这里设置了密码,但我从来没有被提示创建一个密码。

控制台输出:

[root@vps83299 ~]# mysqladmin -u root -p ""
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
[root@vps83299 ~]#

按照此说明时出现错误:https://ubuntu.flowconsult.at/en/mysql-set-change-reset-root-password/

mysql> update user set password=PASSWORD("newpass") where User='root';
ERROR 1054 (42S22): Unknown column 'password' in 'field list'

最佳答案

要访问 mysql,请使用:

mysqladmin -uroot -psetpasswordhere

mysql -uroot -psetpasswordhere

关于mysql - MySQL CentOS 6 无法设置根密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37648881/

相关文章:

python - 卢比符号在 odoo 的发票报告中显示为空白框

php - mysql_fetch_array() 不工作,没有错误

c - 常量与变量不匹配

java - 从 Windows 计算机远程在 Linux 上运行进程

Linux Centos 6 如何过滤端口 80 + 破坏 Apache 2

c++ - 如何找到 glx 库名称?

mysql - 在WHERE条件下选择MySQL中的最后一条记录

mysql - 条件 SQL 选择 : when select has a value select all but the smallest date

c++ - 为每个查询初始化到 MYSQL 的连接有多糟糕?

linux - 带 make 的管道不起作用