如何在Linux系统中使用yum命令安装MySQL

1、安装软件
shell 复制代码
# yum install -y https://repo.mysql.com//mysql80-community-release-el7-8.noarch.rpm
# yum -y install mysql-community-server

网址来源:https://dev.mysql.com/downloads/repo/yum/

2、启动软件
shell 复制代码
 # systemctl enable mysqld
 # systemctl start mysqld
 # systemctl status mysqld
3、配置软件

a、获取密码

shell 复制代码
[root@localhost ~]# grep 'password' /var/log/mysqld.log
2023-07-25T06:31:36.346005Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: uH0sps!uq&Sg
[root@localhost ~]# 

b、软件设置

shell 复制代码
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.

...省略...

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

# 修改密码
mysql> ALTER USER USER() IDENTIFIED BY 'AB%34%ba';
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> SHOW VARIABLES LIKE 'validate_password%';
+-------------------------------------------------+--------+
| Variable_name                                   | Value  |
+-------------------------------------------------+--------+
| validate_password.changed_characters_percentage | 0      |
| validate_password.check_user_name               | ON     | 是否使用该插件
| validate_password.dictionary_file               |        | 插件用于验证密码强度的字典文件路径
| validate_password.length                        | 8      | 密码最小长度
| validate_password.mixed_case_count              | 1      | 密码至少要包含的小写和大写字母个数
| validate_password.number_count                  | 1      | 密码至少要包含的数字个数
| validate_password.policy                        | MEDIUM | 密码强度检查等级
| validate_password.special_char_count            | 1      | 密码至少要包含的特殊字符数
+-------------------------------------------------+--------+
8 rows in set (0.01 sec)

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

# 允许root账号远程访问
mysql> update user set host = '%' where host = 'localhost' and user = 'root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

# mysql8.0 引入了 caching_sha2_password 加密方式,这种方式SQLYong等客户端不支持,为此需要将其改成SQLYong等客户端支持的加密方式:mysql_native_password
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'AB%34%ba';
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye
[root@localhost ~]#

说明:密码强度检查等级分为0/LOW(只检查长度)、1/MEDIUM(检查长度、数字、大小写、特殊字符)和2/STRONG(检查长度、数字、大小写、特殊字符字典文件)。

4、开放端口

为了实现远程连接,我们需要开放3306端口

shell 复制代码
[root@localhost ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
[root@localhost ~]# firewall-cmd --reload
相关推荐
AI_Lab011 小时前
宝塔用了两年,有没有必要换成轻量方案?
linux·运维·服务器
by209991 小时前
Linux GDB 调试与 CGDB 使用
linux·运维·服务器·经验分享
星恒随风1 小时前
Linux网络编程:应用层协议究竟是什么?从网络计算器到TCP Socket抽象基类完整实现
linux·网络·笔记·tcp/ip
`Levie4 小时前
MySQL-数据库服务日志管理与数据闪回
数据库·mysql
香蕉大香蕉(06敬畏市场)4 小时前
MySQL 单点详解(01)
java·数据库·mysql·面试·博客·实习
feng_you_ying_li4 小时前
linux之网络层
linux·运维·网络
未来之窗软件服务4 小时前
Linux 运维日志删除的多种方式—东方仙盟
linux·运维·服务器·仙盟创梦ide·东方仙盟
吹什么轩4 小时前
MySQL 事务管理:从 ACID 到 MVCC,一篇讲透
数据库·mysql
小雉系统4 小时前
BcoreOS实战:用一个升级包,让Rocky Linux跑进Debian服务器
linux·运维·服务器·debian
thethefighter4 小时前
快速预览Word、WPS秒开,支持空格弹窗
linux·word·wps·快速预览·空格弹窗·nhdeepview