Error Establishing A Database Connection
Hello there,
My first problem was http://prntscr.com/ovv4fv only for WordPress Website. html website is running smoothly. Mysql was stop. Tried to run but can not.
Run df -h command and got that http://prntscr.com/ovv4or
Then i deleted these 3 files http://prntscr.com/ovv4tm and restared mysql. Now mysql is running but problem is that http://prntscr.com/ovv50g
All WordPress website want to get re-install. which is not desireable.
The problem appeared from many days ago. Previously I just did restart and deleted some files then it would be ok. But recently i have upgraded my packages BUT did not get ride from this issues.
Please someone help me. I am loosing my business.
Thanks in Advance.
1 Reply
In regards to the initial issue, it looks like your database stopped because you ran out of disk space. To prevent this from happening again, you may consider resizing your Linode to a larger plan, or take advantage of Block Storage. Alternatively, I’ve included some useful commands for locating files you might want to clear out.
# find directories with the most files
dir=/ ; for i in $(ls -1 ${dir} | sort -n) ; { echo "$(find ${dir}${i} -type f | wc -l) => $i,"; } | sort -nr | head -10
# find most populated directories based on file count
sudo find / -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n | tail -50
# sort directories by file size
sudo du -ahx / | sort -rh | head -n 20
# locate largest files by inodes
sudo du --inodes -S 2>/dev/null | sort -rh | head -10
In regards to the second issue, ibdata1
is a really important file, as it's the underlying structure for InnoDB databases. Since it was deleted, your Wordpress installation is not able to find/read the wp_*
tables. Therefore your best option is to restore the database from a backup, whether it be from a mysqldump, physical or system level backup.
There may be users here with other ideas, but without a backup to restore, it seems your only option would be to make a copy of everything in wp-content
and then start over. Attempting to reinstall Wordpress “as-is” will generate new ibdata1
, ib_logfile0
, and ib_logfile1
files, but you might run into errors on step 2 of the process, where it tries to create the wp_*
tables and finds they already exist from before. In this case, you could use something like the WP-CLI tool to drop all the associated tables and then redo the install.
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
sudo rm -rf /var/lib/mysql/wordpressdb
sudo -u www-data -- wp db reset --path=/var/www/wordpress
I hope this was helpful. Again there may be other users here with better solutions.