【发布时间】:2014-07-04 08:30:37
【问题描述】:
当我使用 MySQL WorkBench 在 localhost 上以用户 root 登录并单击 Users and Privileges 时,我收到消息“您当前使用的帐户没有足够的权限来更改 MySQL 用户和权限'。
在the procedure in this answer 之后,我可以恢复我的root 用户的全部权限:
- 停止
mysqld并使用--skip-grant-tables选项重新启动它。 - 仅使用:
mysql连接到mysqld服务器(即没有-p选项,并且可能不需要用户名)。 - 在mysql客户端发出以下命令:
UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root'; FLUSH PRIVILEGES; - 运行
GRANT ALL ON *.* TO 'root'@'localhost';
我可以关闭并重新打开 MySQL Workbench,并且我的 root 用户保持它的完整权限,但如果我重新启动计算机,我会回到之前的权限不足状态,我必须重新执行整个过程。
如何使 MySQL root 用户的完全权限在重启后恢复持久?
我的my.ini 看起来像这样:
# 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
【问题讨论】:
-
在用
mysqld和--skip-grant-tables重新启动后,我向mysql 发出以下命令:UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root'; FLUSH PRIVILEGES; -
那么
GRANT ALL ON *.* TO 'root'@'localhost';呢? -
@VMai,是的,我也这样做。
-
MySQL 用户和权限表在重启时发生了什么?
-
@AndyJones 我猜它是 WAMP 什么的,而且一些配置文件是只读的。从所有文件中删除只读文件,并以管理员身份运行几次,这样做可以保存设置。