本文使用Xshell作为虚拟机连接的工具
简介
本文使用CentOS系统,使用命令行的方式安装MySQL
软件
- VMWare15
- CentOS7
- MySQL5.7
过程
一、安装wget
(1)将当前账户切换为root账户
[mysql@localhost mysql]# su
(2)安装wget
[root@localhost mysql]# yum install wget
二、安装mysql源
因为MySQL可能存在闭源风险,因此CentOS中使用MariaDB替换了MySQL,在使用时需要安装MySQL源,从而使用yum安装MySQL
(1)下载mysql源安装包
[root@localhost mysql]# wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
(2)安装mysql源
[root@localhost mysql]# yum localinstall mysql57-community-release-el7-8.noarch.rpm
(3)检查是否安装成功
[root@localhost mysql]# [root@localhost mysql]# yum repolist enabled | grep "mysql.*-community.*"
显示如下:
[root@localhost mysql]# yum repolist enabled | grep "mysql.*-community.*"
!mysql-connectors-community/x86_64 MySQL Connectors Community 203
!mysql-tools-community/x86_64 MySQL Tools Community 129
!mysql57-community/x86_64 MySQL 5.7 Community Server 504
三、安装mysql
[root@localhost mysql]# yum install mysql-community-server
四、启动mysql
[root@localhost mysql]# systemctl start mysqld
查看启动状态
[root@localhost mysql]# systemctl status mysqld
显示如下:
[root@localhost mysql]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since 二 2021-06-15 10:24:11 CST; 4min 53s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 1043 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 1009 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 1156 (mysqld)
CGroup: /system.slice/mysqld.service
└─1156 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
6月 15 10:24:02 localhost.localdomain systemd[1]: Starting MySQL Server...
6月 15 10:24:11 localhost.localdomain systemd[1]: Started MySQL Server.
至此,MySQL安装完成,在进一步配置后即可使用。