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 127.0.0.1     dbname <  backup.sql

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

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

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

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: