I am following instruction to set permissions on a db in MySQL-Client-Version: 5.1.61
This is the statement I should enter:
GRANT SELECT, INSERT, DELETE, UPDATE, CREATE, DROP, ALTER, INDEX on 'databasename'.*
TO 'username'#'localhost' IDENFIFIED BY 'password';
Obviously I change the names but keep the quotes.
The error is -
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 ''databasename'.* TO 'username'#'localhost' IDENFIFIED BY 'password'' at line 1
What is going wrong here?
Use IDENTIFIED BY instead of IDENFIFIED BY.
Related
I'm trying to install Moodle using Ubuntu using the following guide: Step-by-step Installation Guide for Ubuntu
I'm currently on step 6 where I have to create a mySQL user with the correct permissions and this is where I'm getting stuck.
The 1st command - create user 'user1'#'localhost' IDENTIFIED BY 'password1'; works fine
However the 2nd command -
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO user1#localhost
IDENTIFIED BY 'password1';
Returns the error message - 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 'password1'' at line 1
The installation manual mentions that this may be a problem so advises me to use - SELECT password('password1'); in order to get a hash value to overcome the problem.
However instead of giving me a hash value it comes up with the same error of - 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 '('password1')' at line 1
I am a beginner to all this so I'd appreciate any responses, thanks in advance!
You need apostrophes around the name and the host in your command, like:
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO 'user1'#'localhost'
IDENTIFIED BY 'password1';
EDIT
According to the comments, slightly changing the command fixed the syntax error:
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO 'user1'#'localhost';
First Create user ‘moodleuser’#’localhost’ identified by ‘yourpassword’;
Then grant select,insert,update,delete,create,create temporary tables,drop,index,alter on moodle.* to 'moodleuser'#'localhost';
I'm trying to execute
ALTER USER 'root'#'localhost' IDENTIFIED BY 'my_new_password';
but getting
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 'my_new_password'' at line 1
What am i doing wrong?
The way you want to change the password is only valid since MySQL 5.7.6. You can use the SET PASSWORD statement for older versions instead:
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('my_new_password');
The ALTER USER statement is available since MySQL 5.7.6. Make sure you are using this version or a newer one to use your statement (thx #Dez).
I have an error in my MySQL statement (using shell file), which I can't seem to resolve. Tried to put quotes etc but no luck. When I created it using phpmyadmin it works, but I want to have it scripted. Must be something small... Any ideas?
--- Create mySQL database ---
CREATE DATABASE IF NOT EXISTS _test-123;
CREATE USER 'test-123'#localhost IDENTIFIED BY '***';
GRANT ALL PRIVILEGES ON _test-123.* TO 'test-123'#'localhost';
FLUSH PRIVILEGES;
Enter password:
ERROR 1064 (42000) at line 1: 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 '-123' at line 1
Try removing the "-" and do this one instead-
CREATE DATABASE IF NOT EXISTS _test_123;
the title says it all, here was my code
GRANT SELECT, INSERT, UPDATE, DELETE ON 'database_name' TO 'mysqluser'#'111.111.111.111';
it says
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 near ''database_name' TO 'mysqluser'#'111.111.111.111'' at line 1
This:
GRANT SELECT, INSERT, UPDATE, DELETE ON 'database_name' TO 'mysqluser'#'111.111.111.111';
Should be:
GRANT ALL ON 'database_name'.* TO 'mysqluser'#'111.111.111.111';
In your specific case(tested on my mysql server):
GRANT SELECT, INSERT, UPDATE, DELETE ON database_name.* TO 'mysqluser'#'111.111.111.111';
You quoted the DB name with ', which turns it into a string. Once it's a string, it's no longer a table name. it's just a string that CONTAINS something that looks like a table name.
It should be EITHER
GRANT ... ON database_name
or
GRANT ... ON `database_name`
The backticks are only necessary if the db name happens to be a reserved word.
I am trying to run the following query in MySQL:
GRANT REPLICATION SLAVE ON *.* TO 'replication'#’10.141.2.%’ IDENTIFIED BY ‘slave’;
It keeps returning the following error:
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 '??10.141.2.%’ IDENTIFIED BY ‘slave’' at line 1
What am i doing wrong?
Thanks.
You are using "fancy quotes" (see how they 'lean') ? Replace ’ with '
'replication'#’10.141.2.%’ should be 'replication'#'10.141.2.%'
(also, it appears you are doing it on IDENTIFIED BY ‘slave’; as well)