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 try to install fleetspeak. Use Ubuntu 18.04.
First of all I run this
CREATE USER 'fleetspeak-user' IDENTIFIED BY 'fleetspeak-password';
Then I want to create database with this
CREATE DATABASE 'fleetspeak';
But has an 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 ''fleetspeak'' at line 1
Why I can get this?
Try the create database script without single quotes in dbname
CREATE DATABASE fleetspeak;
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 want to revoke insert on a specific table form a user in mysql
and I try this code before:
use varian_db;
REVOKE INSERT ON 'gevhm_users' FROM 'varian_user';
but mysql returned this error :
#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 ''gevhm_users' FROM 'varian_user'' at line 1
Please help.
You have to specify full path of database name and table name when granting or revoking privileges to/from such user. And also write user name in correct format. Your statement should like this:
REVOKE INSERT ON varian_db.gevhm_users FROM 'varian_user'#'user_ip_address';
FLUSH PRIVILEGES;
More information: MySQL Revoke Syntax
I have a brand new mysql installation. I want to delete a user only if exists and I have only root user. I'm trying to run from shell:
DROP USER IF EXISTS foo;
or
DROP USER IF EXISTS 'foo'#'localhost';
But mysql returns this kind of messages:
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 'IF EXISTS foo' at line 1
What am I doing wrong?
I read this post but does not explain why IF EXISTS statement does not work
From your own link:
As of MySQL 5.7.8, the IF EXISTS clause can be used, which causes the
statement to produce a warning for each named account that does not
exist, rather than an error.
You can find out your server version with e.g.:
select ##version;