ERROR 1064 (42000) at line 1 - mysql

I doing a Batch File and Got the error please help me.
The Error --
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 'GRANT OPTION' at line 1
MySQL Script
CREATE USER 'a4db'#'%' IDENTIFIED BY '0987654321';
GRANT ALL PRIVILEGES ON *.* TO 'a4db'#'%' IDENTIFIED BY '0987654321' WITH GRANT OPTION;
FLUSH PRIVILEGES;
I'm want to create the new user for remote the Sql Databases from client PC. If I copy the script to the workbench or to cmd it will run correctly and no error.
Please help me solve this error.

Add *.* between ON and TO ,the first * is your database name,and the second * is the table name. *.* means all database.all tables. For example, if you want this user just have the right to operate table 'test' in the database 'db',you may write like this db.test
GRANT ALL PRIVILEGES ON *.* TO 'a4db'#'%' IDENTIFIED BY '0987654321' WITH GRANT OPTION;

Related

How to grant all mysql 8.0 privileges to debezium in windows

I tried the below command
mysql> GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE,
REPLICATION CLIENT ON *.* TO 'debezium' IDENTIFIED BY 'dbz';
It gave 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 'IDENTIFIED BY 'dbz'' at line 1
To grant all privileges use GRANT ALL
GRANT ALL ON *.* TO 'debezium'#'%' IDENTIFIED BY 'dbz';
You are missing the host in your query I added % you can log in from anywhere, change it based on your needs.

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL serrver for mySQL [duplicate]

i have installed mysql 8.0.12 into one linux node and when i try to give below grant permission to get access from other nodes, i am getting 42000 error
command issued :
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%' IDENTIFIED BY 'password';
Return results:
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 'secure1t'' at line 1
Any help would be appreciated.
You don't use IDENTIFIED BY in GRANT queries, it's used in CREATE USER.
CREATE USER 'root'#'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%';
GRANT command reference
CREATE USER command reference
GRANT ALL PRIVILEGES ON your_desired_database_name.* TO 'root'#'localhost';
then
FLUSH PRIVILEGES;
**This worked for me and will work for you
**

Error 1064 (42000) Failed to grant privileges

I follow the instructions grant database privileges to rails.
I used the following code:
GRANT ALL PRIVILEGES ON demo_proejcts_development.* TO'rails_user'#'localhost' IDENTIFIED BY PASSWORD 'password'
The demo_proejcts_developments is a database I created and I want to grant the privileges to the rails_user account
But it gives me 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 'IDENTIFIED BY PASSWORD 'password'' at line 1
I have tried to use ` to cover the project name, `demo_projects_development`, but it stills failed.
And more, I tried to separate the comment as two line via 'alter user', it still failed.
You can not use the IDENTIFIED BY in GRANT statement.
check mysql documentation here
If you don't have the rails_user already set then you can create with
CREATE USER 'rails_user'#'localhost' IDENTIFIED BY 'password';
and with following statement you can give permission for all priviledges with
GRANT ALL ON demo_proejcts_development.* TO 'rails_user'#'localhost';

mysql ERROR 1064 (42000): You have an error in your SQL syntax;

i have installed mysql 8.0.12 into one linux node and when i try to give below grant permission to get access from other nodes, i am getting 42000 error
command issued :
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%' IDENTIFIED BY 'password';
Return results:
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 'secure1t'' at line 1
Any help would be appreciated.
You don't use IDENTIFIED BY in GRANT queries, it's used in CREATE USER.
CREATE USER 'root'#'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%';
GRANT command reference
CREATE USER command reference
GRANT ALL PRIVILEGES ON your_desired_database_name.* TO 'root'#'localhost';
then
FLUSH PRIVILEGES;
**This worked for me and will work for you
**

How can I give CREATE USER and GRANT privileges to an user in MySQL?

I created a new user called Hamza in localhost then I tried to give it these 2 privileges:
CREATE USER
GRANT
For the creation everything is OK, but when it comes to granting the privileges I tried this query :
GRANT CREATE USER TO 'Hamza'#'localhost' WITH GRANT OPTION;
And I got this 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 'TO 'Hamza'#'localhost' WITH GRANT OPTION' at line 1
Could someone tell me how can I correct this syntax error ?
You are missing the ON object_name here in your GRANT statement like
GRANT CREATE USER ON *.* TO 'Hamza'#'localhost' WITH GRANT OPTION;