Home >System Tutorial >LINUX >Teach you to install MariaDB 10 on Debian and Ubuntu

Teach you to install MariaDB 10 on Debian and Ubuntu

PHPz
PHPzforward
2024-02-03 08:40:021244browse

MariaDB is a free and open source fork of the popular database management server software MySQL. It was developed under GPLv2 (General Public License version 2) by the original developers of MySQL and remains open source.

It is designed to achieve high compatibility with MySQL. For beginners, you can read MariaDB vs MySQL to learn more about their features. What’s more, it’s used by some big companies/organizations like Wikipedia, WordPress.com, and Google plus, among many more.

In this article, I will show you how to install MariaDB 10.1 stable version in Debian and Ubuntu distributions.

Installing MariaDB on Debian and Ubuntu

1. Before installing MariaDB, you need to import the warehouse key and obtain the MariaDB warehouse through the following command

On Debian 10 (Sid)

$ sudo apt-get install software-properties-common
$ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8
$ sudo add-apt-repository 'deb [arch=amd64,i386] http://www.ftp.saix.net/DB/mariadb/repo/10.1/debian sid main'

On Debian 9 (Stretch)

$ sudo apt-get install software-properties-common
$ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8
$ sudo add-apt-repository 'deb [arch=amd64] http://www.ftp.saix.net/DB/mariadb/repo/10.1/debian stretch main'

On Debian 8 (Jessie)

$ sudo apt-get install software-properties-common
$ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
$ sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://www.ftp.saix.net/DB/mariadb/repo/10.1/debian  jessie main'

On Debian 7 (Wheezy)

$ sudo apt-get install python-software-properties
$ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
$ sudo add-apt-repository 'deb [arch=amd64,i386] http://www.ftp.saix.net/DB/mariadb/repo/10.1/debian wheezy main'

On Ubuntu 16.10 (Yakkety Yak)

$ sudo apt-get install software-properties-common
$ sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
$ sudo add-apt-repository 'deb [arch=amd64,i386] http://www.ftp.saix.net/DB/mariadb/repo/10.1/ubuntu yakkety main'

On Ubuntu 16.04 (Xenial Xerus)

$ sudo apt-get install software-properties-common
$ sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
$ sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://www.ftp.saix.net/DB/mariadb/repo/10.1/ubuntu xenial main'

On Ubuntu 14.04 (Trusty)

$ sudo apt-get install software-properties-common
$ sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
$ sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://www.ftp.saix.net/DB/mariadb/repo/10.1/ubuntu trusty main'

2. Then, update the system installation package list and install MariaDB server as follows:

$ sudo apt-get update
$ sudo apt-get install mariadb-server

During the installation process, you will be asked to configure the MariaDB server; set a secure root user password on the following page:

教你在 Debian 和 Ubuntu 上安装 MariaDB 10

Set a new Root password for MariaDB

Enter the password again and press Enter to continue the installation.

教你在 Debian 和 Ubuntu 上安装 MariaDB 10

Enter MariaDB password again

After the MariaDB installation package is installed, start the database server daemon and enable it so that it can start automatically the next time you boot as follows:

------------- On SystemD Systems -------------
$ sudo systemctl start mariadb
$ sudo systemctl enable mariadb
$ sudo systemctl status mariadb
------------- On SysVinit Systems -------------
$ sudo service mysql  start
$ chkconfig --level 35 mysql on
OR
$ update-rc.d mysql defaults
$ sudo service mysql status

教你在 Debian 和 Ubuntu 上安装 MariaDB 10

Start MariaDB service

4. Then, run the mysql_secure_installation script to protect the database. Here you can:

  1. Set the root password (if you did not set it in the above configuration step).
  2. Prohibit remote root login
  3. Remove test database
  4. Remove anonymous user
  5. Overload permission configuration
$ sudo mysql_secure_installation

教你在 Debian 和 Ubuntu 上安装 MariaDB 10

Securing MariaDB Installation

5. Once the database server is protected, you can use the following shell command to view the installed version and log in to MariaDB:

$ mysql -V
$ mysql -u root -p

教你在 Debian 和 Ubuntu 上安装 MariaDB 10

View MariaDB version


The above is the detailed content of Teach you to install MariaDB 10 on Debian and Ubuntu. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:linuxprobe.com. If there is any infringement, please contact admin@php.cn delete