• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » Why MySQL Auto Restart Failing in WordPress Cloud Server

By Abhishek Ghosh February 24, 2019 12:08 pm Updated on February 24, 2019

Why MySQL Auto Restart Failing in WordPress Cloud Server

Advertisement

Why MySQL Auto Restart Failing in WordPress Cloud Server Despite Your Efforts of Trying Various Optimization and Scripts to Auto-Restart? We already talked around fixing Error Establishing a Database Connection in WordPress, Autostart MySQL After a Crash, other MySQL fixes for Ubuntu and latest fixes for Ubuntu 18.04. Various updates on the part of different software partially force us to discover new fix.

The discussions in the above links clearly would say – properly configured MySQL should automatically restart. That is theoritically true for the cloud servers running WordPress. Virtual environment, bad coding and attacks make the equation to auto-restart not so easy. These can be causes of failing to restart :

Why MySQL Auto Restart Failing in WordPress Cloud Server

Errors in configuration (in /etc/my.cnf like file)
Corrupt MySQL binary
Wrong permissions/ownership of binaries and folders
Busy MySQL port to bind
Unable to write to /tmp directory
Lack of disk space
Out of memory
Various type of networking attacks on WordPress
Badly coded plugin

Advertisement

---

WordPress is targeted because for being based on PHP and MySQL. The clever solution is to increase your cloud server’s memory. We can open the crontab editor in the terminal with crontab -e command and add the following line to check to auto-restart :

Vim
1
*/5 * * * * service mysql status > /dev/null || service mysql start

This checks if MySQL is running every five-minute interval and redirects stdout to null. But it is commonly seen by many of the users that such scripts decrease the number of failed auto-restart but never makes to zero. With an ongoing massive XML-RPC attack, the server likely to have not much memory to execute auto-restart function. Situation can be worse with a badly coded plugin.

You can use this kind of bash script :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash
PATH=/bin:/usr/bin:/sbin:/usr/local/bin
# cronjob need clear where is the path
# mysql under path /usr/local/bin
mysql --host="localhost" --user="root" --password="password" --database="test" --execute="select id from test limit 1"
if [ $? -eq 0 ]; then echo "";
# mysql run well nothing to do, make a
else
sudo /etc/init.d/mysql stop
pkill /usr/local/bin/mysql
# It should be pkill /usr/local/bin/mysql, not pkill mysql, wrong write will cause below code not working
sudo /etc/init.d/mysql start
sudo /etc/init.d/httpd restart
# Some strange behave, after mysql restart, apache will die, so should add httpd restart
echo "error $(date)" >> /home/myspace/restart_log.txt
fi

You’ll get PATH with this command :

Vim
1
env | grep "^PATH="

Alternate option is to use MySQL Ping function via cron :

Vim
1
* * * * *  root  /usr/bin/mysqladmin --host="localhost" --user="root" --password="password" ping || /usr/sbin/service mysql restart

The above methods or Monit like tools are better to be run from another server to monitor your server running WordPress and automatically take actions like restarting a process or forcing to restart the VPS/cloud server. Within a server with some error it may be difficult to resolve it in automated way.

Tagged With wordpress mysql database optimization , ZFE4 , wordpress vps optimization
Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Why MySQL Auto Restart Failing in WordPress Cloud Server

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • WordPress Multisite on Nginx on Ubuntu 14.04 on HP Cloud

    Here is a Step by Step Guide on Setting Up WordPress Multisite on Nginx on Ubuntu 14.04 on HP Cloud with All Commands and the Configuration.

  • WordPress & PHP : Different AdSense Units on Mobile Devices

    Here is How To Serve Different AdSense Units on Mobile Devices on WordPress With PHP. WordPress Has Function Which Can Be Used In Free Way.

  • How to Install WordPress : Ubuntu 16.04, Nginx, PHP7-FPM

    Here is Step by Step Guide on How to Install WordPress on Ubuntu 16.04, Nginx, PHP7-FPM, memcached & Percona MySQL 5.7 on Cloud Server or VPS.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy