如何在 MySQL 中以 root@localhost 权限运行?

发布于 2024-11-05 11:46:21 字数 1079 浏览 0 评论 0原文

我正在尝试运行 GRANT ALL 语句:

GRANT ALL ON daisyrepository.* TO daisy@localhost IDENTIFIED BY 'password_here';

我已使用远程桌面在服务器本身上运行此语句:

  • PHPMyAdmin
  • MySQL Administrator
  • 命令行客户端

每次运行此语句时,都会收到以下错误:

ERROR 1044 (42000): Access denied for user 'root'@'%' to database 'daisyrepository'

有关权限的一些信息:

root@%

SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, REPLICATION SLAVE, REPLICATION CLIENT, EXECUTE 

root@localhost

ALL PRIVILEGES 

如果我理解正确的话,即使我连接到服务器上,MySQL 也会将我的语句视为我来自远程位置?

编辑#1 澄清:我连接的服务器也运行 MySQL。

编辑#2 进入 RDP 后,我使用命令行登录 MySQL。如果我运行 select current_user(),我会得到 [email protected]。 my.ini 文件中也有skip_name_resolve。

I'm trying to run a GRANT ALL statement:

GRANT ALL ON daisyrepository.* TO daisy@localhost IDENTIFIED BY 'password_here';

I've ran this statement on the server itself using Remote Desktop using:

  • PHPMyAdmin
  • MySQL Administrator
  • Command line client

Everytime I run this statement, I get the following error:

ERROR 1044 (42000): Access denied for user 'root'@'%' to database 'daisyrepository'

A bit of information regarding priviledges:

root@%

SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, REPLICATION SLAVE, REPLICATION CLIENT, EXECUTE 

root@localhost

ALL PRIVILEGES 

If I understand correctly, even though I'm connected on the server, MySQL is treating my statements like I was coming from a remote location?

Edit #1
Clafification: the server I'm connected to is where MySQL is also running.

Edit #2
Once in RDP, I log into MySQL using the command line. If I run select current_user(), I get [email protected]. The my.ini file also has skip_name_resolve in it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只为一人 2024-11-12 11:46:21

您似乎总是通过 TCP 连接(而不是 Linux 上的 Unix 套接字或 Windows 上的命名管道)。因为你的ini文件中有skip_name_resolve,服务器不会将IP 127.0.0.1反向DNS到本地主机,因此你显示的用户是[电子邮件受保护],而不是 root@localhost。

如果可以,请从 ini 文件中删除skip_name_resolve,并确保 Abe Petrillo 提到您的主机文件中有“127.0.0.1 localhost”。这应该允许您以 root@localhost 身份进行连接。如果您需要放回skip_name_resolve,请确保运行,

GRANT ALL on *.* to 'root'@'127.0.0.1' identified by '$roots_password' WITH GRANT OPTION;

这应该允许您将skip_name_resolve添加回ini文件中。

You appear to always be connecting over TCP (rather than Unix sockets on Linux or named pipes on windows). Because you have skip_name_resolve in your ini file, the server doesn't reverse DNS the ip 127.0.0.1 back to localhost, hence the user you appear as is [email protected], not root@localhost.

If you can, remove the skip_name_resolve from the ini file and make sure as Abe Petrillo mentions that you have '127.0.0.1 localhost' in your hosts file. This should allow you to connect as root@localhost. If you need skip_name_resolve to be put back, make sure you run,

GRANT ALL on *.* to 'root'@'127.0.0.1' identified by '$roots_password' WITH GRANT OPTION;

which should allow you to add the skip_name_resolve back into your ini file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文