Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I maintain CREATE rights after DROP DATABASE in MySQL?

Tags:

mysql

I have a user in MySQL with the following privileges:

GRANT USAGE ON *.* TO 'certain_db'@'192.168.1.1' IDENTIFIED BY PASSWORD '****'
GRANT ALL PRIVILEGES ON `certain_db`.* TO 'certain_db'@'192.168.1.1'

If I drop this database, do I maintain the right to create it afterwards?

like image 738
Cas van Noort Avatar asked Jan 06 '12 22:01

Cas van Noort


People also ask

Why should you be very careful with the drop database command?

We can drop the database using the SQL command DROP DATABASE that completely and permanently deletes the database and all the contents of that database. Hence, we should be careful while using this command as it is not possible to restore the dropped database if you don't have any backup of it.

How do I drop an entire database in MySQL?

Deleting a MySQL or MariaDB database First list all databases on your server. Use the command 'SHOW DATABASES;' in the mysql-console like in the example above. Now copy the name of the database you want to delete. To do delete a database you need the command 'DROP DATABASE'.

How do I give a drop privilege in MySQL?

To revoke all privileges, use the second syntax, which drops all global, database, table, column, and routine privileges for the named users or roles: REVOKE ALL PRIVILEGES, GRANT OPTION FROM user_or_role [, user_or_role] ... REVOKE ALL PRIVILEGES, GRANT OPTION does not revoke any roles.

How does drop work in MySQL?

Use the DROP Statement to Remove a Table. To permanently remove a table, enter the following statement within the MySQL shell: DROP TABLE table1; Replace table1 with the name of the table you want to delete.


1 Answers

Yes. All information related to user access, privileges, etc is stored in a database named 'mysql'. Information related to database privileges is stored in table 'db'. When you drop a database your privileges over it are not deleted. So, if you want to create a database with the SAME name later you will be able to.

like image 72
Diego Ledesma Avatar answered Oct 16 '22 07:10

Diego Ledesma