Skip to content

Instantly share code, notes, and snippets.

@pancho508
Last active May 6, 2020 22:32
Show Gist options
  • Select an option

  • Save pancho508/a475a6d8904989e42cca6dfd51c6c319 to your computer and use it in GitHub Desktop.

Select an option

Save pancho508/a475a6d8904989e42cca6dfd51c6c319 to your computer and use it in GitHub Desktop.

Installing mysql server in WSL

On a Windows box MySQL server can be installed as a regular Windows service or inside WSL, the following will guide you through the WSL installation:

Installation

mysql version 8.0.19.

Update and Upagread your WSL

$  sudo apt update && sudo apt upgrade

Once completed restart your bash and install mysql

go super user 
    $ 	sudo su
Install mysql server 
    $ apt-get install mysql-server mysql-client
Check mysql version
    $ mysql -V
Start the service 
    $ service mysql start
Start a session with 
    $ mysql --host=127.0.0.1 --user=root 

Change password

Change your password to be able to connect to your db in future sprints.

Lets start a session as a super user and once inside our mysql client.

Use the mysql db
	>use mysql;
Modify the existing password of root by changing password to your own
	>ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
Finally flush your privilages
	>flush privileges;
	>exit;

Restart the mysql server by

    $  service mysql stop
    $  service mysql start
now lets try to log into mysql with our new password 
    $ mysql --host=127.0.0.1 --user=root -p

Ready "lets do this!"

Cool now we have mysql set up and ready for action:

N|Solid

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