mysql  change alter column 

most used mysql commands

Creating a table:


CREATE TABLE favourites  
(
fid   INT NOT NULL auto_increment PRIMARY KEY,
ipaddr  VARCHAR(20) NOT NULL,
addedon DATETIME,     
uid     INT(10) NOT NULL,     
nid     INT(10) NOT NULL,     
title   VARCHAR(25),      FOREIGN KEY(uid) REFERENCES users(uid),     
FOREIGN KEY(nid) REFERENCES notes(nid)
);

Change column name

ALTER TABLE users   CHANGE username email VARCHAR(30); 

Here, we changing column name username to email with varchar.

Change default value for a Column name

update users set active =0 where uid = 25;


To access mysql server remotely
mysql> GRANT ALL ON foo.* TO bar@'202.54.10.20' IDENTIFIED BY 'PASSWORD';