0

I am running mysql server on my ubuntu machine,

I created a database using the following line of code:

CREATE DATABASE Quizzie;

Now , I want to grant permission to users in this database, so I used the following line of code.

GRANT ALL ON Quizzie.* TO 'user'@'localost' IDENTIFIED BY 'user';
GRANT ALL ON Quizzie.* TO 'user'@'127.0.0.1' IDENTIFIED BY 'user';

But I get following errors:

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 'Abhilekh'' at line 1
Bill Karwin
  • 499,602
  • 82
  • 638
  • 795
IcanCode
  • 509
  • 1
  • 10
  • 1
    It doesn't need the `IDENTIFIED BY 'Abhilekh'` when giving grants, so remove it and it will work. And I suppose you have create the users – Ergest Basha Sep 13 '21 at 15:50
  • No I haven't created a user – IcanCode Sep 13 '21 at 15:52
  • After creating the database run `create user 'user'@'localhost' identified by 'choose a strong password';` and `create user 'user'@'127.0.0.1' identified by 'choose a strong password';` and then give the grants removing the part I mentioned in the first comment – Ergest Basha Sep 13 '21 at 15:55
  • 2
    MySQL 8.0 changed the syntax for creating users and running grants. If you are following instructions written for earlier versions of MySQL, you should read the [current manual on Account Management Statements in MySQL 8.0](https://dev.mysql.com/doc/refman/8.0/en/account-management-statements.html). – Bill Karwin Sep 13 '21 at 16:00

0 Answers0