我无法访问 MySQL 中的某些数据库(我得到:未知数据库“[我的数据库名称]”)

发布于 2024-11-25 20:51:56 字数 1739 浏览 1 评论 0原文

我对此感到疯狂,试图找出我可能出错的地方。 我有一种奇怪的感觉,这是某种权限问题,但我不知道如何解决。

我刚刚决定迁移到 MAMP,并且已将所有数据库文件夹移动到 db/mysql 文件夹,但它们没有在 phpMyAdmin 中显示,也无法通过 PHP 连接到它们。我得到:

1049:未知数据库“[我的数据库名称]”

尝试从 Sequel Pro 访问它们也不起作用,它们只是不显示。

  • 将它们 CHMOD 为 0777 不会执行任何操作。
  • 将它们 CHWONing 到 bruno:admin (我的用户和组)不会执行任何操作。
  • 使用 phpMyAdmin 创建新数据库工作正常,并且数据库显示并且我可以使用它。

解决这个问题的一个可靠方法是转到 Windows(不会出现权限问题),将所有数据库导出为 SQL,然后将它们导入到我的 Mac 上。但这似乎是一种愚蠢的解决方法。必须有一种更智能的方法,我想了解为什么这不起作用,我想知道出了什么问题。

PS 最奇怪的是,当我使用常规 MySQL 安装时,我没有遇到这些问题,直到现在我将数据库移至 MAMP 的 MySQL,才开始发生这种情况。

附加信息:

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.10 sec)

mysql> show grants;
+----------------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@localhost                                                                                                              |
+----------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '[removed]' WITH GRANT OPTION |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION                                                                           |
+----------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

I've been going insane with this, trying to figure out where I could possibly be going wrong.
I have this strange feeling it's some sort of permissions issue, but I don't know how to solve it.

I have just decided to move to MAMP, and I've moved all my database folders to the db/mysql folder, but they just aren't showing up for me in phpMyAdmin, nor can I connect to them via PHP. I get:

1049: Unknown database '[my-database-name]'

Trying to access them from Sequel Pro doesn't work either, they just don't show up.

  • CHMODing them to 0777 doesn't do anything.
  • CHWONing them to bruno:admin (my user and group) doesn't do anything.
  • Creating a new database with phpMyAdmin works fine, and the database shows up and I can use it.

A sure-fire way around this is to go to Windows (wouldn't get permission issues there), export all the databases as SQL, then import them on my Mac. But that seems like such a stupid way to get around it. There's got to be a more intelligent way, and I want to understand WHY this is not working, I want to know what's wrong.

P.S. The oddest thing is, I didn't have these problems when I was using a regular MySQL installation, it's only now that I've moved databases over to MAMP's MySQL that this started happening.

Additional Information:

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.10 sec)

mysql> show grants;
+----------------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@localhost                                                                                                              |
+----------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '[removed]' WITH GRANT OPTION |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION                                                                           |
+----------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

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

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

发布评论

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

评论(1

伴我老 2024-12-02 20:51:56

只需尝试从控制台登录数据库并尝试 showdatabaseshowgrants 看看您是否有权限。

Just try to login to the db from console and try show databases or show grants to see if you have permissions.

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