Error with dropping tables:
SQL query:
DROP user IF EXISTS 's01'@'%';
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to
use near 'if exists 's01'@'%'' at line 1
Error without dropping tables:
SQL query:
/*Students*/ CREATE User 's01'@'%' IDENTIFIED BY 'pw1';
MySQL said: Documentation
#1396 - Operation CREATE USER failed for 's01'@'%'
Example of some of my code:
Drop user if exists 's01'@'%';
flush privileges;
/*Students*/
Create User 's01'@'%' Identified by 'pw1';
I don't exactly know what is wrong. I looked it up and it said add flush privileges, but I still get the same two errors.
Check your version of mysql with
select version();
. TheIF EXISTS
option forDROP USER
was added in 5.7. If you're not using 5.7, then that likely explains your first error.Check if the user exists by querying
mysql.user
table.Also since you are not specifying a hostname, just execute
The wildcard host (@'%') is implied.
Also execute
SHOW GRANTS
to verify that your user has the correct privileges to create and drop users.