Posts

Showing posts from July, 2009

MySQL Commands - Adding User, Backup and Restore

Adding new user to access the database

Syntax:
mysqldump -u [username] -p [password] [databasename] > [backupfile.sql]

Examples:
mysql> GRANT all ON mydatabase.* TO myuser@'192.168.17.186' IDENTIFIED BY 'mypassword';
mysql> GRANT all ON mydatabase.* TO myuser@'localhost' IDENTIFIED BY 'mypassword';
mysql> FLUSH PRIVILEGES;


Making Backup of the Database

Syntax:
mysqldump -u[mysqluser] -p[password] [databasename] > [destinationfile.sql]

Example:
$ mysqldump -utestaccount -pg3pass employeefile > employeefile-dump.sql

Restoring MySQL Database

$ mysql -uaccount -ppassword employeefile < employeefile-dump.sql

Making Backup of the existing Table

Syntax:
create table <Table Destination> as select * from <Table Source>;

Example:
create table RADUSAGE_09082009 as select * from RADUSAGE;

Killing a Process in Linux

At times we encounter java process that won't stop by issuing the usual command "./shutdown.sh", or in some cases a multiple instance was created when the program was not properly restarted.

Below are the sample process status of the java in my linux box.

[root@geone bin]# ps -eaf | grep java
root 27272 1 0 Jul06 ? 00:00:22 /usr/java/j2sdk1.4.1_01/bin/java
root 27684 27273 0 Jul06 ? 00:03:01 /usr/java/j2sdk1.4.1_01/bin/java
root 27685 27273 0 Jul06 ? 00:04:23 /usr/java/j2sdk1.4.1_01/bin/java
root 27686 27273 0 Jul06 ? 00:03:01 /usr/java/j2sdk1.4.1_01/bin/java
root 27687 27273 0 Jul06 ? 00:03:01 /usr/java/j2sdk1.4.1_01/bin/java
root 27688 27273 0 Jul06 ? 00:03:04 /usr/java/j2sdk1.4.1_01/bin/java
root 27689 27273 0 Jul06 ? 00:03:04 /usr/java/j2sdk1.4.1_01/bin/java
root 27690 27273 0 Jul06 ? 00:03:04 /usr/java/j2sdk1.4.1_01/bin/java
root 27691 27273 0 Jul06 ? 00:03:01 /usr/java/j2sdk1.4.1_01/bin/java
root 27692 27273 0 Jul06 ? 00:03:01 /usr/java/j2sdk1.4.1_01/bin/java
root 27693 27273 0…