【问题标题】:Make restore of MySQL root user’s full privileges persistent after restart重启后恢复 MySQL root 用户的全部权限
【发布时间】: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 什么的,而且一些配置文件是只读的。从所有文件中删除只读文件,并以管理员身份运行几次,这样做可以保存设置。

标签: mysql root


【解决方案1】:

尝试稍微不同的操作顺序:

  1. 停止 mysqld 并使用 mysqld --skip-grant-tables 选项重新启动它。
  2. 仅使用以下命令连接到 mysqld 服务器:mysql(即没有 -p 选项,并且可能不需要用户名)。
  3. 在mysql客户端发出如下命令:UPDATE mysql.user SET Grant_priv='Y',Super_priv='Y' WHERE User='root'; FLUSH PRIVILEGES;
  4. 重启你的mysql服务
  5. 现在运行GRANT ALL ON *.* TO 'root'@'localhost';

让我知道这是否有效。

【讨论】:

  • 抱歉回复晚了。遗憾的是,这种流程变化并没有帮助。
猜你喜欢
  • 2010-12-15
  • 1970-01-01
  • 2010-12-12
  • 2023-03-25
  • 2016-03-10
  • 1970-01-01
  • 2020-11-10
  • 2020-10-08
  • 2017-02-17
相关资源
最近更新 更多