---
slug: "mysql-missing-with-grant-option-for-root"
title: "MySQL で、 root から WITH GRANT OPTION 権限が消えたので"
description: "Ansible の mysql_user モジュールで、root ユーザーを操作していたら、他のユーザーに権限付与ができなくなっていた。"
url: "https://www.ytyng.com/blog/mysql-missing-with-grant-option-for-root"
publish_date: "2018-02-26T13:14:58Z"
created: "2018-02-26T13:14:58Z"
updated: "2026-02-27T07:35:08.618Z"
categories: ["MySQL"]
keywords: ""
featured_image_url: "https://media.ytyng.com/resize/20230812/d3164ec97fd043029b9f4bf4e7dc9ad5.png.webp?width=768"
has_video: false
has_music: false
video_urls: []
music_urls: []
lang: "ja"
---

# MySQL で、 root から WITH GRANT OPTION 権限が消えたので

<p>Ansible の mysql_user モジュールで、root ユーザーを操作していたら、他のユーザーに権限付与ができなくなっていた。</p>
<p></p>
<p>root の show grants 見たら</p>
<pre>mysql&gt; show grants;<br />+--------------------------------------------------------------+<br />| Grants for root@localhost&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br />+--------------------------------------------------------------+<br />| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'            |<br />| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION |<br />+--------------------------------------------------------------+</pre>
<p>WITH GRANT OPTION が消えていた。</p>
<p></p>
<p>その場合、</p>
<pre style="background-color: #ffffff; color: #000000; font-family: 'Menlo'; font-size: 9.0pt;"><span style="color: #000080; font-weight: bold;">UPDATE </span>mysql.user <span style="color: #000080; font-weight: bold;">SET </span><span style="color: #660e7a; font-weight: bold;">Grant_priv </span>= <span style="color: #008000; font-weight: bold;">'Y' </span><span style="color: #000080; font-weight: bold;">WHERE </span><span style="color: #660e7a; font-weight: bold;">User</span>=<span style="color: #008000; font-weight: bold;">'root'</span>;</pre>
<p>して、強制的に Grant_priv を立てるといい。</p>
<p>(この後、FLUSH PRIVILEGES; いるかも?)</p>
<p></p>
<p>正しい show grants は</p>
<pre>mysql&gt; show grants;<br />+---------------------------------------------------------------------+<br />| Grants for root@localhost&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br />+---------------------------------------------------------------------+<br />| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |<br />| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br />+---------------------------------------------------------------------+</pre>
<p>こうなる。</p>
<p></p>
<p></p>
