MySQL 5.7.x 安装

1. MySQL官方URL:https://repo.mysql.com/

2. MySQL Repo

  1. [mysql57-community]
  2. name=MySQL 5.7 Community Server
  3. baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/
  4. enabled=1
  5. gpgcheck=0

3. CentOS上安装

  1. --------------------------------------------------------------------------------------------
  2. # 安装MySQL
  3. # yum -y install mysql-community-server.x86_64
  4. --------------------------------------------------------------------------------------------
  5. # 启动MySQL
  6. # systemctl statr mysqld.service
  7. --------------------------------------------------------------------------------------------
  8. # 获取临时生成的密码
  9. # grep password /var/log/mysqld.log
  10. ****** 1 [Note] A temporary password is generated for root@localhost: -n5:oh(tQwnI

4. 登录MySQL变更root密码

  1. # mysql -u root -p
  2. Enter password: '临时密码'
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 5
  5. Server version: 5.7.35 MySQL Community Server (GPL)
  6. Copyright (c) 2000, 2021, Oracle and/or its affiliates.
  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.
  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  11. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';
  12. Query OK, 0 rows affected (0.00 sec)
  13. mysql> quit;
  14. Bye