MySQL 是一个流行的开源关系型数据库管理系统(RDBMS),由瑞典公司 MySQL AB 开发,后被 Sun Microsystems 收购,最终又被 Oracle Corporation 收购。MySQL 使用结构化查询SQL)进行数据库管理。
测试系统:
CentOS Stream 9
测试步骤:
查看yum安装源中是否存在MySQL
[root@localhost ~]# yum info mysql
上次元数据过期检查:0:27:46 前,执行于 2024年06月07日 星期五 15时57分28秒。
可安装的软件包
名称 : mysql
版本 : 8.0.36
发布 : 1.el9
架构 : x86_64
大小 : 2.8 M
源 : mysql-8.0.36-1.el9.src.rpm
仓库 : appstream
概况 : MySQL client programs and shared libraries
URL : http://www.mysql.com
协议 : GPLv2 with exceptions and LGPLv2 and BSD
描述 : MySQL is a multi-user, multi-threaded SQL database server. MySQL is
: a client/server implementation consisting of a server daemon
: (mysqld) and many different client programs and libraries. The base
: package contains the standard MySQL client programs and generic
: MySQL files.
[root@localhost ~]#
查看相关软件包信息
[root@localhost ~]# yum list 'mysql*'
上次元数据过期检查:0:31:45 前,执行于 2024年06月07日 星期五 15时57分28秒。
可安装的软件包
mysql.x86_64 8.0.36-1.el9 appstream
mysql-common.x86_64 8.0.36-1.el9 appstream
mysql-errmsg.x86_64 8.0.36-1.el9 appstream
mysql-selinux.noarch 1.0.10-1.el9 appstream
mysql-server.x86_64 8.0.36-1.el9 appstream
[root@localhost ~]#
查看mysql-serve信息
[root@localhost ~]# yum info mysql-server
上次元数据过期检查:0:32:58 前,执行于 2024年06月07日 星期五 15时57分28秒。
可安装的软件包
名称 : mysql-server
版本 : 8.0.36
发布 : 1.el9
架构 : x86_64
大小 : 17 M
源 : mysql-8.0.36-1.el9.src.rpm
仓库 : appstream
概况 : The MySQL server and related files
URL : http://www.mysql.com
协议 : GPLv2 with exceptions and LGPLv2 and BSD
描述 : MySQL is a multi-user, multi-threaded SQL database server. MySQL is
: a client/server implementation consisting of a server daemon
: (mysqld) and many different client programs and libraries. This
: package contains the MySQL server and some accompanying files and
: directories.
[root@localhost ~]#
安装mysql-server
[root@localhost ~]# yum -y install mysql-server
上次元数据过期检查:0:35:20 前,执行于 2024年06月07日 星期五 15时57分28秒。
依赖关系解决。
===================================================================================
软件包 架构 版本 仓库 大小
===================================================================================
安装:
mysql-server x86_64 8.0.36-1.el9 appstream 17 M
安装依赖关系:
checkpolicy x86_64 3.6-1.el9 baseos 353 k
libicu x86_64 67.1-9.el9 baseos 9.6 M
mariadb-connector-c-config noarch 3.2.6-1.el9 appstream 11 k
mecab x86_64 0.996-3.el9.4 appstream 356 k
mysql x86_64 8.0.36-1.el9 appstream 2.8 M
mysql-common x86_64 8.0.36-1.el9 appstream 74 k
mysql-errmsg x86_64 8.0.36-1.el9 appstream 505 k
mysql-selinux noarch 1.0.10-1.el9 appstream 37 k
policycoreutils-python-utils noarch 3.6-2.1.el9 baseos 77 k
protobuf-lite x86_64 3.14.0-13.el9 appstream 232 k
python3-audit x86_64 3.1.2-2.el9 baseos 83 k
python3-distro noarch 1.5.0-7.el9 baseos 37 k
python3-libsemanage x86_64 3.6-1.el9 baseos 80 k
python3-policycoreutils noarch 3.6-2.1.el9 baseos 2.1 M
python3-setools x86_64 4.4.4-1.el9 baseos 605 k
python3-setuptools noarch 53.0.0-12.el9 baseos 944 k
查询数据库是否安装成功
[root@localhost ~]# rpm -q mysql-server
mysql-server-8.0.36-1.el9.x86_64
查询防火墙是否关闭
[root@localhost ~]# sestatus
SELinux status: disabled
[root@localhost ~]# systemctl status firewalld
○ firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; preset: >
Active: inactive (dead)
Docs: man:firewalld(1)
[root@localhost ~]# iptables -vnL
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
[root@localhost ~]#
启动MySQL查看进程
[root@localhost ~]# systemctl start mysqld
[root@localhost ~]# ps axu | grep mysqld
mysql 9561 7.0 5.0 2365264 406928 ? Ssl 16:39 0:01 /usr/libexec/mysqld --basedir=/usr
root 9609 0.0 0.0 6636 2176 pts/1 S+ 16:40 0:00 grep --color=auto mysqld
[root@localhost ~]#
登录MySQL数据库
[root@localhost ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.36 Source distribution
Copyright (c) 2000, 2024, 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库的user表的user、host、authentication_string字段的数据库信息
mysql> select user,host,authentication_string from mysql.user;
+------------------+-----------+------------------------------------------------------------------------+
| user | host | authentication_string |
+------------------+-----------+------------------------------------------------------------------------+
| mysql.infoschema | localhost | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| mysql.session | localhost | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| mysql.sys | localhost | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| root | localhost | |
+------------------+-----------+------------------------------------------------------------------------+
4 rows in set (0.00 sec)
mysql>
退出数据库
mysql> exit
Bye
[root@localhost ~]#