Mysql 1064 syntax error

Mysql 1064 syntax error
0
#1

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

Thanks

0 Likes

#2

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

0 Likes

#3

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

0 Likes

#4

Try this (copy/paste it as is):

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

#5

Still no luck, same error message :confused:

0 Likes

#6

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…

0 Likes

#7

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

0 Likes

#8

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

0 Likes

#9

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’;
'>

0 Likes

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

You have an extra quote here

0 Likes

#11

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

0 Likes

#12

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

0 Likes