Mysql 1064 syntax error

I’m getting a 1064 syntax error when trying to create a new user. I’m on windows 10, using python. What I’ve entered at the command line after creating the database is: grant all on vsearchlogDB.* to ‘vsearch’ identified by ‘vsearchpasswd’ ; I’m following Head First Python 2nd edition and this is on page 287. The error I get is that this is a syntax error and it is having trouble with the identified by ‘vsearchpasswd’ ; part of the code. I’m using the latest version of mysql for Windows


Check if you’re using correct quotes (those in your post are not valid).

Apologies, I think that was because I posted from my phone. I’ve added the code direct from the command prompt now, still having the error shown below:

mysql> grant all on vsearchlogDB.* to ‘vsearch’ identified by ‘vsearchpasswd’;

ERROR 1064 (42000): 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 ‘identified by ‘vsearchpasswd’’ at line 1

Try this (copy/paste it as is):

grant all on vsearchlogDB.* to 'vsearch' identified by 'vsearchpasswd';

Still no luck, same error message :confused:

Quoth the documentation:

As of MySQL 5.7.2, if the account already exists, IDENTIFIED WITH is prohibited because it is intended only for use when creating new accounts.

That might be the cause, though I can’t see why it would result in a syntax error. Possibly it’s demanding the full username syntax like:

grant all on vsearch.*' to 'vsearch'@'localhost' identified by 'vsearchpasswd'

It’s hard to tell with mysql a lot of the time…

Ok, so I shouldn’t be using IDENTIFIED BY? The user doesn’t exist yet

See my amended post. I’m not sure why it would be a syntax error though.

Rather than an error it’s just given me a new line with this '> arrow. Apologies, brand new to MySQL and pretty new to Python!

mysql> grant all on vsearch.*’ to ‘vsearch’@‘localhost’ identified by ‘vsearchpasswd’;

grant all on vsearch.*' to 'vsearch'@'localhost' identified by 'vsearchpasswd';`

You have an extra quote here

That was from when I copied your code above but I did spot and tried it without, still no luck. It’s very strange…

Managed to get there. I had to split it in half and do over two lines: create user and then on the next line set a password