I thought of writing this post as a reply for a comment published in the last post I wrote on connectivity of Java and MySQL. From a previous post I showed you how to install and configure MySQL server on your PC. From this post you can learn some of the basic but essential operations you can do using MySQL.
First open the command prompt. These are the very first commands you should give.
For normal login to MySQL server, type mysql and press Enter.
If you have a user name but no password, type the following and press Enter. Here my user name is 'root'.
mysql -u root
If you have a username and also a password, type the following and press Enter. Here my user name is 'root'.
mysql -u root -p
Then it will prompt to enter the password. Type the password and press Enter.
Now you have successfully logged into the MySQL server. In your command prompt, the following will appear.
Now let's see how to view all the databases currently in the server. The command is,
The command to create a new database is the following. Assume my database name is sliit.
create database sliit;
In order to manipulate data inside a database, first we need to go inside the particular database. The command is the following. Assume my database name is sliit.
Now you are inside the database. You can view the tables inside the database using this command.
You can create tables using MySQL statements that you already know. Given below is an example.
CREATE TABLE Students
id INT PRIMARY KEY,
To view data in a table, you can easily type a query like this.
SELECT * FROM Students;
I hope now you are familiar with the basics. If you don't like to work in command line, there is a tool called 'MySQL GUI Tools'. It provides a easy to use graphical user interface to handle MySQL operations.
If you have any questions, feel free to put as comments.