mysql错误1064语法,但一切似乎都很好

发布于 2025-02-02 19:05:26 字数 1005 浏览 3 评论 0原文

我正在使用XAMPP控制面板,然后从那里开始使用Apache和MySQL的过程。然后我转到MySQL WorkBench,服务器状态似乎还可以,这里有一些信息,

Host: Windows-PC
Socket: C:/xampp/mysql/mysql.sock
Port: 3306
Version 10.1.31-MariaDB mariadb.org binary distribution
Compiled For: Win32(32)
Configuratin File: unknown

然后每次尝试为我的虚拟模式添加外键,例如:

 ALTER TABLE `puppies`.`animals` 
 ADD INDEX `Breed_idx` (`BreedID` ASC) VISIBLE;
 ;
 ALTER TABLE `puppies`.`animals` 
 ADD CONSTRAINT `Breed`
 FOREIGN KEY (`BreedID`)
 REFERENCES `puppies`.`breeds` (`Breed`)
 ON DELETE NO ACTION
 ON UPDATE NO ACTION;

我会收到以下错误,

 ERROR 1064: You have an error in your SQL syntax; check the manual that 
 corresponds to your MariaDB server version for the right syntax to use near 
 '' at line 2
 SQL Statement:
 ALTER TABLE `puppies`.`animals` 
 ADD INDEX `Breed_idx` (`BreedID` ASC) VISIBLE

所以我可以做什么,以便XAMPP开始使用XAMPP Mariadb上的MySQL语法?

或者,如果我对问题的理解是错误的,那么我该怎么做,以便在使用XAMPP时不必再次面对这种问题?

Im using xampp control panel and from there i start the process for apache and mysql. Then i go to mysql workbench and server status seems to be ok, here is some info

Host: Windows-PC
Socket: C:/xampp/mysql/mysql.sock
Port: 3306
Version 10.1.31-MariaDB mariadb.org binary distribution
Compiled For: Win32(32)
Configuratin File: unknown

Then everytime when i try to add the foreign key for my dummy schema like:

 ALTER TABLE `puppies`.`animals` 
 ADD INDEX `Breed_idx` (`BreedID` ASC) VISIBLE;
 ;
 ALTER TABLE `puppies`.`animals` 
 ADD CONSTRAINT `Breed`
 FOREIGN KEY (`BreedID`)
 REFERENCES `puppies`.`breeds` (`Breed`)
 ON DELETE NO ACTION
 ON UPDATE NO ACTION;

I get the following error

 ERROR 1064: You have an error in your SQL syntax; check the manual that 
 corresponds to your MariaDB server version for the right syntax to use near 
 '' at line 2
 SQL Statement:
 ALTER TABLE `puppies`.`animals` 
 ADD INDEX `Breed_idx` (`BreedID` ASC) VISIBLE

So what can i do so that xampp will start using mysql syntax over mariaDb?

Or if im wrong in my understanding of the problem, then what should i do so that i dont have to face this kind of issues again when using xampp?

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

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

发布评论

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

评论(3

少女的英雄梦 2025-02-09 19:05:26

问题是单词可见,将其删除并将起作用。
默认情况下可见索引。

您的问题:“如果我删除可见的话,它可以正常工作,那么为什么MySQL Workbench决定添加可见的?”

我的答案:在Mariadb(Afaik!)中尚未实现标记索引的选项。

更新:

Mariadb的语法不同,请参阅此参考: https://jira.mariadb.org /浏览/MDEV-7317

Problem is the word VISIBLE, remove it and it will work.
Index are visible by default.

Your question: "If i remove VISIBLE it works just fine, so why did mysql workbench decided to add visible?"

My answer: The option to mark index invisible is not yet implemented in MariaDB (afaik!).

Update:

The syntax for MariaDB is different, please see this reference: https://jira.mariadb.org/browse/MDEV-7317

悟红尘 2025-02-09 19:05:26

只是为了添加那些与MySQL Workbench一起使用Maria DB的人,您无需安装MySQL。您可以将“默认目标MySQL版本”从首选项更改为5.7或5.6,并且可见的关键字将由Workbench删除。

这是MySQL错误的链接
https://bugs.mysql.com/bug.com/bug.php?id=92269

Just to add to those who are using Maria DB with MySQL Workbench, you don't need to install mysql. You can just change 'Default Target MySQL Version' from Preferences to 5.7 or 5.6, and the VISIBLE keyword will be removed by workbench.
MySQL Workbench Preference Changes

Here is a link from mysql bugs
https://bugs.mysql.com/bug.php?id=92269

一抹苦笑 2025-02-09 19:05:26

我正在使用MySQL Workbench,并且有同样的问题。 偏好的变化,但它不起作用

解决方案:如果您导出向前工程器,则需要在另一个地方更改配置。

  1. 转到Model> 模型选项中的模型选项
  2. ,转到mySQL
  3. ,然后将“目标mysql版本”更改为5.6

I am using MySQL Workbench and have same problem. Change in the Preferences but it did not work.

Solution: If you export forward-engineer the model you need to change the configuration on another place.

  1. Go to Model > Model Options
  2. Inside the Model Options, go to MySQL
  3. Then change the "Target MySQL Version" to 5.6

example here

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