mysql dump of data only – no table and database schema

Mates, I want to dump the data from the tables only rather than its definition and data.

The problem with mysqldump is it checks if database/table exist  or not. if the table exist it drops the table create the blank table and then enters the insert into statements. I don’t want to use this.

goggled and found

dump the database with options –no-create-db and –no-create-info

Mysql Database Backup script

Create a file called and also an empty directory called mysql_backup.

The script should have the following info :

date=`date '+%m-%d-%y'`
mysqldump -u database_username -pdatabase_password database_name > $PATH

Run the script that performs the backup job.

Using Cron  :

Set this script up to run every night, etc. as a cron job. It will save an sql dump of your database every night in the mysql_backup.

* 23 * * * your_userid /path/to/backup/script

Backing Up MySQL Database

MySQL database backup can be accomplished in two ways:

a) Copying the raw mysql database files &
b) Exporting tables to text files

Copying the Mysql database Files :

MySQL uses the same table format on different platforms, so it’s possible to copy MySQL table and index files from one platform and use them on another without any difficulties (assuming, of course, that you’re using the same version of MySQL on both platforms).

Exporting tables to text files.

The MySQLDump is handy utility that can be used to quickly backup the MySQL Database to the text files. To use the MySQLDump utility it is required to logon to the System running the MySQL Databse. You can use Telnet to remotely logon to the system if you don’t have the physical access to the machine.
The syntax for the command is as follows.

mysqldump -u [Username] -p [password] [databasename] > [backupfile.sql]

[username] – this is your database username
[password]- this is the password for your database
[databasename] – the name of your database
[backupfile.sql] – the filename for your database backup

Let’s discuss the example of backing up MySQL Database named “accounts” into text file accounts.sql. Here are the scenarios of taking the backup assuming that both user name and password of the database is “admin”.

a) Taking the full backup of all the tables including the data.

Use the following command to accomplish this:
mysqldump -u admin -p admin accounts > accounts.sql

b) Taking the backup of table structures only.

Use the following command to accomplish this:
mysqldump -u admin -p admin –no-data accounts > accounts.sql

c) Taking the backup data only.

Use the following command to accomplish this:
mysqldump -u admin -p admin –no-create-info accounts > accounts.sql

Restoring MySQL Database

Restoring the MySQL is very easy job. You can use the following to command to restore the accounts database from accounts.sql backup file.

mysql – u admin -p admin accounts < accounts.sql

In this tutorial you learned how to take the backup of your MySQL Database and restore the same in the event of some database crash or on some other machine.

How to check how much free space we have in Mysql database

fire the query
show table status like ‘org’;

The last column Comments gives the size of the database.

If you need to have a shell script to check InnoDB_free space of Mysql database here is the code

Query="show table status like 'org';"
#freespace=${echo "$Query" | mysql -t --host=tiber4 mvc | /bin/awk '/InnoDB free:/ {print $38}' }
freespace=$(echo "$Query" | mysql -t --host=$host $db | /bin/awk '/InnoDB free:/ {print $38}' )

echo $host has $freespace kB free

basic postgresql tips

Start and stop postgresql

Service postgres start

Add to the chkconfig
Chkconfig –level 3 postgres on

to create a first user in kubuntu/ubuntu linux, type the following:
~$ sudo su postgres -c createuser *USERNAME*

Then create a db:
~$ sudo su postgres -c createdb *DBNAME*

Then create a password for the user by connecting using psql:
~$ sudo su postgres -c psql *DBNAME*

Then alter the password:
=#ALTER USER *username* WITH PASSWORD ‘*password*‘;