如何安装install mariadb 10 2 centos 7
在本文中,我们将学习–如何在Centos 7 / RHEL上安装MariaDB 10.2。这可以用作初学者的指南或参考。请注意,它也可以用作MySQL的替代替代品。
MariaDB的功能
MariaDB是一种开源的关系数据库管理软件。
MariaDB具有强大的存储引擎,功能强大,快速且可扩展。
MariaDB具有GIS和JSON等新功能。
服务器信息和程序包
该软件包包括:MariadB,Mariadb服务器,MariaDB库。
使用的守护程序名称是:mariadb。
端口号:3306。
配置路径:/etc/my.cnf。
在Centos 7 / RHEL 7上安装Maria DB 10.2
通常,mariaDB软件包在本地存储库中带有安装媒体,我们可以进行安装,但是如果需要安装最新的软件包,我们可以通过将存储库添加到yum本地存储库列表中来进行安装。我们使用以下命令和代码将存储库添加到yum。
将仓库添加到Yum中以进行MariaDB安装
为Centos 7 64位添加回购
[mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.2/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
为RHEL 7 64位添加仓库
[mariadb10] name = MariaDB baseurl = http://yum.mariadb.org/10.2/rhel7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
使用Yum Repo的安装MariaDB
我们可以使用Yum Repo安装MariaDB,因为我们刚刚将存储库添加到本地yum,下面是使用Yum安装mariaDB的命令
# yum groupinstall mariadb* Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: ftp.iitm.ac.in * extras: ftp.iitm.ac.in * updates: ftp.iitm.ac.in .... .... ..... .... .... ... .... Downloading packages: -------------------------------------------------------------------------------------------------------------------------------------------- Total 68 MB/s | 22 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Warning: RPMDB altered outside of yum. Installing : perl-Data-Dumper-2.145-3.el7.x86_64 1/13 Installing : unixODBC-2.3.1-10.el7.x86_64 2/13 Installing : perl-Net-Daemon-0.48-5.el7.noarch 3/13 Installing : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 4/13 Installing : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 5/13 Installing : perl-IO-Compress-2.061-2.el7.noarch 6/13 Installing : perl-PlRPC-0.2020-14.el7.noarch 7/13 Installing : perl-DBI-1.627-4.el7.x86_64 8/13 Installing : perl-DBD-MySQL-4.023-5.el7.x86_64 9/13 Installing : 1:mariadb-5.5.41-2.el7_0.x86_64 10/13 Installing : 1:mariadb-server-5.5.41-2.el7_0.x86_64 11/13 Installing : mysql-connector-odbc-5.2.5-6.el7.x86_64 12/13 Installing : MySQL-python-1.2.3-11.el7.x86_64 13/13 Verifying : 1:mariadb-5.5.41-2.el7_0.x86_64 1/13 Verifying : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 2/13 Verifying : mysql-connector-odbc-5.2.5-6.el7.x86_64 3/13 Verifying : perl-Data-Dumper-2.145-3.el7.x86_64 4/13 Verifying : MySQL-python-1.2.3-11.el7.x86_64 5/13 Verifying : 1:mariadb-server-5.5.41-2.el7_0.x86_64 6/13 Verifying : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 7/13 Verifying : perl-PlRPC-0.2020-14.el7.noarch 8/13 Verifying : perl-Net-Daemon-0.48-5.el7.noarch 9/13 Verifying : perl-DBI-1.627-4.el7.x86_64 10/13 Verifying : unixODBC-2.3.1-10.el7.x86_64 11/13 Verifying : perl-DBD-MySQL-4.023-5.el7.x86_64 12/13 Verifying : perl-IO-Compress-2.061-2.el7.noarch 13/13 Installed: MySQL-python.x86_64 0:1.2.3-11.el7 mariadb.x86_64 1:5.5.41-2.el7_0 mariadb-server.x86_64 1:5.5.41-2.el7_0 mysql-connector-odbc.x86_64 0:5.2.5-6.el7 Dependency Installed: perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 perl-DBD-MySQL.x86_64 0:4.023-5.el7 perl-DBI.x86_64 0:1.627-4.el7 perl-Data-Dumper.x86_64 0:2.145-3.el7 perl-IO-Compress.noarch 0:2.061-2.el7 perl-Net-Daemon.noarch 0:0.48-5.el7 perl-PlRPC.noarch 0:0.2020-14.el7 unixODBC.x86_64 0:2.3.1-10.el7 Complete!
启动MariaDB服务
以下是启动mariaDB服务的命令
# systemctl start mariadb.services
我们需要添加服务以在引导时启动服务,我们可以使用以下命令在引导时启动mariaDB服务。
# systemctl enable mariadb.services
添加MariaDB端口以允许来自防火墙
# firewall-cmd –permanent –add-services=mysql # firewall-cmd –permanent –add-port=3306/tcp # firewall-cmd –reload
保护mariadb并设置root用户密码
默认情况下,未设置mariadb的root密码,没有root密码,我们将无法登录数据库服务器。下面是用于为mariaDB设置root密码,删除匿名用户并通过限制root的远程登录并删除测试数据库来保护mariaDB的命令。
# mysql_secure_installation /usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found 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 authorization. Set root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading the 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. Install MariaDB 10.2 RHEL 7 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. Install MariaDB 10.2 RHEL 7 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!
测试与MariaDB的连接。
完成安装并为root用户分配密码并保护连接后,我们需要通过登录数据库来测试mariadb。以下是测试mariaDB的命令-
# mysql -uroot -p Enter password: Welcome to the MariaDB monitor. Commands end with; or \g. Your MariaDB connection id is 10 Server version: 5.5.41-MariaDB MariaDB Server Install MariaDB 10.2 RHEL 7 Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
通过使用上述步骤,我们可以在CentOS 7 / RHEL 7上安装MariadDB 10.2,并通过删除匿名用户和测试数据库来保护mariadb,这是MySQL服务器的一个很好的替代选择。在未来的文章中,您将了解有关MariaDB的更多信息。