MySQL basic commands

NewImage

This is basically a quick set of commands for those who don’t use MySQL often.

commands are in bold

#log in to the server..at the terminal type

mysql -u root; 

#set a new password

UPDATE user SET Password =PASSWORD(‘mypassword’) WHERE User = ‘root’;

#create a database with name ‘MyDatabaseName’

CREATE DATABASE MyDatabaseName;

#add a non-root user account to the server

INSERT INTO user (Host,User,Password) VALUES (‘localhost’,’John’,PASSWORD(‘abc123abc’));

#give new user access to the database you created

GRAND ALL PRIVILEGES ON MyDatabaseName.* TO John;

#update MySQL priviliges

FLUSH PRIVILIGES;

#quit MySQL

exit;

#Log on a new user into the new database .. at the terminal type

mysql -u John -p MyDatabaseName

or you just log in and type

SHOW DATABASES;

USE MyDatabaseName;

#Get a list of all tables in this database

SHOW TABLES;

Advertisements


Categories: Databases, Linux, Mac OSX, Open source, Servers, Windows

Tags: , , , ,

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: