Linux Admin 简明教程
Linux Admin - MySQL Setup On CentOS 7
正如在将 CentOS 配置为与 Maria DB 配合使用时,CentOS 7 yum 存储库中没有本地 MySQL 包。考虑到这一点,我们需要添加一个 MySQL 托管存储库。
As touched upon briefly when configuring CentOS for use with Maria DB, there is no native MySQL package in the CentOS 7 yum repository. To account for this, we will need to add a MySQL hosted repository.
MariaDB vs MySQL On CentOS Linux
需要指出的一点是 MySQL 需要一组与 MariaDB 不同的基本依赖项。同时使用 MySQL 会打破 CentOS 的概念和哲学:专为实现最大可靠性而设计的生产包。
One thing to note is MySQL will require a different set of base dependencies from MariaDB. Also using MySQL will break the concept and philosophy of CentOS: production packages designed for maximum reliability.
因此,在决定是否使用 Maria 还是 MySQL 时应权衡这两个选项:我的当前数据库模式是否适用于 Maria?安装 MySQL 相比使用 Maria 有什么优势?
So when deciding whether to use Maria or MySQL one should weigh two options: Will my current DB Schema work with Maria? What advantage does installing MySQL over Maria give me?
Maria 组件对 MySQL 结构完全透明,具有更好的许可,并增加了一些效率。除非有令人信服的理由出现,否则建议将 CentOS 配置为使用 MariaDB。
Maria components are 100% transparent to MySQL structure, with some added efficiency with better licensing. Unless a compelling reason comes along, it is advised to configure CentOS to use MariaDB.
在 CentOS 上支持 Maria 的最大原因是:
The biggest reasons for favoring Maria on CentOS are −
-
Most people will be using MariaDB. When experiencing issues you will get more assistance with Maria.
-
CentOS is designed to run with Maria. Hence, Maria will offer better stability.
-
Maria is officially supported for CentOS.
Download and Add the MySQL Repository
从以下链接下载并安装 MySQL 存储库:
We will want to download and install the MySQL repository from −
Step 1 − 下载存储库。
Step 1 − Download the Repository.
存储库经过方便地打包,使用 rpm 包可以轻松安装。可使用 wget 下载:
The repository comes conveniently packaged in an rpm package for easy installation. It can be downloaded with wget −
[root@centos]# wget http://repo.mysql.com/mysql-community-release-el75.noarch.rpm
--2017-02-26 03:18:36-- http://repo.mysql.com/mysql-community-release-el75.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 104.86.98.130
Step 2 −从 YUM 安装 MySQL。
Step 2 − Install MySQL From YUM.
我们现在可以使用 yum 包管理器来安装 MySQL:
We can now use the yum package manager to install MySQL −
[root@centos]# yum -y install mysql-server
Step 3 −启动并启用 MySQL 守护进程服务。
Step 3 − Start and Enable the MySQL Daemon Service.
[root@centos]# systemctl start mysql
[root@centos]# systemctl enable mysql
Step 4 −确保我们的 MySQL 服务正在运行中。
Step 4 − Make sure our MySQL service is up and running.
[root@centos]# netstat -antup | grep 3306
tcp6 0 0 :::3306 :::* LISTEN 6572/mysqld
[root@centos]#
注意:我们不会允许任何防火墙规则通过。通常将 MySQL 配置为使用 Unix Domain Sockets 。这确保只有 LAMP 堆栈的 Web 服务器在本地才能访问 MySQL 数据库,从而消除了数据库软件中的整个攻击向量维度。
Note − We will not allow any firewall rules through. It’s common to have MySQL configured to use Unix Domain Sockets. This assures only the web-server of the LAMP stack, locally, can access the MySQL database, taking out a complete dimension in the attack vector at the database software.