Raymond
Install MySQL on WSL
insights Stats
warning Please login first to view stats information.
toc Table of contents
Prerequisites
Before installing MySQL on WSL, please ensure you have WSL enabled on your Windows 10 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 MySQL on WSL Debian distro. You can follow similar steps to install it in other Linux distros.
Step by step guide
- Open Debian distro through WSL command:
wsl -d Debian
- Update Debian packages:
sudo apt update
You need to type user password.
- Install MySQL using the following command:
sudo apt install mysql-server
Type Y to continue when asked.
- Wait until the installation is completed.
- Verify MySQL version:
$ mysql --version mysql Ver 15.1 Distrib 10.1.48-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
Test MySQL
- Start MySQL service using the following commands:
$ sudo service mysql start # Or sudo /etc/init.d/mysql start
- Check the status of the service:
$ sudo service mysql status # Or sudo /etc/init.d/mysql status
The output looks like the following:[info] /usr/bin/mysqladmin Ver 9.1 Distrib 10.1.48-MariaDB, for debian-linux-gnu on x86_64 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Server version 10.1.48-MariaDB-0+deb9u1 Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/run/mysqld/mysqld.sock Uptime: 1 min 33 sec Threads: 1 Questions: 63 Slow queries: 0 Opens: 32 Flush tables: 1 Open tables: 26 Queries per second avg: 0.677.
- Start security script prompts:
sudo mysql_secure_installation
- Try MySQL prompt using the following command:
sudo mysql
- Check databases:
show databases;
The output looks like the following screenshot:
- Type exit; to exit the CLI.
- Stop the service using the following command:
$ sudo service mysql stop # Or sudo /etc/init.d/mysql stop
copyright
This page is subject to Site terms.
comment Comments
No comments yet.