| Free tutorials for Java, Eclipse and Web programming |
After installation of a database management system you need to create the database itself, create users and grant access to the database. Some database management system create defaults but it is good to know how to create them yourself.
The following explains the creation, deletion and usage of database schemas.
Table 6. Manage your databases
| Command | Description |
|---|---|
| show databases; | List all the databases on the SQL server |
| create database my_database; | Creates a new database with the name my_database |
| drop database my_database; | Deletes database my_database |
| use my_database; | Switches to my_database |
| show schemas; | Show all schemas in this database |
| SELECT * FROM INFORMATION_SCHEMA.TABLES where table_schema='myschema'; | Shows all tables for the database schema "myschema". |
The following demonstrate how to create a user and how to grant access rights to a user.
Table 7. User maintenance
| Command | Description |
|---|---|
| CREATE USER my_user IDENTIFIED BY 'my_password'; | Creates a user my_user on the database with the password my_password; |
| grant usage on *.* to my_user@localhost identified by 'my_password'; | Allows the user my_user to connect to the database. |
| grant all privileges on my_database.* to my_user@localhost; | Allows the user my_user from the localhost full access to my_database |