MySQL error: The partition with /var/lib/mysql is too full! Fix

MySQL error: The partition with /var/lib/mysql is too full!

An unusual error.

The fix for it is to restart MySQL

Look for the process

ps -aux | grep mysql
root      5314  0.0  0.1  11748  2220 pts/0    S+   11:18   0:00 grep --color=auto mysql
mysql    30357  0.2  8.5 825260 174464 ?       Ssl  Dec14   6:25 /usr/sbin/mysqld

Kill the process

root@localhost:~# kill 30357

Restart MySQL

root@localhost:~# sudo /etc/init.d/mysql start
 * Starting MySQL database server mysqld                                                                      [ OK ] 

Now your MySQL should be looking good!

 ssh Command Examples

ssh lets you login to remote hosts and transfer files

ssh command Syntax

$ ssh options

Options Description
-V get the version of the SSH Client
-v verbose

ssh command examples

login to remote hosts

ssh root@somewhere.com

login to remote hosts with verbose messages. Causes ssh to print debugging messages about its progress.

ssh -v root@somewhere.com

 MySQL: Backup Database with mysqldump from the Command Line

Backups are an essential part of development. You always want backups. mysqldump is the goto program to backup mysql databases

Backup a database

mysqldump database_name > database_dump.sql

Backup a database with username and password

mysqldump -u username -p password database_name > database_dump.sql

Backup a database with username and password and compressed

Gzip
mysqldump -u username -p password database_name | gzip > database_dump.sql.gz
Bzip
mysqldump -u username -p password database_name | bzip2 > database_dump.sql.bz2

 whenever: command not found

The whenever is a gem that allows you to write cron jobs easily.

every 2.hours do
  command "mysqldump db > db.sql"
end
every :day, :at => '12:20am' do
  command "mysqldump db > db.sql"
end

whenever: command not found

A whenever: command not found error is shown whenever the whenever gem is not installed or cannot be seen

$ whenever
whenever: command not found
$ gem list | grep whenever

The thing since we almost always use bundler, you should use the bundle exec command:

$ bundle show whenever
/home/myapp/vendor/bundle/ruby/2.2.2/gems/whenever-0.9.2

So running whenever commands would be:

$ bundle exec whenever
0 0,12 * * * /bin/bash -l -c 'mysqldump -u username -p password database_name | bzip2 -c > backup_$(date +\%Y-\%m-\%d-\%H.\%M.\%S).sql.bz2'

Write crontab

$ bundle exec whenever -w
[write] crontab file written