MySQL

Connect MySQL through Putty

how to connect mySQL server through Putty application.
To log into MySQL:
mysql -u root -pPassword

To show all databases:
show databases;

To use a database :
use database_name;

To drop a database:
drop database databaseName;

How to backup a MySql Database:
mysql -u root -pPassword databaseName > /root/name.sql
or
mysqldump -u username -pPassword databasename > /root/name.sql

Compress the .sql file with gzip:
gzip filename.sql

How to restore a MySql Database:
mysql -u root -pPassword databaseName < /root/name.sql

Add new varchar column to the end of the table :
ALTER TABLE `tablename_here` ADD `new_column_name` VARCHAR( 255 ) NOT NULL ;

Add new integer column after an existing column in table :
ALTER TABLE `tablename_here` ADD `new_column_name` INT NOT NULL AFTER `existing_column` ;

Delete a column from an existing MySQL table :
ALTER TABLE ’table_things’ DROP ’col_stuff’

Hope Useful
Yupi Sugianto, S.Kom



Related posts

Leave a Comment