How to install mariadb
How to install mariadb
How To Install MariaDB on Ubuntu 20.04
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:
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
To install it, update the package index on your server with apt :
Then install the package:
Ensure that MariaDB is running with the systemctl start command:
These commands will install and start 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:
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”.
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) 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. 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:
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.
You’ll receive output that is similar to the following:
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:
If you configured a separate administrative user with password authentication, you could perform the same operation by typing:
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:
Want to learn more? Join the DigitalOcean Community!
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in our Questions & Answers section, find tutorials and tools that will help you grow as a developer and scale your project or business, and subscribe to topics of interest.
How To Install MariaDB on Debian 10
Introduction
MariaDB is an open-source database management system (DBMS), commonly used as an alternative for the MySQL portion of the popular LAMP (Linux, Apache, MySQL, PHP/Python/Perl) stack. It’s intended to be a drop-in replacement for MySQL and Debian now only ships with MariaDB packages. If you attempt to install MySQL server-related packages, you’ll receive the compatible MariaDB replacement versions instead.
The short version of this installation guide consists of the following three steps:
This tutorial will explain how to install MariaDB version 10.3 on a Debian 10 server, and verify that it is running and has a safe initial configuration.
Prerequisites
To complete this tutorial, you will need one Debian 10 server set up with a non-root user with sudo privileges and a firewall. You can set this up by following our initial server setup guide.
Step 1 — Installing MariaDB
On Debian 10, MariaDB version 10.3 is included in the APT package repositories by default. It is marked as the default MySQL variant by the Debian MySQL/MariaDB packaging team.
To install it, update the package index on your server with apt :
Then install the package:
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, you’ll 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. We will use it to block remote root logins and to remove unused database users.
Run the following security script:
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 haven’t set one up yet, press ENTER to indicate “none”.
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 respects the changes you have made.
Step 3 — (Optional) Adjusting User Authentication and Privileges
In Debian 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 demonstrate this process, we will create a new account called admin with the same capabilities as the root account, but configured for password authentication. To do this, open up the MariaDB prompt from your terminal:
Now, create a new user with root privileges and password-based access. Change the username and password to match your preferences:
Flush the privileges to ensure that they are saved and available in the current session:
Following this, exit the MariaDB shell:
Next, let’s test the MariaDB installation.
Step 4 — Testing MariaDB
When installed from the default repositories, MariaDB should start running automatically. To test this, check its status:
You’ll receive output that is similar to the following:
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 and return the version using the Unix socket:
Your output should be similar to the following:
If you configured a separate administrative user with password authentication, you can perform the same operation by running the following command:
This output means that MariaDB is up and running and that your user is able to authenticate successfully.
Conclusion
In this guide, you installed MariaDB to act as a SQL server. During the installation process, you also secured the server. Optionally, you also created a separate user to ensure administrative access to MariaDB across package updates.
Now that you have a running and secure MariaDB server, here are some examples of the next steps that you can take to work with the server:
You can also incorporate MariaDB into a larger application stack:
Want to learn more? Join the DigitalOcean Community!
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in our Questions & Answers section, find tutorials and tools that will help you grow as a developer and scale your project or business, and subscribe to topics of interest.
How To Install MariaDB on Ubuntu 18.04
Introduction
MariaDB is an open-source database management system, commonly used as an alternative for the MySQL 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:
This tutorial will explain how to install MariaDB on an Ubuntu 18.04 server, and verify that it is running and has a safe initial configuration.
Prerequisites
To follow this tutorial, you will need:
Step 1 — Installing MariaDB
On Ubuntu 18.04, MariaDB version 10.1 is included in the APT package repositories by default.
To install it, update the package index on your server with apt :
Then install the package:
Ensure that MariaDB is running with the systemctl start command:
These commands will install and start 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. We will use it to block remote root logins and to remove unused database users.
Run the security script:
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 we have not set one up yet, press ENTER to indicate “none”.
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.
Step 3 — (Optional) Adjusting User Authentication and Privileges
On Ubuntu systems running MariaDB 10.1, 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 do so, we will create a new account called admin with the same capabilities as the root account, but configured for password authentication. To do this, open up the MariaDB prompt from your terminal:
Now, we will create a new user with root privileges and password-based access. Change the username and password to match your preferences:
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 should start running automatically. To test this, check its status.
You’ll receive output that is similar to the following:
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 and return the version using the Unix socket:
You should receive output similar to this:
If you configured a separate administrative user with password authentication, you could perform the same operation by typing:
This means that MariaDB is up and running and that your user is able to authenticate successfully.
Conclusion
In this guide you installed MariaDB to act as an SQL server. During the installation process you also secured the server. Optionally, you also created a separate password-authenticated administrative user.
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:
You can also incorporate MariaDB into a larger application stack:
Want to learn more? Join the DigitalOcean Community!
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in our Questions & Answers section, find tutorials and tools that will help you grow as a developer and scale your project or business, and subscribe to topics of interest.
How To Install MariaDB on Ubuntu 22.04
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:
This tutorial will explain how to install MariaDB on an Ubuntu 22.04 server and verify that it is running and has a safe initial configuration.
Prerequisites
Step 1 — Installing MariaDB
As of this writing, Ubuntu 22.04’s default APT repositories include MariaDB version 10.5.12.
To install it, update the package index on your server with apt :
Then install the package:
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, you 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:
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”.
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 you should not change the configured authentication methods for that account.
Later, you’ll go over 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) Creating an Administrative User that Employs Password Authentication
On Ubuntu systems running MariaDB 10.5, 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:
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.
You’ll receive output that is similar to the following:
For an additional check, you can try connecting to the database using the mysqladmin tool, which is a client that allows you to 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:
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:
Want to learn more? Join the DigitalOcean Community!
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in our Questions & Answers section, find tutorials and tools that will help you grow as a developer and scale your project or business, and subscribe to topics of interest.
Installing MariaDB Binary Tarballs
Contents
MariaDB Binary tarballs are named following the pattern: mariadb-VERSION-OS.tar.gz. Be sure to download the correct version for your machine.
Others are marked ‘systemd’, which are for systems with systemd and GLIBC 2.19 or higher.
To install the binaries, unpack the distribution into the directory of your choice and run the mysql_install_db script.
In the example below we install MariaDB in the /usr/local/mysql directory (this is the default location for MariaDB for many platforms). However any other directory should work too.
We install the binary with a symlink to the original name. This is done so that you can easily change MariaDB versions just by moving the symlink to point to another directory.
Ensure You Use the Correct my.cnf Files
MariaDB searches for the configuration files ‘ /etc/my.cnf ‘ (on some systems ‘ /etc/mysql/my.cnf ‘) and ‘
The normal solution for this is to ignore the my.cnf file in /etc when you use the programs in the tar file.
/.my.cnf ‘. Note that this has to be first option for the above commands!
Installing MariaDB as root in /usr/local/mysql
If you have root access to the system, you probably want to install MariaDB under the user and group ‘mysql’ (to keep compatibility with MySQL installations):
To start mysqld you should now do:
Installing MariaDB as Not root in Any Directory
Below, change /usr/local to the directory of your choice.
If you have problems with the above gunzip command line, you can instead, if you have gnu tar, do:
To start mysqld you should now do:
Auto Start of mysqld
You can get mysqld (the MariaDB server) to autostart by copying the file mysql.server file to the right place.
The exact place depends on your system. The mysql.server file contains instructions of how to use and fine tune it.
For systemd installation the mariadb.service file will need to be copied from the support-files/systemd folder to the /usr/lib/systemd/system/ folder.
Note that by default the /usr/ directory is write protected by systemd though, so when having the data directory in /usr/local/mysql/data as per the instructions above you also need to make that directory writable. You can do so by adding an extra service include file:
After this you can start and stop the service using
Please refer to the systemd page for further information.
Post Installation
After this, remember to set proper passwords for all accounts accessible from untrusted sources, to avoid exposing the host to security risks!
Also consider using the mysql.server to start MariaDB automatically when your system boots.
On systems using systemd you can instead enable automatic startup during system boot with
Our MariaDB binaries are similar to the Generic binaries available for the MySQL binary distribution. So for more options on using these binaries, the MySQL 5.5 manual entry on installing generic binaries can be consulted.
For details on the exact steps used to build the binaries, see the compiling MariaDB section of the KB.
Источники информации:
- http://www.digitalocean.com/community/tutorials/how-to-install-mariadb-on-debian-10
- http://www.digitalocean.com/community/tutorials/how-to-install-mariadb-on-ubuntu-18-04
- http://www.digitalocean.com/community/tutorials/how-to-install-mariadb-on-ubuntu-22-04
- http://mariadb.com/kb/en/installing-mariadb-binary-tarballs/