Case study
You are a database administrator at ABC company, tikno is a new employee. You are asked to give tikno access to the database server with DML level access authority without being allowed to delete data. Write the steps and query commands!
SQL Add User
Completion
1) Log in to MySQL as root
mysql.exe -u root
2) After entering the MySQL console, create a new user with a command like this:
CREATE USER 'tikno'@'localhost' IDENTIFIED BY '1234';
The result
The command above is to create a new user with the name: "tikno" with the password "1234"
3) Set the privileges (determine the access rights) with the format below:
GRANT hak_akses ON nama_database.nama_tabel TO'nama_user'@'lokasi_user';
It's still the same, namely using the Northwind database, and perhaps some of you don't have the database yet, perhaps because you haven't followed the previous material or the database has been deleted, so please just download it HERE .
So we will try to limit tikno's access rights to the northwind database, namely not being able to DELETE. The method is as follows:
GRANT SELECT, INSERT, UPDATE ON northwind.categories TO 'tikno'@'localhost';
The result
Query Delete
Next we will do testing on the user by logging in as tikno, then we try to delete data in the table, and we will see if this access restriction is successful? Ok let's follow me,
4) Login as tikno
Query **Login
5) Using the northwind database and accessing the categories table
**Database Access Query
6) View detailed category contents
Query **View Table Contents categories
4. Now let's try to delete one of the CategoryName records, indicated by the arrow above.
Access Denied Notification
Successfull, it turns out that access to DELETE was rejected, this proves that the privileges we have set on Tikno are working properly.
That's all, hopefully it's useful, greetings programmer