Skip to content

Instantly share code, notes, and snippets.

@zhensongren
Last active March 11, 2024 16:59
Show Gist options
  • Save zhensongren/2b11dbda33d51482894e736246c4bd41 to your computer and use it in GitHub Desktop.
Save zhensongren/2b11dbda33d51482894e736246c4bd41 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