One place for hosting & domains

      MariaDB

      Installieren von MariaDB unter CentOS 8


      Einführung

      MariaDB ist ein Open-Source-basiertes Datenbank-Managementsystem, das häufig als Alternative für den MySQL-Teil des beliebten LAMP-Stacks (Linux, Apache, MySQL, PHP/Python/Perl) verwendet wird. Es ist als Drop-in-Ersatz für MySQL gedacht.

      In diesem Tutorial erklären wir Ihnen, wie Sie die neueste Version von MariaDB auf einem CentOS 8-Server installieren. Wenn Sie sich über MySQL im Vergleich zu MariaDB wundern: MariaDB ist das bevorzugte Paket und sollte nahtlos anstelle von MySQL funktionieren. Wenn Sie MySQL spezifisch benötigen, lesen Sie den Leitfaden Installieren von MySQL unter CentOS 8.

      Voraussetzungen

      Um diesem Tutorial folgen zu können, benötigen Sie einen CentOS 8-Server mit einem non-root sudo-fähigen user. Weitere Informationen über die Einrichtung eines Benutzers mit diesen Berechtigungen finden Sie im Leitfaden Ersteinrichtung des Servers unter CentOS 8.

      Schritt 1 — Installieren von MariaDB

      Verwenden Sie zunächst dnf zur Installation des Pakets MariaDB:

      • sudo dnf install mariadb-server

      Sie werden aufgefordert, die Aktion zu bestätigen. Drücken Sie y und dann ENTER, um fortzufahren.

      Sobald die Installation abgeschlossen ist, starten Sie den Dienst mit systemctl:

      • sudo systemctl start mariadb

      Überprüfen Sie dann den Status des Dienstes:

      • sudo systemctl status mariadb

      Output

      ● mariadb.service - MariaDB 10.3 database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled) Active: active (running) since Fri 2020-04-03 17:32:46 UTC; 52min ago Docs: man:mysqld(8) https://mariadb.com/kb/en/library/systemd/ Main PID: 4567 (mysqld) Status: "Taking your SQL requests now..." Tasks: 30 (limit: 5059) Memory: 77.1M CGroup: /system.slice/mariadb.service └─4567 /usr/libexec/mysqld --basedir=/usr . . . Apr 03 17:32:46 centos8-mariadb systemd[1]: Started MariaDB 10.3 database server.

      Wenn MariaDB erfolgreich gestartet wurde, sollte die Ausgabe active (running) zeigen und die letzte Zeile sollte in etwa so aussehen:

      Output

      Apr 03 17:32:46 centos8-mariadb systemd[1]: Started MariaDB 10.3 database server..

      Nehmen wir uns als Nächstes einen Moment Zeit, um sicherzustellen, dass MariaDB beim Booten startet, indem wir den Befehl systemctl enable verwenden:

      • sudo systemctl enable mariadb

      Output

      Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service. Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service. Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.

      MariaDB wird nun ausgeführt und ist konfiguriert, um beim Hochfahren zu starten. Als Nächstes wenden wir unsere Aufmerksamkeit der Sicherung unserer Installation zu.

      Schritt 2 — Sichern des MariaDB-Servers

      MariaDB enthält ein Sicherheitsskript, um einige der weniger sicheren Standardoptionen für Dinge wie Remote-root-Logins und Beispielbenutzer zu ändern. Verwenden Sie diesen Befehl zur Ausführung des Sicherheitsskripts:

      • sudo mysql_secure_installation

      Das Skript bietet eine detaillierte Erklärung für jeden Schritt. Der erste Schritt fragt nach dem root-Passwort, das noch nicht festgelegt wurde, sodass wir wie empfohlen ENTER drücken. Im Folgenden werden wir aufgefordert, dieses root-Passwort festzulegen. Denken Sie daran, dass dies für den root-Datenbankbenutzer gilt, nicht den root user Ihres CentOS-Servers selbst.

      Geben Sie Y und dann ENTER ein, um ein Passwort für den root-Datenbankbenutzer einzugeben und folgen Sie dann der Eingabeaufforderung.

      Nach der Aktualisierung des Passworts akzeptieren wir alle folgenden Sicherheitsvorschläge, indem wir y und dann ENTER drücken. Dadurch werden anonyme Benutzer entfernt, die Fernanmeldung als root user verhindert, die Testdatenbank entfernt und die Berechtigungstabelle neu geladen.

      Nachdem wir nun die Installation gesichert haben, überprüfen wir ihre Funktionalität, indem wir uns mit der Datenbank verbinden.

      Schritt 3 – Testen der Installation

      Wir können unsere Installation überprüfen und Informationen darüber erhalten, indem wir uns mit dem Tool mysqladmin, einem Client, mit dem Sie administrative Befehle ausführen können, verbinden. Verwenden Sie den folgenden Befehl, um sich als root (-u root) mit MariaDB zu verbinden, zur Eingabe eines Passworts (-p) aufgefordert zu werden und die Version der Installation ausgegeben zu bekommen.

      • mysqladmin -u root -p version

      Sie sollten eine ähnliche Ausgabe wie diese sehen:

      Output

      mysqladmin Ver 9.1 Distrib 10.3.17-MariaDB, for Linux on x86_64 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Server version 10.3.17-MariaDB Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/lib/mysql/mysql.sock Uptime: 6 min 5 sec Threads: 7 Questions: 16 Slow queries: 0 Opens: 17 Flush tables: 1 Open tables: 11 Queries per second avg: 0.043

      Dadurch wird angezeigt, dass die Installation erfolgreich war.

      Zusammenfassung

      In diesem Leitfaden haben Sie MariaDB installiert, um als SQL-Server zu fungieren. Im Rahmen der Installation haben Sie außerdem den Server gesichert. Optional haben Sie auch einen separaten administrativen Benutzer mit Passwortauthentifizierung erstellt.

      Nachdem Sie nun über einen laufenden und sicheren MariaDB-Server verfügen, finden Sie hier einige Beispiele für nächste Schritte, die Ihnen das Arbeiten mit dem Server erlauben:



      Source link

      How To Install MariaDB on Ubuntu 20.04 [Quickstart]


      A previous version of this tutorial was written by Brian Boucheron

      Introduction

      MariaDB is an open-source relational database management system, commonly used as an alternative for MySQL as the database portion of the popular LAMP (Linux, Apache, MySQL, PHP/Python/Perl) stack. It is intended to be a drop-in replacement for MySQL.

      This quickstart tutorial describes how to install MariaDB on an Ubuntu 20.04 server and set it up with a safe initial configuration. It will also cover how to set up an additional administrative account for password access.

      Prerequisites

      To follow this tutorial, you will need a server running Ubuntu 20.04. This server should have a non-root administrative user and a firewall configured with UFW. Set this up by following our initial server setup guide for Ubuntu 20.04.

      Step 1 — Installing MariaDB

      Before you install MariaDB, update the package index on your server with apt:

      Then install the package:

      • sudo apt install mariadb-server

      When installed from the default repositories, MariaDB will start running automatically. To test this, check its status.

      • sudo systemctl status mariadb

      You’ll receive output that is similar to the following:

      Output

      ● mariadb.service - MariaDB 10.3.22 database server Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2020-05-12 13:38:18 UTC; 3min 55s ago Docs: man:mysqld(8) https://mariadb.com/kb/en/library/systemd/ Main PID: 25914 (mysqld) Status: "Taking your SQL requests now..." Tasks: 31 (limit: 2345) Memory: 65.6M CGroup: /system.slice/mariadb.service └─25914 /usr/sbin/mysqld . . .

      If MariaDB isn’t running, you can start it with the command sudo systemctl start mariadb.

      Step 2 — Configuring MariaDB

      Run the security script that came installed with MariaDB. This will take you through a series of prompts where you can make some changes to your MariaDB installation’s security options:

      • sudo mysql_secure_installation

      The first prompt will ask you to enter the current database root password. Since you have not set one up yet, press ENTER to indicate “none”.

      Output

      . . . Enter current password for root (enter for none):

      The next prompt asks you whether you’d like to set up a database root password. On Ubuntu, the root account for MariaDB is tied closely to automated system maintenance, so we should not change the configured authentication methods for that account. Type N and then press ENTER.

      Output

      . . . Set root password? [Y/n] N

      From there, you can press Y and then ENTER to accept the defaults for all the subsequent questions. This will remove some anonymous users and the test database, disable remote root logins, and then load these new rules.

      Step 3 — (Optional) Creating an Administrative User that Employs Password Authentication

      On Ubuntu systems running MariaDB 10.3, the root MariaDB user is set to authenticate using the unix_socket plugin by default rather than with a password. Because the server uses the root account for tasks like log rotation and starting and stopping the server, it is best not to change the root account’s authentication details. Instead, the package maintainers recommend creating a separate administrative account for password-based access.

      To this end, open up the MariaDB prompt from your terminal:

      Then create a new user with root privileges and password-based access. Be sure to change the username and password to match your preferences:

      • GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;

      Flush the privileges to ensure that they are saved and available in the current session:

      Following this, exit the MariaDB shell:

      You can test out this new user with the mysqladmin tool, a client that lets you run administrative commands. The following mysqladmin command connects to MariaDB as the admin user and returns the version number after prompting for the user’s password:

      • mysqladmin -u admin -p version

      You will receive output similar to this:

      Output

      mysqladmin Ver 9.1 Distrib 10.3.22-MariaDB, for debian-linux-gnu on x86_64 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Server version 10.3.22-MariaDB-1ubuntu1 Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/run/mysqld/mysqld.sock Uptime: 4 min 49 sec Threads: 7 Questions: 467 Slow queries: 0 Opens: 177 Flush tables: 1 Open tables: 31 Queries per second avg: 1.615

      Conclusion

      In this guide you installed the MariaDB relational database management system, and secured it using the mysql_secure_installation script that it came installed with. You also had the option to create a new administrative user that uses password authentication.

      Now that you have a running and secure MariaDB server, here some examples of next steps that you can take to work with the server:



      Source link

      How To Install MariaDB on Ubuntu 20.04


      A previous version of this tutorial was written by Brian Boucheron

      Introduction

      MariaDB is an open-source relational database management system, commonly used as an alternative for MySQL as the database portion of the popular LAMP (Linux, Apache, MySQL, PHP/Python/Perl) stack. It is intended to be a drop-in replacement for MySQL.

      The short version of this installation guide consists of these three steps:

      • Update your package index using apt
      • Install the mariadb-server package using apt. The package also pulls in related tools to interact with MariaDB
      • Run the included mysql_secure_installation security script to restrict access to the server
      • sudo apt update
      • sudo apt install mariadb-server
      • sudo mysql_secure_installation

      This tutorial will explain how to install MariaDB on an Ubuntu 20.04 server and verify that it is running and has a safe initial configuration.

      Prerequisites

      To follow this tutorial, you will need a server running Ubuntu 20.04. This server should have a non-root administrative user and a firewall configured with UFW. Set this up by following our initial server setup guide for Ubuntu 20.04.

      Step 1 — Installing MariaDB

      As of this writing, Ubuntu 20.04’s default APT repositories include MariaDB version 10.3.

      To install it, update the package index on your server with apt:

      Then install the package:

      • sudo apt install mariadb-server

      These commands will install MariaDB, but will not prompt you to set a password or make any other configuration changes. Because the default configuration leaves your installation of MariaDB insecure, we will use a script that the mariadb-server package provides to restrict access to the server and remove unused accounts.

      Step 2 — Configuring MariaDB

      For new MariaDB installations, the next step is to run the included security script. This script changes some of the less secure default options for things like remote root logins and sample users.

      Run the security script:

      • sudo mysql_secure_installation

      This will take you through a series of prompts where you can make some changes to your MariaDB installation’s security options. The first prompt will ask you to enter the current database root password. Since you have not set one up yet, press ENTER to indicate “none”.

      Output

      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):

      The next prompt asks you whether you’d like to set up a database root password. On Ubuntu, the root account for MariaDB is tied closely to automated system maintenance, so we should not change the configured authentication methods for that account. Doing so would make it possible for a package update to break the database system by removing access to the administrative account. Type N and then press ENTER.

      Output

      . . . 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] N

      Later, we will cover how to set up an additional administrative account for password access if socket authentication is not appropriate for your use case.

      From there, you can press Y and then ENTER to accept the defaults for all the subsequent questions. This will remove some anonymous users and the test database, disable remote root logins, and load these new rules so that MariaDB immediately implements the changes you have made.

      With that, you’ve finished MariaDB’s initial security configuration. The next step is an optional one, though you should follow it if you prefer to authenticate to your MariaDB server with a password.

      Step 3 — (Optional) Adjusting User Authentication and Privileges

      On Ubuntu systems running MariaDB 10.3, the root MariaDB user is set to authenticate using the unix_socket plugin by default rather than with a password. This allows for some greater security and usability in many cases, but it can also complicate things when you need to allow an external program (e.g., phpMyAdmin) administrative rights.

      Because the server uses the root account for tasks like log rotation and starting and stopping the server, it is best not to change the root account’s authentication details. Changing credentials in the /etc/mysql/debian.cnf configuration file may work initially, but package updates could potentially overwrite those changes. Instead of modifying the root account, the package maintainers recommend creating a separate administrative account for password-based access.

      To this end, we will create a new account called admin with the same capabilities as the root account, but configured for password authentication. Open up the MariaDB prompt from your terminal:

      Then create a new user with root privileges and password-based access. Be sure to change the username and password to match your preferences:

      • GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;

      Flush the privileges to ensure that they are saved and available in the current session:

      Following this, exit the MariaDB shell:

      Finally, let’s test the MariaDB installation.

      Step 4 — Testing MariaDB

      When installed from the default repositories, MariaDB will start running automatically. To test this, check its status.

      • sudo systemctl status mariadb

      You’ll receive output that is similar to the following:

      Output

      ● mariadb.service - MariaDB 10.3.22 database server Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2020-05-12 13:38:18 UTC; 3min 55s ago Docs: man:mysqld(8) https://mariadb.com/kb/en/library/systemd/ Main PID: 25914 (mysqld) Status: "Taking your SQL requests now..." Tasks: 31 (limit: 2345) Memory: 65.6M CGroup: /system.slice/mariadb.service └─25914 /usr/sbin/mysqld . . .

      If MariaDB isn’t running, you can start it with the command sudo systemctl start mariadb.

      For an additional check, you can try connecting to the database using the mysqladmin tool, which is a client that lets you run administrative commands. For example, this command says to connect to MariaDB as root using the Unix socket and return the version:

      You will receive output similar to this:

      Output

      mysqladmin Ver 9.1 Distrib 10.3.22-MariaDB, for debian-linux-gnu on x86_64 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Server version 10.3.22-MariaDB-1ubuntu1 Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/run/mysqld/mysqld.sock Uptime: 4 min 49 sec Threads: 7 Questions: 467 Slow queries: 0 Opens: 177 Flush tables: 1 Open tables: 31 Queries per second avg: 1.615

      If you configured a separate administrative user with password authentication, you could perform the same operation by typing:

      • mysqladmin -u admin -p version

      This means that MariaDB is up and running and that your user is able to authenticate successfully.

      Conclusion

      In this guide you installed the MariaDB relational database management system, and secured it using the mysql_secure_installation script that it came installed with. You also had the option to create a new administrative user that uses password authentication before testing the MariaDB server’s functionality.

      Now that you have a running and secure MariaDB server, here some examples of next steps that you can take to work with the server:



      Source link