Skip to content

Instantly share code, notes, and snippets.

@elialejandro
Last active July 7, 2020 17:08
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save elialejandro/9a98d7dec1da4a526d63043f7087ba61 to your computer and use it in GitHub Desktop.
Save elialejandro/9a98d7dec1da4a526d63043f7087ba61 to your computer and use it in GitHub Desktop.
MySQL 5.7 No directory, logging in with HOME=/
# Install MySQL
mysql_config_file="/etc/mysql/my.cnf"
echo "mysql-server mysql-server/root_password password secret" | sudo debconf-set-selections
echo "mysql-server mysql-server/root_password_again password secret" | sudo debconf-set-selections
apt-get -y install mysql-client mysql-server
sed -i "s/bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/" ${mysql_config_file}
usermod -d /var/lib/mysql/ mysql
service mysql start
# Allow root access from any host
echo "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'secret' WITH GRANT OPTION" | mysql -u root --password=secret
echo "GRANT PROXY ON ''@'' TO 'root'@'%' WITH GRANT OPTION" | mysql -u root --password=secret
service mysql restart

Stop MYSQL service:

sudo service mysql stop

Change home directory of mysql from nonexistent to original directory where it is supposed to be

sudo usermod -d /var/lib/mysql/ mysql

Start MYSQL service

sudo service mysql start
@cferrante
Copy link

Windows Version 10.0.18363 Build 18363 WSL
Ubuntu 18.04
MySQL Server version: 5.7.29-0ubuntu0.18.04.1 (Ubuntu)

All I had to run was this:

sudo usermod -d /var/lib/mysql/ mysql

Allowed me to start the service - thanks much!

@elialejandro
Copy link
Author

Windows Version 10.0.18363 Build 18363 WSL
Ubuntu 18.04
MySQL Server version: 5.7.29-0ubuntu0.18.04.1 (Ubuntu)

All I had to run was this:

sudo usermod -d /var/lib/mysql/ mysql

Allowed me to start the service - thanks much!

I am happy because my work has have useful for you

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