Setup MySql on Ubuntu 11.04

Install MySQL
sudo apt-get install mysql-server-5.1
sudo mysql_install_db
sudo mysql_secure_installation
Then download and install JDBC (connector/J) driver.


Starting mysql:
mysql -u username -p 
exit; // exit mysql


Create a new user

mysql -u root -p
CREATE USER newusername;
SET PASSWORD FOR newusername=PASSWORD("password");
GRANT ALL PRIVILEGES ON *.* TO newusername IDENTIFIED BY 'password';
or 
GRANT SELECT, INSERT, UPDATE DELETE, CREATE, DROP, 
     REFERENCES, EXECUTE ALTER on databasename.* TO newusername;


Add a column to a table:
ALTER TABLE tableName ADD newColumn type;
ALTER TABLE tableName ADD newColumn type AFTER whatColumn;
ALTER TABLE tableName ADD newColumn type FIRST;

No comments: