Mysql – Removed privileges from root user and can’t access database

MySQLpermissions

New to databases and accidentally removed privileges from root user; only privileges I currently have are USAGE and PROXY. This is a MySQL database that I access through HeidiSQL. Currently cannot access my data tables; is there a way to get these privileges restored? Did not create any other user accounts.

Best Answer

You can use following steps to regrant root priviledge.

  1. Shutdown mysqld.
  2. Start mysqld with --skip-grant-tables.
  3. Use mysql to connect mysqld. (Type mysql only, No need to input password -p, maybe No need to input username root, either)
  4. UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root';

    FLUSH PRIVILEGES;

  5. Restart mysqld normally.