Skip to content

Instantly share code, notes, and snippets.

@erycamel
Forked from zhensongren/install_mysql_in_wsl.md
Created January 20, 2024 14:35
Show Gist options
  • Save erycamel/1bef8156aa783c3027f0799ab7c962a9 to your computer and use it in GitHub Desktop.
Save erycamel/1bef8156aa783c3027f0799ab7c962a9 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