Skip to content

Instantly share code, notes, and snippets.

@e-cloud
Last active April 11, 2023 14:24
Show Gist options
  • Save e-cloud/34acbefe0597a02f9a081a01eff6dd24 to your computer and use it in GitHub Desktop.
Save e-cloud/34acbefe0597a02f9a081a01eff6dd24 to your computer and use it in GitHub Desktop.
Install mysql 8.0 on wsl
wget -c "https://gist.github.com/e-cloud/34acbefe0597a02f9a081a01eff6dd24/raw/3bad7148f60ab70659b0be14ef07b0bd4d019f62/install-mysql8-on-wsl.sh" install-mysql8-on-wsl.sh
chmod 740 install-mysql8-on-wsl.sh
./install-mysql8-on-wsl.sh
#!/usr/bin/env bash
mysql_apt_deb=mysql-apt-config_0.8.14-1_all.deb
sudo apt-get remove mysql-server mysql-client -y
sudo apt-get autoremove -y && sudo apt-get autoclean -y
wget –c "https://dev.mysql.com/get/${mysql_apt_deb}"
sudo dpkg -i $mysql_apt_deb # select 5.7
sudo apt-get update
sudo apt policy mysql-server #(it will show 5.x is the default candidate)
sudo apt-get -y install mysql-server
# ensure your host windows have no mysql service running
sudo service mysql start
sudo service mysql stop
sudo dpkg -i $mysql_apt_deb # select 8.0
sudo apt-get update
sudo apt policy mysql-server #(it will show 8.x is the default candidate)
sudo apt-get -y install mysql-server
sudo sed -ie 's/\/usr\/share\/mysql\/mysql-helpers/\/usr\/share\/mysql-8.0\/mysql-helpers/' /etc/init.d/mysql
sudo service mysql start
@ernestovalent
Copy link

The installation is really good. However in Debian WSL 2 the service did not work.
I read the following blog that helped me figure it out.
https://www.58bits.com/blog/2020/05/03/installing-mysql-80-under-wsl-2-and-ubuntu

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