注意官方是很不提倡用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;

 

相关文章:

  • 2021-11-07
  • 2021-12-19
  • 2021-06-17
  • 2021-11-27
  • 2021-12-01
  • 2022-12-23
  • 2022-01-22
  • 2021-08-22
猜你喜欢
  • 2021-12-17
  • 2021-09-21
  • 2021-07-07
  • 2021-11-07
  • 2021-06-28
  • 2022-12-23
相关资源
相似解决方案