BioGeek
BioGeek

Reputation: 22917

Make restore of MySQL root user’s full privileges persistent after restart

When I log in with user root on localhost using MySQL WorkBench and click on Users and Privileges, I get the message 'The account you are currently using does not have sufficient privileges to make changes to MySQL users and privileges'.

Following the procedure in this answer I am able to restore my root user’s full privileges:

I can close and reopen MySQL Workbench and my root user keeps it's full priviliges but if I restart my computer I am back in the previous insufficient priviliges state and I have to do the whole procedure over again.

How can I make the restore of MySQL root user’s full privileges persistent after restart?

My my.ini looks like this:

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]
# skip_grant_tables

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....


# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
explicit_defaults_for_timestamp=TRUE

Upvotes: 1

Views: 2730

Answers (1)

Shawn
Shawn

Reputation: 3369

Try a slightly different order of operations:

  1. Stop mysqld and restart it with mysqld --skip-grant-tables option.
  2. Connect to the mysqld server with just: mysql (i.e. no -p option, and username may not be required).
  3. Issue the following commands in the mysql client: UPDATE mysql.user SET Grant_priv='Y',Super_priv='Y' WHERE User='root'; FLUSH PRIVILEGES;
  4. Restart your mysql service
  5. Now run GRANT ALL ON *.* TO 'root'@'localhost';

Let me know if this works.

Upvotes: 2

Related Questions