为什么它显示错误 1146“表‘student.db’”不存在,尽管我已经创建了“学生”;数据库?

发布于 2024-12-23 15:07:36 字数 464 浏览 1 评论 0原文

创建数据库“student”后,当我设置有关该数据库的权限时,出现错误,并显示消息“错误 1146(42S02):表“student.db”不存在。 我不明白为什么会发生这种错误,尽管我确实创建了数据库。

你能让我知道问题是什么吗?

请参考以下步骤进行重现。

Start mysql with root account
create database student;
use student;

insert into db values ('%', 'student', 'beginner', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y'); 

发生错误......“错误1146(42S02):表'student.db'不存在。

我可以使用'showdatabase;'检查学生数据库是否存在。但这条消息说“student.db”不存在。

After I created database 'student', when I set authorities about the db, error occurred with the message "ERROR 1146(42S02) : Table 'student.db' doesn't exist.
I can't understand why this kind error happened, though I surely created the database.

Could you let me know what the problem is?

Please, refer below step to reproduce.

Start mysql with root account
create database student;
use student;

insert into db values ('%', 'student', 'beginner', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y'); 

Error occurred...... "ERROR 1146(42S02) : Table 'student.db' doesn't exist.

I can check that student database exists by using 'show databases;'. but this message says "student.db" doesn't exist.

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

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

发布评论

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

评论(5

许仙没带伞 2024-12-30 15:07:36

您似乎正在尝试通过直接修改系统表来授予权限。每个 MySQL 实例中都有一个表 mysql.db,但该表不属于您的 student 数据库。

我建议您使用 GRANT 语句,而不是直接修改系统数据:

mysql> CREATE USER 'beginner'@'%' identified by 'enter password here';
mysql> GRANT ALL PRIVILEGES ON student.* to 'beginner';

It appears that you are trying to grant privileges by modifying the system tables directly. There is a table mysql.db in every MySQL instance, but that table does not belong to your student database.

I recommend you use the GRANT statement instead of tinkering with system data directly:

mysql> CREATE USER 'beginner'@'%' identified by 'enter password here';
mysql> GRANT ALL PRIVILEGES ON student.* to 'beginner';
三生一梦 2024-12-30 15:07:36

Student.db 引用 student 数据库中名为 db 的表。显然您还没有创建此表...
顺便说一句,请仔细阅读错误消息以及您认为的问题所在。

student.db refers to a TABLE named db inside the student database. You obviously did not create this table yet...
b.t.w. read carefully the error message and what you thought the problem is.

拿命拼未来 2024-12-30 15:07:36

此语句

insert into db values ('%', 'student', 'beginner', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y');

假设在某个时刻,名为 db 的表已创建:

create table db ( ...

根据您在此处显示的内容,您似乎尚未创建它;您期望它的定义从何而来?

This statement

insert into db values ('%', 'student', 'beginner', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y');

assumes that at some point, the table named db has been created:

create table db ( ...

Based on what you've shown here, you don't seem to have created it; where did you expect its definition to come from?

乖乖哒 2024-12-30 15:07:36

您已创建数据库,但尚未在其中创建任何表。您告诉 MySQL 将数据插入到名为“db”的表中,但该表并不存在。您需要这样的事情:

create database student;
use student;
create table db (.... field definitions here ...)  <---you're missing this step
insert into db values (....);

数据库只是一个容器。它必须至少定义一个表才能真正有用。

You've created a database, but haven't created any tables in it. You're telling MySQL to insert your data into a table name "db", which doesn't exist. You need to have something like this goin gon:

create database student;
use student;
create table db (.... field definitions here ...)  <---you're missing this step
insert into db values (....);

A database is just a container. It must have at least ONE table defined in it to actually be useful.

随波逐流 2024-12-30 15:07:36

问题是...
你有一个带有“InnoDB ENGINE”的数据库......
我的解决方案是...
你必须有一个“MyISAM引擎”,
怎么改?...发现你的环境可能是

# find / -name my.cnf

在LINUX上,只需添加以下行即可,

nbsp;vim /etc/mysql/my.cnf 

default-storage-engine= MyISAM

然后重新启动mysql:

$ service mysql restart

The Problem was...
You have a DB with "InnoDB ENGINE".......
My Solution was...
You must have a "MyISAM ENGINE",
how to change?... find on your environment may be with

# find / -name my.cnf

on LINUX, simply add the following line to

$ vim /etc/mysql/my.cnf 

default-storage-engine= MyISAM

Then restart mysql:

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