记录下 rhel 7 安装MySQL 并重置root密码

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了记录下 rhel 7 安装MySQL 并重置root密码相关的知识,希望对你有一定的参考价值。

注意官方是很不提倡用root的。

下载并安装mysql

最新的rpm地址 https://dev.mysql.com/downloads/repo/yum/

#wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm 
#rpm -ivh mysql57-community-release-el7-11.noarch.rpm
#yum install mysql-server

重置root密码

# systemctl stop mysqld
# systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
# systemctl start mysqld
# mysql -u root

mysql>  UPDATE mysql.user
    ->     SET authentication_string = PASSWORD(password), password_expired = N
    ->     WHERE User = root AND Host = localhost;
    ->     FLUSH PRIVILEGES;
    ->     quit

# systemctl stop mysqld
# systemctl unset-environment MYSQLD_OPTS
# systemctl start mysqld
# mysql -u root -p
Enter password: 

mysql> show databases;

 

以上是关于记录下 rhel 7 安装MySQL 并重置root密码的主要内容,如果未能解决你的问题,请参考以下文章

Linux rhel7 下MySQL5.7.18详细安装文档

Linux rhel7 下MySQL5.7怎么 详细安装文档

Linux红帽RHEL 7 系统重置root用户密码

Linux rhel7 下MySQL5.7怎么 详细安装文档

RHEL7.3安装mysql5.7

Centos 7下mysql的安装与配置