This Blog is intended to collect information of my various Intrests,pen my opinion on the information gathered and not intended to educate any one of the information posted,but are most welcome to share there view on them
Wednesday, June 15, 2011
Basic MySQL Commands
To login (from unix shell) use -h only if needed.
#mysql -h hostname -u root -p
Create a database on the sql server.
mysql> create database [databasename];
List all databases on the sql server.
mysql> show databases;
Switch to a database.
mysql> use [db name];
To see all the tables in the db.
mysql> show tables;
To see database’s field formats.
mysql> describe [table name];
To delete a database.
mysql> drop database [database name];
To delete a table.
mysql> drop table [table name];
Show all data in a table.
mysql> SELECT * FROM [table name];
Creating a new user.
# mysql -u root -p
mysql> use mysql;
mysql> INSERTINTO user (Host,User,Password)VALUES(‘%’,'username’,PASSWORD(‘password’));