如何在 MySQL 中以 root@localhost 权限运行? [英] How can I run with root@localhost privileges in MySQL?
问题描述
我正在尝试运行 GRANT ALL 语句:
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 管理员
- 命令行客户端
每次运行此语句时,都会出现以下错误:
Everytime I run this statement, I get the following error:
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
root@localhost
ALL PRIVILEGES
如果我理解正确,即使我已连接到服务器,MySQL 也会将我的语句视为来自远程位置?
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?
编辑 #1澄清:我连接的服务器也是运行 MySQL 的地方.
Edit #1 Clafification: the server I'm connected to is where MySQL is also running.
编辑 #2进入 RDP 后,我使用命令行登录 MySQL.如果我运行 select current_user(),我会得到 root@127.0.0.1.my.ini 文件中也有skip_name_resolve.
Edit #2 Once in RDP, I log into MySQL using the command line. If I run select current_user(), I get root@127.0.0.1. The my.ini file also has skip_name_resolve in it.
推荐答案
您似乎总是通过 TCP 进行连接(而不是 Linux 上的 Unix 套接字或 Windows 上的命名管道).因为您的 ini 文件中有 skip_name_resolve,服务器不会将 DNS ip 127.0.0.1 反向回本地主机,因此您显示的用户是 root@127.0.0.1,而不是 root@localhost.
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 root@127.0.0.1, not root@localhost.
如果可以,请从 ini 文件中删除 skip_name_resolve 并确保如 Abe Petrillo 所述,您的主机文件中有127.0.0.1 localhost".这应该允许您以 root@localhost 身份连接.如果您需要将 skip_name_resolve 放回去,请确保您运行,
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;
这应该允许您将 skip_name_resolve 添加回您的 ini 文件.
which should allow you to add the skip_name_resolve back into your ini file.
这篇关于如何在 MySQL 中以 root@localhost 权限运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!