如何在 MySQL 中以 root@localhost 权限运行?
我正在尝试运行 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您似乎总是通过 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,请确保运行,
这应该允许您将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,
which should allow you to add the skip_name_resolve back into your ini file.