Tuesday, October 16, 2012

Linux Mysql Configuration and Backup Tutorial



Mysql Configuration :

Mysql is one of the enterprise database provided by Oracle.

First Check the Mysql server and client packages are installed.

Check with rpm -qa | grep mysql




Check the mysql daemon is running or not.

service mysqld status 

if not

service mysqld start




Connect to the mysql use the following command.

mysql -u root -p 

you will connect to mysql database.

mysql>

mysql > show databases;  (This command list the available databases)




Create a new database called senthil.

mysql> create database senthil;



mysql> use senthil; ( Use named database)

mysql> show tables; (List the tables in the database)




Create a new table.
mysql> create table login (uanme varchar(20), upass varchar(20));




To insert a values into that table,

mysql> insert into login values ("sdfdf", "sadsf");




To list the records in that table, 

mysql> select * from login;




Mysql databse backup:

In linux OS prompt execute the following command.

# mysqldump -u root -p senthil > /root/bacup.sql





Once the backup is done, login to mysql.

mysql> drop database senthil;  ( This removes the database) *** This you can test only the dummy database.




Restoring the database:

In Linux Os prompt use the following command.

# mysql -u root -p senthil < /root/backup.sql





Now you check with show databases;



All the records are restored.




Mysql stores in /var/lib/mysql location ( All databases files)




No comments:

Post a Comment