简体   繁体   中英

Grant all privileges to root user in MySQL 8.0.21

I am aware that this question has been asked already on stackoverflow but I don't see any answer for the actual question posted. Hence posting again.

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD 'abcd' WITH GRANT OPTION;
 GRANT ALL PRIVILEGES ON *.* TO 'root'@'::1' IDENTIFIED BY PASSWORD 'abcd' WITH GRANT OPTION;

Above lines throw

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 'abcd' WITH GRANT OP' at line 1

I am trying to upgrade mysql from 5.7 to latest 8.0.21

Thanks!

For GRANT ALL privileges to root user use the following syntax:

GRANT ALL PRIVILEGES ON database_name.* TO 'root'@'localhost';
FLUSH PRIVILEGES;

The above grant mysql command defines that:

  • GRANT the PRIVILEGES of type ALL
  • These privileges are for a particular database named dbname and it applies to all tables of that database indicated by the.* that follows the dbname.
  • These privileges are assigned to username when that username is connected through locally, as specified by @'localhost'.
  • You can change to specify any valid host, replace 'localhost' with '%'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM