Mysql数据库的安装
本安装手册是以在Centos7上安装Mysql为例。
- 检查操作系统中是否安装了wget工具。
[root@localhost ~]# wget -bash: wget: command not found |
(2)如果没有安装的话,则进行安装wget
[root@localhost ~]# yum install wget –y …. …. Installed: wget.x86_64 0:1.14-18.el7_6.1
Complete! |
(3)下载mysql的官方yum源并检查下载结果
[root@localhost ~]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm [root@localhost ~]# ls anaconda-ks.cfg mysql57-community-release-el7-10.noarch.rpm |
(4)安装mysql的yum源
[root@localhost ~]# yum -y install mysql57-community-release-el7-10.noarch.rpm
Loaded plugins: fastestmirror Examining mysql57-community-release-el7-10.noarch.rpm: mysql57-community-release-el7-10.noarch Marking mysql57-community-release-el7-10.noarch.rpm to be installed Resolving Dependencies --> Running transaction check ---> Package mysql57-community-release.noarch 0:el7-10 will be installed --> Finished Dependency Resolution
Dependencies Resolved
======================================================================================================================================================================= Package Arch Version Repository Size ======================================================================================================================================================================= Installing: mysql57-community-release noarch el7-10 /mysql57-community-release-el7-10.noarch 30 k
Transaction Summary ======================================================================================================================================================================= Install 1 Package
Total size: 30 k Installed size: 30 k Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : mysql57-community-release-el7-10.noarch 1/1 Verifying : mysql57-community-release-el7-10.noarch 1/1
Installed: mysql57-community-release.noarch 0:el7-10
Complete! |
(5)检查安装结果,如果有红色的两行文件内容,则表示成功。
[root@localhost ~]# ll /etc/yum.repos.d/ total 40 -rw-r--r--. 1 root root 1664 Sep 5 2019 CentOS-Base.repo -rw-r--r--. 1 root root 1309 Sep 5 2019 CentOS-CR.repo -rw-r--r--. 1 root root 649 Sep 5 2019 CentOS-Debuginfo.repo -rw-r--r--. 1 root root 314 Sep 5 2019 CentOS-fasttrack.repo -rw-r--r--. 1 root root 630 Sep 5 2019 CentOS-Media.repo -rw-r--r--. 1 root root 1331 Sep 5 2019 CentOS-Sources.repo -rw-r--r--. 1 root root 6639 Sep 5 2019 CentOS-Vault.repo -rw-r--r--. 1 root root 1627 Apr 5 2017 mysql-community.repo -rw-r--r--. 1 root root 1663 Apr 5 2017 mysql-community-source.repo |
(6)安装mysql server,这一步时间会比较长,网络良好的情况,大概十分钟左右。
[root@localhost ~]# yum -y install mysql-community-server |
执行安装命令后,如果网络不是很好的情况,一直处在下载mysql-community-server-5.7.29-1.el7.x86_64.rpm和mysql-community-client-5.7.29-1.el7.x86_64.rpm的情况下,可以提前下载这两个文件,
下载网址:
https://dev.mysql.com/downloads/mysql/5.7.html?os=src
然后把文件上传到如下目录,终止命令执行,然后再次执行安装命令即可。
/var/cache/yum/x86_64/7/mysql57-community/packages
(7)启动mysql。
先检查mysql的启动状态。 [root@localhost ~]# systemctl status mysqld ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: inactive (dead) Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html [root@localhost ~]# systemctl start mysqld [root@localhost ~]# systemctl status mysqld ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2020-03-14 21:14:49 EDT; 13s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 4751 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS) Process: 4701 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 4754 (mysqld) CGroup: /system.slice/mysqld.service └─4754 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mys...
Mar 14 21:14:40 localhost.localdomain systemd[1]: Starting MySQL Server... Mar 14 21:14:49 localhost.localdomain systemd[1]: Started MySQL Server. |
到此就安装成功了。