Install MariaDB Server on WSL
Kontextvisibility 6,144 comment 1 event 2022-06-06 access_time 12 months ago language English
MariaDB Server is one of the most popular open source relational databases and was created by the original developers of MySQL and guaranteed to stay open source.
Before installing MariaDB on WSL, please ensure you have WSL enabled on your Windows 10/11 system.
Follow Install Windows Subsystem for Linux on a Non-System Drive to install WSL on a non-C drive.
This tutorial provides steps to install MariaDB on WSL Ubuntu 20.04 distro. You can follow similar steps to install it in other Linux distros.
warning If you have installed MySQL on the same WSL distro, the setup will overwrite the data directory.
Step by step guide
- Open Ubuntu distro through WSL command:
wsl -d "Ubuntu-20.04" # Or the following name if the name has no version in it wsl -d "Ubuntu"
*Remember to change the distro name accordingly.
- Update Ubuntu packages:
sudo apt update
You need to type user password.
- Install MariaDB server using the following command:
sudo apt install mariadb-server
Type Y to continue when asked.
- If you have installed MySQL before in the same WSL, the data will be overwritten:
- Wait until the installation is completed.
- Verify MariaDB version:
$ mariadb --version mariadb Ver 15.1 Distrib 10.3.34-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
- Start MariaDB service using the following commands:
$ sudo /etc/init.d/mysql start * Starting MariaDB database server mysqld [ OK ]
- Check the status of the service:
$ sudo /etc/init.d/mysql statusThe output looks like the following:
* /usr/bin/mysqladmin Ver 9.1 Distrib 10.3.34-MariaDB, for debian-linux-gnu on x86_64 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Server version 10.3.34-MariaDB-0ubuntu0.20.04.1 Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/run/mysqld/mysqld.sock Uptime: 48 sec Threads: 6 Questions: 61 Slow queries: 0 Opens: 33 Flush tables: 1 Open tables: 26 Queries per second avg: 1.270
- Start security script prompts:
The following are the 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): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. You already have a root password set, so you can safely answer 'n'. Change the root password? [Y/n] n ... skipping. 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] n ... skipping. 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] n ... skipping. 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!
- Try MySQL prompt using the following command:
sudo mariadb #or sudo mysql
- Check databases:
The output looks like the following screenshot:
- Type exit; to exit the CLI.
- Stop the service using the following command:
$ sudo /etc/init.d/mysql stop
info Last modified by Kontext 12 months ago copyright This page is subject to Site terms.
Please log in or register to comment.account_circle Log in person_add Register
In step 1. of chapter "Test MariaDB" you will want to start mariadb with the following command:
In step 2. of chapter "Test MariaDB" you will want to check the mariadb status the following command: