I am trying to execute this queries -
DROP DATABASE IF EXISTS `hotel`;
GRANT USAGE ON *.* TO \'user\'@\'localhost\';
DROP USER \'user\'@\'localhost\';
CRE
I thought that Grant usage create new user if user does not exist. What is wrong?
In previous versions of mysql that was the case. See this answer if you want to do it the new way. If you would like to modify your system settings to make it work the way it used to, read on. However, note that this is a deprecated behavior, as the linked documentation states that
NO_AUTO_CREATE_USER will be removed in a future MySQL release, at which point its effect will be enabled at all times (GRANT will not create accounts)
From the documentation, you can set an option to allow mysql to create a user if it does not exist.
NO_AUTO_CREATE_USER
Prevent the GRANT statement from automatically creating new users if it would otherwise do so, unless a nonempty password also is specified.
To set the option:
You can change the SQL mode at runtime by using a SET [GLOBAL|SESSION] sql_mode='modes' statement to set the sql_mode system value.