1. 程式人生 > >CentOS7安裝MySQL Server

CentOS7安裝MySQL Server

sys ref lease intern httpd 127.0.0.1 bin 查看 emc

CentOS 7的默認YUM源中是MariaDB,而不是我們常用的MySQL。

本文將介紹如何通過YUM安裝MySQL。

  1. 首先下載Yum源的rpm包

具體地址在:

http://repo.mysql.com/

可以選擇自己需要的版本。

我下載的是:

wget http://repo.mysql.com/mysql57-community-release-el7.rpm

  1. 安裝rpm文件

通過命令,安裝MySQL的YUM源:

rpm -ivh mysql57-community-release-el7.rpm

可以在/etc/yum.repos.d中看到相關的repo文件:

[[email protected]

/* */ yum.repos.d]# ls

CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo mysql-community-source.repo

CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo mysql-community.repo OpenLogic.repo

[[email protected] yum.repos.d]#

  1. YUM安裝MySQL

通過yum命令安裝:

yum install -y mysql-server

  1. 啟動MySQL

啟動:

Systemctl start mysqld

查看:

Systemctl status mysqld

設置開機啟動:

Systemctl enable mysqld

通過netstat查看:

[[email protected] yum.repos.d]# netstat -tunlp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name

tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd

tcp 0 0 0.0.0.0:53 0.0.0.0:* LISTEN 808/dnsmasq

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 807/sshd

tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 909/master

tcp6 0 0 :::111 :::* LISTEN 1/systemd

tcp6 0 0 :::80 :::* LISTEN 1526/httpd

tcp6 0 0 :::53 :::* LISTEN 808/dnsmasq

tcp6 0 0 :::22 :::* LISTEN 807/sshd

tcp6 0 0 ::1:25 :::* LISTEN 909/master

tcp6 0 0 :::3306 :::* LISTEN 24276/mysqld

udp 0 0 127.0.0.1:323 0.0.0.0:* 498/chronyd

udp 0 0 0.0.0.0:617 0.0.0.0:* 12738/rpcbind

udp 0 0 0.0.0.0:40620 0.0.0.0:* 757/dhclient

udp 0 0 0.0.0.0:53 0.0.0.0:* 808/dnsmasq

udp 0 0 0.0.0.0:68 0.0.0.0:* 757/dhclient

udp 0 0 0.0.0.0:111 0.0.0.0:* 12738/rpcbind

udp6 0 0 ::1:323 :::* 498/chronyd

udp6 0 0 :::617 :::* 12738/rpcbind

udp6 0 0 :::40419 :::* 757/dhclient

udp6 0 0 :::53 :::* 808/dnsmasq

udp6 0 0 :::111 :::* 12738/rpcbind

可以看到3306端口。

CentOS7安裝MySQL Server