Tutorial for MySQL An Introduction to Java Programming
Using MySQL
By default, the server contains two databases named mysql and test. You can see these two databases displayed in Figure 1.3 using the command show databases. The show databases command displays all available databases in the MySQL database server.
<side remark: create database>
The mysql database contains the tables that store the information about the server and its users. This database is intended for the server administrator to use. For example, the administrator can use it to create users and grant or revoke user privileges. Since you are the owner of the server installed on your system, you have full access to the mysql database. However, you should not create user tables in the mysql database. You can use the test database to store data or create new databases. You can also create a new database using the command create database databasename or drop an existing database using the command drop database databasename.
<side remark: use database>
To select a database for use, type the use databasename command. Since the test database is created by default in every MySQL database, let us use it to demonstrate SQL commands. As shown in Figure 1.4, the test database is selected.
The use test command selects the test database. Enter the following SQL statements from the MySQL command prompt, as shown in Figure 1.5. The create table statement creates a table named State. The insert statement inserts the values into the table. The select statement displays the contents from the table.
Download file here