Installer MariaDB-database i RHEL/CentOS/Fedora og Debian/Ubuntu


MariaDB er en binær drop-in-erstatning for MySQL, udviklet af originale forfattere af MySQL Project og fuldt kompatibel med MySQL, der har flere funktioner og bedre ydelsesforbedring. Indtil vi skrev dette indlæg, er MariaDB 10.0-serien udviklingsversionen (Alpha), og MariaDB 5.5 er den nuværende stabile (GA) frigivelse.

Hvorfor skal jeg bruge MariaDB?

Som vi alle ved er MySQL meget brugt og det mest populære RDBMS og førstevalg af udviklere. I 2008 blev MySQL erhvervet af Sun Microsystem, som efterfølgende blev købt af Oracle, og som ikke længere er open source.

MariaDB er sponsoreret af Monty Program AB og MariaDB Foundation og er uafhængigt udviklet af kerneudvikleren af MySQL og andre medlemmer af samfundet og virkelig open source. Manden, der oprettede MySQL-database af Michael “Monty” Widenius, David Axmark og Allan Larsso, grundlæggeren af MySQL og Monty Program AB, står nu bag MariaDB. De vil overvåge udviklingen af MariaDB-stiftelsen.

Hvem bruger MariaDB?

Der er mange distributioner og store websteder har skiftet til MariaDB, nogle af dem er:

  1. Mozilla Corporation
  2. Wikipedia
  3. OpenSuse
  4. Fedora
  5. OLX
  6. Nimbuzz
  7. SlashGear
  8. ArchLinux
  9. Redhat Enterprise Linux (fra RHEL7)
  10. Slackware
  11. Mageia
  12. Slackware
  13. TurboLinux
  14. Chakra-projektet
  15. Gentoo
  16. GNU/Linux KDu

Installation af MariaDB-database i RHEL/CentOS 6/5 og Fedora 18/17

Vi anbefales stærkt at bruge brugerdefineret MariaDB YUM (Package Manager) lager til installation. Opret en repo-fil under /etc/yum.repos.d/MariaDB.repo, Kopier og indsæt følgende poster under den.

I øjeblikket er MariaDB-arkiver tilgængelige for RHEL 6, RHEL5, CentOS 6, CentOS 5 og Fedora 20,19,18,17. Vælg og tilføj det korrekte lager til din OS-version.

# MariaDB 5.5 RedHat repository list - created 2013-08-11 14:29 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/rhel6-x86
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
# MariaDB 5.5 RedHat repository list - created 2013-08-11 14:30 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/rhel6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
# MariaDB 5.5 RedHat repository list - created 2013-08-11 14:31 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/rhel5-x86
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
# MariaDB 5.5 RedHat repository list - created 2013-08-11 14:31 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/rhel5-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
# MariaDB 5.5 CentOS repository list - created 2013-08-11 14:21 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-x86
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
# MariaDB 5.5 CentOS repository list - created 2013-08-11 14:22 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
# MariaDB 5.5 CentOS repository list - created 2013-08-11 14:23 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos5-x86
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
# MariaDB 5.5 CentOS repository list - created 2013-08-11 14:23 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos5-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
# MariaDB 5.5 Fedora repository list - created 2014-03-19 06:34 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/fedora20-x86
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
# MariaDB 5.5 Fedora repository list - created 2014-03-19 06:35 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/fedora20-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
# MariaDB 5.5 Fedora repository list - created 2014-03-19 06:31 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/fedora19-x86
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
# MariaDB 5.5 Fedora repository list - created 2014-03-19 06:34 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/fedora19-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
# MariaDB 5.5 Fedora repository list - created 2013-08-11 14:32 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/fedora18-x86
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
# MariaDB 5.5 Fedora repository list - created 2013-08-11 14:33 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/fedora18-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
# MariaDB 5.5 Fedora repository list - created 2013-08-11 14:33 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/fedora17-x86
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
# MariaDB 5.5 Fedora repository list - created 2013-08-11 14:33 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/fedora17-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Når du har placeret MariaDB.repo-filen under /etc/yum.repos.d/. Lad os installere med følgende YUM-kommando.

# On RHEL/CentOS 6/5 and Fedora 19,18,17 #
 yum -y install MariaDB MariaDB-server

# On Fedora 20 #
 yum -y install mariadb mariadb-server

Hvis MariaDB GPG-signaturnøgle ikke er installeret, installerer YUM den automatisk efter download af alle pakkerne.

Når installationen er afsluttet, skal du starte MariaDB med følgende kommando.

# On RHEL/CentOS 6/5 and Fedora 19,18,17 #
 /etc/init.d/mysql start

# On Fedora 20 #
 systemctl start mariadb.service 
 systemctl enable mariadb.service

Skriv kommandoen ‘mysql’ i terminalen. Adgangskoden til root er som standard tom.

 mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 1
Server version: 5.5.32-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

Kør følgende kommando for at se standarddatabaser, der følger med installationen.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

Skriv luk fra kommandoprompten for at afslutte shell.

MariaDB [(none)]> quit
Bye

Efter installation, skal du læse og under hvert trin omhyggeligt, som vil indstille rodadgangskode , fjerne anonyme brugere , afvise fjern rodindlogning og fjern testdatabasen og få adgang for at sikre 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!

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!

Når scriptet efter installation er afsluttet, skal du genstarte MariaDB-databasen for at foretage nye ændringer.

# On RHEL/CentOS 6/5 and Fedora 19,18,17 #
 /etc/init.d/mysql restart

# On Fedora 20 #
 systemctl restart mariadb.service 

Indstil MariaDB til at starte ved opstart

 chkconfig mysql on

Lad os prøve at oprette forbindelse til nyindstillet root-legitimationsoplysninger, og vi skal se noget lignende.

 mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 1
Server version: 5.5.32-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

Installation af MariaDB-database i Debian 7/6 og Ubuntu 13.04/12/10/12.04

Vi anbefales stærkt at bruge brugerdefineret lager til installation. Kør følgende kommandoer for at tilføje MariaDB til dit system. Bemærk, at underskriftsnøglen forbliver den samme i Debian og Ubuntu, mens du importerer den samme.

[email :~$ sudo apt-get install python-software-properties
[email :~$ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db

Kopier og indsæt følgende poster i en fil /etc/apt/sources.list nederst.

# MariaDB 5.5 repository list - created 2013-08-11 15:03 UTC
# http://mariadb.org/mariadb/repositories/
deb http://mirrors.scie.in/mariadb/repo/5.5/debian wheezy main
deb-src http://mirrors.scie.in/mariadb/repo/5.5/debian wheezy main
# MariaDB 5.5 repository list - created 2013-08-11 15:17 UTC
# http://mariadb.org/mariadb/repositories/
deb http://mirrors.scie.in/mariadb/repo/5.5/debian squeeze main
deb-src http://mirrors.scie.in/mariadb/repo/5.5/debian squeeze main
# MariaDB 5.5 repository list - created 2014-03-19 06:47 UTC
# http://mariadb.org/mariadb/repositories/
deb http://mirrors.scie.in/mariadb/repo/5.5/ubuntu saucy main
deb-src http://mirrors.scie.in/mariadb/repo/5.5/ubuntu saucy main
# MariaDB 5.5 repository list - created 2013-08-11 15:18 UTC
# http://mariadb.org/mariadb/repositories/
deb http://mirrors.scie.in/mariadb/repo/5.5/ubuntu raring main
deb-src http://mirrors.scie.in/mariadb/repo/5.5/ubuntu raring main
# MariaDB 5.5 repository list - created 2013-08-11 15:24 UTC
# http://mariadb.org/mariadb/repositories/
deb http://mirrors.scie.in/mariadb/repo/5.5/ubuntu quantal main
deb-src http://mirrors.scie.in/mariadb/repo/5.5/ubuntu quantal main
# MariaDB 5.5 repository list - created 2013-08-11 15:24 UTC
# http://mariadb.org/mariadb/repositories/
deb http://mirrors.scie.in/mariadb/repo/5.5/ubuntu precise main
deb-src http://mirrors.scie.in/mariadb/repo/5.5/ubuntu precise main

Når du har korrekt importeret nøgle og tilføjet lager korrekt, kan du installere MariaDB med apt-get-kommandoen som vist. Under installationen kan du bede om at konfigurere root-adgangskoden til databasen.

[email :~$ sudo apt-get update
[email :~$ sudo apt-get install mariadb-server

Login MariaDB med root-legitimationsoplysninger, som blev indstillet tidligere.

[email :~$ sudo mysql -u root -p
[sudo] password for narad: 
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 42
Server version: 10.0.3-MariaDB-1~raring-log mariadb.org binary distribution

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

Bemærk: Skriv afslut fra kommandoprompten for at afslutte databasen.

Reference Links

  1. MariaDB Vs MySQL - Funktioner
  2. MariaDB-dokumentation
  3. MariaDB-startside