一起养成写作习惯!这是我参与「掘金日新计划 · 4 月更文挑战」的第9天,点击查看活动详情。
下载rpm包
[root@master mysql]# ll
-rw-r--r--. 1 root root 14052636 3月 23 2021 mysql-community-client-8.0.24-1.el8.x86_64.rpm
-rw-r--r--. 1 root root 100356 3月 23 2021 mysql-community-client-plugins-8.0.24-1.el8.x86_64.rpm
-rw-r--r--. 1 root root 632772 3月 23 2021 mysql-community-common-8.0.24-1.el8.x86_64.rpm
-rw-r--r--. 1 root root 1497724 3月 23 2021 mysql-community-libs-8.0.24-1.el8.x86_64.rpm
-rw-r--r--. 1 root root 55483196 3月 23 2021 mysql-community-server-8.0.24-1.el8.x86_64.rpm
开始安装
需要按顺序安装,有依赖关系
yum install -y mysql-community-common-8.0.24-1.el8.x86_64.rpm
yum install -y mysql-community-client-plugins-8.0.24-1.el8.x86_64.rpm
yum install -y mysql-community-libs-8.0.24-1.el8.x86_64.rpm
yum install -y mysql-community-client-8.0.24-1.el8.x86_64.rpm
yum install -y mysql-community-server-8.0.24-1.el8.x86_64.rpm
启动mysqld服务
systemctl enable mysqld
systemctl start mysqld
查看是否启动
[root@master mysql]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2022-04-25 19:15:50 CST; 1h 59min ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Main PID: 14757 (mysqld)
Status: "Server is operational"
Tasks: 38 (limit: 23624)
Memory: 289.7M
CGroup: /system.slice/mysqld.service
└─14757 /usr/sbin/mysqld
- 查看密码
[root@master local]# grep 'temporary password' /var/log/mysqld.log
2022-04-25T11:15:47.288359Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: hjtut>)<n7;K
- 用户名密码登录
[root@master local]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.24
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
- 修改密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'feng'
-> ;
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql>
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Feng_6666';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
第一次设置密码太简单了不行,需要设置复杂一点的密码。
有时候事情会如你所愿,有时候则事与愿违。