Skip to content

Instantly share code, notes, and snippets.

@synsa
Forked from zhensongren/install_mysql_in_wsl.md
Created May 9, 2021 22:16
Show Gist options
  • Save synsa/c371ecb94034cc29bb7ea84c460b3d06 to your computer and use it in GitHub Desktop.
Save synsa/c371ecb94034cc29bb7ea84c460b3d06 to your computer and use it in GitHub Desktop.
Set up MySQL on local machine (Windows Subsystem for Linux, WSL2)

Upgrade the Repositories

sudo apt update sudo apt upgrade

Install MySQL 5.7

sudo apt install mysql-server

Secure MySQL Installation

sudo apt install mysql-server #To do the high security provide all answers to yes

Start service

sudo service mysql start

Setup new user account and grant privileges

sudo mysql

Check the authentication method/plugin that all your MySQL accounts are currently using

SELECT user,authentication_string,plugin,host FROM mysql.user;

Create a new user within the shell and grant privileges

CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost'; FLUSH PRIVILEGES;

Exit shell and return with passward 'password':

mysql -u username -p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment