In diesem Tutorial zeigen wir Ihnen, wie Sie MariaDB auf Ihrem CentOS 6-Server installieren und konfigurieren. Für diejenigen unter Ihnen, die es nicht wussten, MariaDB ist ein Drop-in-Ersatz für MySQL . Es ist einfach zu installieren, bietet viele Geschwindigkeits- und Leistungsverbesserungen und lässt sich problemlos in die meisten MySQL-Bereitstellungen integrieren. MariaDB ist weit verbreitet und mehrere Linux-Distributionen und große Unternehmen haben bereits von MySQL auf MariaDB umgestellt.
Dieser Artikel geht davon aus, dass Sie zumindest über Grundkenntnisse in Linux verfügen, wissen, wie man die Shell verwendet, und vor allem, dass Sie Ihre Website auf Ihrem eigenen VPS hosten. Die Installation ist recht einfach und setzt Sie voraus im Root-Konto ausgeführt werden, wenn nicht, müssen Sie möglicherweise 'sudo
hinzufügen ‘ zu den Befehlen, um Root-Rechte zu erhalten. Ich zeige Ihnen Schritt für Schritt die Installation der MariaDB-Datenbanken auf CentOS 6.
Installieren Sie MariaDB auf CentOS 6
Schritt 1. Zuerst müssen Sie das Repository auf Ihrem System aktivieren.
Navigieren Sie zu /etc/yum.repos.d/
auf Ihrer CentOS-Box und erstellen Sie eine neue Datei namens MariaDB repo.
## RHEL/CentOS 6 64-Bit ## [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/5.5/centos6-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1 ## RHEL/CentOS 6 32-Bit ## [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/5.5/centos6-x86 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
Schritt 2. MariaDB auf CentOS 6 installieren.
Installieren von MariaDB mit yum:
yum update yum install -y MariaDB-server MariaDB-client MariaDB-devel
Starten Sie nach Abschluss der Installation MariaDB:
service mysql start
MariaDB so einstellen, dass es beim Booten startet:
chkconfig mysql on
Schritt 3. MariaDB konfigurieren.
Die Konfigurationsdateien und Binärdateien für MariaDB sind größtenteils die gleichen wie für MySQL. Beispielsweise verwenden beide eine Konfigurationsdatei namens my.cnf
.
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
Schritt 4. MariaDB auch nach der Installation sichern.
Standardmäßig ist MariaDB nicht gehärtet. Sie können MariaDB mit dem Skript mysql_secure_installation sichern. Sie sollten jeden Schritt sorgfältig lesen, der ein Root-Passwort setzt, anonym entfernen Benutzer, verweigern Sie die Remote-Root-Anmeldung und entfernen Sie die Testdatenbank und den Zugriff auf die sichere 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 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]#
Schritt 5. Melden Sie sich bei MariaDB an.
MariaDB mit den zuvor festgelegten Root-Anmeldeinformationen anmelden.
mysql -u root -p
Herzlichen Glückwunsch! Sie haben MariaDB erfolgreich installiert. Vielen Dank, dass Sie dieses Tutorial zur Installation von MariaDB in einem CentOS 6-System verwendet haben. Für zusätzliche Hilfe oder nützliche Informationen empfehlen wir Ihnen, die offizielle MariaDB-Website zu besuchen.