Database management and users¶
In order to manage the tables and their contents, we need users who will be able to do it. In addition, in this section you will also learn how to create such a database on the server.
Database management¶
We want to keep all data in tables in a certain database. In order to create it, we can use the command:
CREATE DATABASE database_name;
where database name is any name that the database should take. Database deletion is possible using the instructions:
DROP DATABASE database_name;
Due to the fact that many databases can exist on the database server, it is possible to choose the database on which we will work. The use
command is used for this, e.g.
use database_name;
Please note that access to the database is only possible if the user has the appropriate access rights.
User accounts management¶
As part of database management systems, it is possible to add new users. This is done using the command:
CREATE USER name [IDENTIFIED BY [PASSWORD]];
As part of the above query, we can create an account without a user password. An example of a query with a given password will look like this:
CREATE USER sda_user IDENTIFIED BY 'sda_password';
The user account can be deleted using the command:
DROP USER user_name;
As part of the topic of managing user accounts, it is also possible to change the account name, which is implemented by:
RENAME USER user_name TO new_user_name;
Any password changes can be made using the SET
statement:
SET PASSWORD FOR user_name=PASSWORD('new_password');