Install mysql on wsl

How

  1. Install a distro in windows store.

    I got ubuntu18.04LTS here.

  2. Change sources.list

    backup first.

    1
    2
    sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
    sudo vi /etc/apt/sources.list

    run these commands in vi to replace url.

    1
    2
    :%s/archive.ubuntu.com/mirrors.163.com
    :%s/security.ubuntu.com/mirrors.163.com
  3. Install mysql

    meet some problem when install mariadb, so I change to mysql.

    1
    2
    3
    sudo apt install mysql-server
    sudo service mysql start
    sudo mysql_secure_installation
  4. Adjusting User Authentication and Privileges

    1
    2
    3
    4
    5
    sudo mysql
    # after enter mysql, check which authentication method each of your MySQL user accounts use with the following command
    # SELECT user,authentication_string,plugin,host FROM mysql.user;
    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YourPassword';
    FLUSH PRIVILEGES;

Ref

How To Install MySQL on Ubuntu 18.04