Skip to content

Database support and users

In order to manage the tables and their contents, we need users who can perform such actions. In addition, in this section you will also learn how to create a database on a server.

Database management

We want to keep all the data in tables in some sort of database. In order to create it, we can use the command:

CREATE DATABASE database_name;

where database name is whatever name you want the database to take. Removing the database is possible with the following instructions:

DROP DATABASE database_name_to_be_deleted;

Due to the fact that on a database server there may be many databases, it is possible to choose the database on which we will work. The use command is for this, e.g .:

use database_name;

It should be remembered that entering the database is possible only if the user has the appropriate access rights.

User account management

Within the database management systems, it is possible to add new users. This is done with the command:

CREATE USER name [IDENTIFIED BY [PASSWORD]];

As part of the query above, we can create an account without a user password. An example of a query with a password will look like this:

CREATE USER sda_user IDENTIFIED BY 'sda_password';

However, deleting a user account is possible with the command:

DROP USER username;

As part of the user account management topic, it is also possible to change the account name, which is done by:

RENAME USER username TO new_username;

Any changes to the password can be made using the SET instruction:

SET PASSWORD FOR username=PASSWORD('new_password');