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.
-
What privileges did the root user have and do you have the name of the root user? Since it is a root user i assume it has the highest of privileges so you can run mysql code to grant privileges: GRANT ALL PRIVILEGES ON mydb.* TO 'myuser'@'%' WITH GRANT OPTION; See: stackoverflow.com/questions/5016505/… for more information – Raidenlee Jun 7 '17 at 15:18
You can use following steps to regrant root priviledge.
- Shutdown
mysqld
. - Start
mysqld
with--skip-grant-tables
. - Use
mysql
to connectmysqld
. (Typemysql
only, No need to input password-p
, maybe No need to input usernameroot
, either) UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root';
FLUSH PRIVILEGES;
- Restart
mysqld
normally.
-
-
-
I don't have shutdown privileges so I can't use the mysqladmin shutdown. I tried turning off MySQL using the "Services" menu on my PC, but when I try to restart with 'mysqld_safe --skip-grant-tables -skip-networking' it tells me that it can't connect to server. Any ideas? – Eric Cooks Sep 26 '17 at 17:15