Skip to content

Installing MariaDB on Windows with WSL

Installing MariaDB on Windows with WSL is super easy. First, launch your WSL Ubuntu server. Then install MariaDB with:

Text Only
sudo apt-get update
sudo apt-get install mariadb-server

Then to start the MariaDB server, just run:

Text Only
sudo /sbin/service mysql start

Launch on Startup

However, in order to launch the mysql server on startup without having to write the sudo service mysql start every time, we need to do couple things.

First, run this command:

Text Only
sudo visudo

And when the file opens, scroll to bottom of the file and add this into the file in it's own line:

Text Only
ALL ALL=NOPASSWD:/sbin/service mysql start

And finally, press ctrl + x to save the file and exit.

What this did is that whenever we now launch mysql server using the command sudo /sbin/service mysql start, we no longer need to type in the password every time.

Now, to start the mysql server whenever you login, use this command:

Text Only
echo "sudo /sbin/service mysql start" >> ~/.bashrc

Which adds the mysql startup command in your .bashrc file.

Testing the Installation

To test the installation, just run:

Text Only
sudo mysql

Which should start the MySQL CLI (Command-Line Interface).

Exiting from the MySQL Command Line Interface

To exit from the MySQL Command Line Interface (CLI), just write:

MySQL
exit

Or press:

Text Only
ctrl + c

Installing mycli

There is also a great command line interface available for MariaDB called mycli that I recommend using during this course. This command line interface includes auto-completion and syntax highlighting.

To install mycli, just run:

Text Only
sudo apt update
sudo apt install mycli

And after the installation, just run this to launch into mycli:

Text Only
sudo mycli

And to exit from mycli run this:

MySQL
exit