Are you getting this error on your WordPress website?
“error establishing database connection”
Create a file mysql.sh with this code :
#!/bin/bash UP=$(/etc/init.d/mysql status | grep running | grep -v not | wc -l); if [ "$UP" -ne 1 ]; then echo "MySQL is down."; service mysql start else echo "All is well."; fi
$ chmod +x mysql.sh $ crontab -e
One file will open after running the above command. Now, you just add the below line at the end of the file and after that save it.
*/5 * * * * /<path>/mysql.sh
If you are getting this error :
“fi” unexpected (expecting “then”) in shell scripts
then you have to convert the file with dos to unix converter. I have used one online: http://newline.nadav.org/
Useful links :
https://www.digitalocean.com/community/questions/how-can-i-fix-error-establishing-database-connection
https://gist.github.com/mheadd/5571023
https://www.digitalocean.com/community/tutorials/how-to-debug-the-wordpress-error-establishing-database-connection
https://stackoverflow.com/questions/45395720/getting-syntax-error-fi-unexpected-expecting-then-in-shell-scripts
https://github.com/imgurnoor/Launch-Mysql
Leave A Comment