简体   繁体   English

MySQL看不到数据库

[英]MySQL can't see database

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 .当我通过 PHPMyAdmin 使用wade登录时,我看不到数据库source_starcraft I've only executed this query and created the user prior to this query.我只执行了这个查询并在这个查询之前创建了用户。

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.简而言之,它表示如果 MySQL 有一个 <anonymous> 帐户,并且您无法使用您的用户登录,您最终会以匿名用户的身份登录,而不会另行通知。 To find out this you can do:要了解这一点,您可以执行以下操作:

SELECT user(), current_user();

Here's why:原因如下:

One important thing to note is that SELECT USER();需要注意的一件重要事情是SELECT USER(); shows you your current username and host.显示您当前的用户名和主机。 Another command, SELECT CURRENT_USER();另一个命令, SELECT CURRENT_USER(); shows what you're authenticated as.显示您的身份验证

Indeed, in my case, user() was mylogin@localhost , current_user() was @localhost (the anon user).实际上,就我而言, user()mylogin@localhostcurrent_user()@localhost (匿名用户)。

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.如果您登录 phpMyAdmin 的用户确实具有查看数据库的正确权限,但您仍然看不到它,这可能意味着 phpMyAdmin 本身已配置为不显示它。 This is easiest to verify by issuing a show databases;这是最容易通过发出show databases;来验证的show databases; SQL query from within phpMyAdmin.来自 phpMyAdmin 的 SQL 查询。 If the database you are looking for shows up, the user is permitted to view it, at the least.如果您要查找的数据库出现,则至少允许用户查看它。

There are several config directives which can controls which databases are visible in phpMyAdmin's lists.有几个配置指令可以控制哪些数据库在 phpMyAdmin 的列表中可见。 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.如果您使用自动安装程序或脚本将 phpMyAdmin 添加到用户帐户,它也可能设置了 only_db 或 hide_db 之一。 These are also described in the official phpMyAdmin documentation, which should have been included with your installation, and on the wiki .这些也在官方 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.如果您的用户有权更改设置,您可以在 phpMyAdmin 中的“设置”和“功能”选项卡下为当前会话执行此操作。 To permanently change these settings you will need to edit config.inc.php .要永久更改这些设置,您需要编辑config.inc.php Its location depends on where phpMyAdmin is installed on your system.它的位置取决于 phpMyAdmin 在您系统上的安装位置。

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.请注意,MySQL 始终将登录与最具体的主机相关联。 See doc .文档 Then compare that to what's in the privileges database.然后将其与权限数据库中的内容进行比较。

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.为了解决这种情况,要么REVOKEDELETE + FLUSH PRIVILEGES的麻烦,造成冲突(注意不要给自己画成一个角落),或GRANT更多的特权用户被识别为一个。

I had the same issue yesterday.我昨天有同样的问题。 I swap my data files HD onto another MySQL server (Same version of everything, replica brand new install same passwords as preventive maintenance).我将我的数据文件 HD 交换到另一个 MySQL 服务器上(所有内容都相同,副本全新安装与预防性维护相同的密码)。 Had both root access, but I guess they are different machines and hashs for the passwords created at MySQL startup.有两个 root 访问权限,但我猜它们是不同的机器和在 MySQL 启动时创建的密码的哈希值。 When I listed for files, all are intact in both servers, but phpmyadmin could't see databases (just information_schema), even not available using MySQL thru shell, but files are at the right location.当我列出文件时,两台服务器中的所有文件都完好无损,但 phpmyadmin 看不到数据库(只是 information_schema),甚至无法通过 shell 使用 MySQL,但文件位于正确的位置。

When check ownership of files they where not owned by root, the owner was 'nobody' , so I proceded to take ownership of the databases files at MySQL default data location using chown root:root *当检查不属于 root 的文件的所有权时,所有者是'nobody' ,所以我继续使用chown root:root *在 MySQL 默认数据位置获取数据库文件的所有权

So if you think that just replacing the data by swapping HDs, and beeing root in both places, with root access on both you will be happy camper.因此,如果您认为只是通过交换 HD 来替换数据,并且在两个地方都拥有 root 权限,那么您将很高兴露营。 But not so quickly, you may need to check persmission and ownership of those files still to be able to list them in PHPMYADMIN但不是那么快,您可能需要检查这些文件的权限和所有权仍然能够在 PHPMYADMIN 中列出它们

After that procedure, everything worked OK after reboot.在该程序之后,重启后一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM