MySQL MySQL看不到数据库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4349077/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MySQL can't see database
提问by Webnet
GRANT SELECT ON source_starcraft.udb_ability TO `wade`@`localhost'
When I login with wade
via PHPMyAdmin I can't see the database source_starcraft
. I've only executed this query and created the user prior to this query.
当我wade
通过 PHPMyAdmin登录时,我看不到数据库source_starcraft
。我只执行了这个查询并在这个查询之前创建了用户。
回答by bigstones
Here something that helped me a lot. Actually I was working with MySQL Workbench.
这里有一些对我帮助很大的东西。实际上我正在使用 MySQL Workbench。
http://bobfield.blogspot.it/2006/10/i-cant-see-my-databases.html
http://bobfield.blogspot.it/2006/10/i-cant-see-my-databases.html
Briefly, it says that if MySQL has an <anonymous> account, and you fail logging in with your user, you end up logged in as the anonymous user, without notice. To find out this you can do:
简而言之,它表示如果 MySQL 有一个 <anonymous> 帐户,并且您无法使用您的用户登录,您最终会以匿名用户的身份登录,而不会另行通知。要了解这一点,您可以执行以下操作:
SELECT user(), current_user();
Here's why:
原因如下:
One important thing to note is that
SELECT USER();
shows you your current username and host. Another command,SELECT CURRENT_USER();
shows what you're authenticatedas.
需要注意的一件重要事情是
SELECT USER();
显示您当前的用户名和主机。另一个命令SELECT CURRENT_USER();
显示您的身份验证。
Indeed, in my case, user()
was mylogin@localhost
, current_user()
was @localhost
(the anon user).
事实上,就我而言,user()
是mylogin@localhost
,current_user()
是@localhost
(匿名用户)。
回答by TwoD
If the user you logged into phpMyAdmin with does have the correct permissions to view the database, but you still can't see it, it might mean phpMyAdmin itself has been configured to not show it. This is easiest to verify by issuing a show databases;
SQL query from within phpMyAdmin. If the database you are looking for shows up, the user is permitted to view it, at the least.
如果您登录 phpMyAdmin 的用户确实具有查看数据库的正确权限,但您仍然看不到它,这可能意味着 phpMyAdmin 本身已配置为不显示它。通过show databases;
在 phpMyAdmin 中发出SQL 查询,最容易验证。如果您要查找的数据库出现,则至少允许用户查看它。
There are several config directives which can controls which databases are visible in phpMyAdmin's lists. If you used an automated installer or script to add phpMyAdmin to a user account, it might also have set one of only_db or hide_db. These are also described in the official phpMyAdmin documentation, which should have been included with your installation, and on the wiki.
有几个配置指令可以控制哪些数据库在 phpMyAdmin 的列表中可见。如果您使用自动安装程序或脚本将 phpMyAdmin 添加到用户帐户,它也可能设置了 only_db 或 hide_db 之一。这些也在官方 phpMyAdmin 文档中进行了描述,该文档应该包含在您的安装中,以及在wiki 上。
If your user has access to change the settings, you can do it for the current session from within phpMyAdmin under "Settings" and the "Features" tab. To permanently change these settings you will need to edit config.inc.php. Its location depends on where phpMyAdmin is installed on your system.
如果您的用户有权更改设置,您可以在 phpMyAdmin 中的“设置”和“功能”选项卡下为当前会话执行此操作。要永久更改这些设置,您需要编辑config.inc.php。它的位置取决于 phpMyAdmin 在您系统上的安装位置。
回答by Riedsio
Seems like there might me some conflict/confusion with respect to which host the permission was granted to, and which one(s) are being used.
似乎对于授予许可的主机以及正在使用的主机可能存在一些冲突/困惑。
After FLUSH PRIVILEGES
to remove that possibility, I'd see which user I was being identified as once I was logged in:
在FLUSH PRIVILEGES
消除这种可能性之后,我会看到我登录后被识别为哪个用户:
SELECT user();
Note that MySQL always associates a login with the most specific host. See doc. Then compare that to what's in the privileges database.
请注意,MySQL 始终将登录与最具体的主机相关联。见文档。然后将其与权限数据库中的内容进行比较。
SELECT * FROM mysql.user WHERE user='wade';
SELECT * FROM mysql.db WHERE user='wade';
To resolve the situation, either REVOKE
or DELETE
+FLUSH PRIVILEGES
the trouble-causing conflict (being careful not to paint yourself into a corner), or GRANT
more privileges to the one your user is identified as.
为了解决这种情况,要么REVOKE
或DELETE
+FLUSH PRIVILEGES
的故障导致冲突(注意不要给自己画成一个角落),或GRANT
更多的特权用户被识别为一个。