Skip to content

Instantly share code, notes, and snippets.

@bandogora
Last active December 8, 2021 21:43
Show Gist options
  • Save bandogora/75ef6027977cd2a248facb39e617df82 to your computer and use it in GitHub Desktop.
Save bandogora/75ef6027977cd2a248facb39e617df82 to your computer and use it in GitHub Desktop.
WSL2: Add to bashrc to check if MySQL server is running and start it if it's not.
#!/bin/sh
# Start mysql if its not running
mysql_daemon='mysqld'
pgrep='/usr/bin/pgrep'
$pgrep $mysql_daemon > /dev/null
if [ $? -ne 0 ]; then
sudo /usr/sbin/service mysql start
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment