MySQL Tips

Renaming column
alter table TblName change oldColName NewColName int not null;

Removing primary key attribute(column will not be removed):
alter table TblName drop primary key;

Adding new column
alter table TblName add column id int auto_increment primary key;

Restoring backup
mysql   -u username    -ppassword    -h     dbname <  backup.sql

Taking backup
mysqldump   -u username    -ppassword    -h     dbname > backup.sql

Creating New User
create   user   username@   identified  by   ‘passwd;

Assign User Permissions to a database
grant   all   on   dbname.*     to   username@;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: