Add database and tables MySQL

  • Connect to MySQL

user@user:mysql -u root -p

-p (prompts for password)

  • Create database

mysql> create database customers;


  • Grant permissions of database to the correct user (other than root)

mysql>GRANT ALL PRIVILEGES ON customers.* TO user@localhost IDENTIFIED BY ‘passwordGoesHere’;

At this point exit mysql and re-enter using mysql -u user -p (just reconnecting as different user)

  • Create table in database

mysql>Use customers (selects what database to use)

mysql>CREATE TABLE customer ( id varchar(50) NOT NULL, username varchar(30) NOT NULL, primary key(id));

mysql>SHOW TABLES; (lists your tables)

mysql>DESCRIBE customer; (lists a single tables attributes)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s