MariaDB是MySQL的替代品。它易于安装,提供了许多速度和性能改进,并且易于集成到大多数MySQL部署中。MariaDB被广泛使用,并且有几个Linux发行版和大型公司已经从MySQL转换到了MariaDB。本文假设您至少具有linux的基础知识,了解如何使用shell,最重要的是,您将自己的站点托管在您自己的VPS上。安装很简单。我将在CentOS 7上逐步安装MariaDB。
首先,您需要在系统上启用存储库。
导航到您的CentOS框上的/etc/yum.repos.d/并创建一个名为MariaDB repo的新文件:
[mariadb] name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
步骤2.使用Yum安装MariaDB。
确保所有包是最新的:
yum update
yum install MariaDB-server MariaDB-client启动MariaDB并启用它启动服务器:
systemctl start mariadb.service
systemctl enable mariadb.service
步骤3.配置MariaDB。
MariaDB的配置文件和二进制文件大部分与MySQL相同。例如,都使用一个名为my.cnf的配置文件。
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
安装之后安装MariaDB。
默认情况下,MariaDB没有硬化。您可以使用mysql_secure_installation脚本来保护MariaDB。您应仔细阅读并下面的每个步骤,将设置root密码,删除匿名用户,禁止远程root登录,并删除测试数据库并访问安全的MariaDB。
### mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we\”ll need the current
password for the root user. If you\”ve just installed MariaDB, and
you haven\”t set the root password yet, the password will be blank,
so you should just press enter here.Enter current password for root (enter for none):
OK, successfully used password, moving on…Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
… Success!By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.Remove anonymous users? [Y/n] y
… Success!Normally, root should only be allowed to connect from \”localhost\”. This
ensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] y
… Success!By default, MariaDB comes with a database named \”test\” that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.Remove test database and access to it? [Y/n] y
– Dropping test database…
… Success!
– Removing privileges on test database…
… Success!Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.Reload privilege tables now? [Y/n] y
… Success!Cleaning up…
All done! If you\”ve completed all of the above steps, your MariaDB
installation should now be secure.Thanks for using MariaDB!
[root@idroot]#
步骤5.登录到MariaDB。
使用早先设置的root凭据登录MariaDB:
mysql -u root -p
祝贺的!您已经成功安装了MariaDB。感谢您使用本教程在CentOS 7系统上安装MariaDB。