MySQL Super-Short Course/ Cheat Sheet

June 14, 2006

To start mysql Server 

#mysqld_safe  &

or

#mysqld &

(To start server with logging option 

#mysqld –l  &

log files are written in data directory as hostname.err  and hostname.log)

To Change root user password 

#mysqladmin -u root password ‘newpass’

#mysqladmin –u root –h “hostname” password ‘newpass’

 ( usually mysql has 2 entries : one for localhost and one for the hostname and 2 anonymous users for those both initially )  

To connect to mysql server 

#mysql –u root –p

Show All database in System

mysql> SHOW DATABASES;

Use particular database

Mysql> use  testdb

Or you can run quries with prefix  :  like   SELECT * FROM testdb.mytable;

DELETE INITIAL ACCOUNTS & SET ROOT PASSWORD 

Mysql> DELETE FROM mysql.user WHERE User = ‘’;

Mysql> FLUSH PRIVILEGES;

Use mysqladmin  to set password as explained above

Create NEW Database 

Mysql> CREATE DATABASE   mydb;

Create New USERS 

Mysql> GRANTE ALL ON mydb.*  TO ‘testuser1’@’localhost’ IDENTIFIED BY ‘testpass1’;

Mysql>FLUSH PRIVELEGES;

 

Shutdown Server 

#mysqladmin shutdown

Advertisements

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: