MySQL dump / restore (quick notes)

Some quick notes on dump / restore of a MySQL database.

REM DUMP A DATABASE TO FILE NOTE: the -- database option will include the CREATE DATABASE IF NOT EXISTS AND USE DATABASE COMMANDS

mysqldump --host localhost -P 3306 -u root -p --databases INFO_DB > /u99/backup/INFO_DB_new.dmp

REM DUMP A DATABASE TO FILE NOTE: the this version will NOT include the CREATE DATABASE IF NOT EXISTS AND USE DATABASE COMMANDS

mysqldump --host localhost -P 3306 -u root -p INFO_DB > /u99/backup/INFO_DB_new.dmp

REM DUMP A DATABASE TO FILE (zipped)

mysqldump --host localhost -P 3306 -u root -p --databases INFO_DB | gzip > /u99/backup/INFO_DB_new.dmp.gz

REM RESTORE A FILE

mysql --host localhost -P 3306 -u root -p < /u99/backup/INFO_DB_new.dmp

REM RESTORE A DATABASE INTO AN EXISTING DATABASE "my_dbase"

mysql --host localhost -P 3306 -u root -p my_dbase< /u99/backup/INFO_DB_new.dmp

REM RESTORE A COMPRESSED DATABASE INTO AN EXISTING DATABASE "my_dbase"

gunzip < myfile.sql.gz | mysql -u root -p my_dbase

Chuckle Bros

I just want to say how sad it was to read about Barry Chuckle passing away. Great entertainer and a big miss. Him and his brother Paul have entertained for many years using good old fashioned humor and will be a big miss. If you have not watched the Chuckle Bros, loads on YouTube and I can thoroughly recommend giving them a go. Anyway, I was thinking that a Chuckle Bros Unix fortune command would be great so if anyone knows any sites with Chuckle Bros quotes please let me know.

Chuckle Bros.   "Nice church Vicar"
Vicar                 "It's Norman"
Chuckle Bros.   "Nice church Norman"

to you, to.........

Color / Colour to Unix output


If you want to add some color to your Unix output, use echo ^[[35m then the text you want e.g. Hello

Where ^[ is "ctrl-v escape" then [

The numeric value will depend on your TERM type (combination of text / background).

echo ^[[0m to reset text (see table below).

The available codes are:

  
0
Normal text, foreground and background
1
Bold text
4
Underline
5
Blink
7
Inverse
30
Black foreground
31
Red foreground
32
Green foreground
33
Yellow foreground
34
Blue foreground
35
Magenta foreground
36
Cyan foreground
37
White foreground
40
Black background
41
Red background
42
Green background
43
Yellow background
44
Blue background
45
Magenta background
46
Cyan backgroud
47
White background

You can combine codes in a single escape sequence by separating them with semicolons.

For example, to create a section of text that is bold text with a yellow foreground and blue background, the escape sequence would be:

^[[1;33;44m