简体   繁体   English

Phpmyadmin 导入 sql 文件错误“... for the right syntax to use near '1'”

[英]Phpmyadmin Importing sql file error “… for the right syntax to use near '1'”

I used phpmyadmin in xampp to import a sql file to generate a database for a tutorial course, and got this error:我在 xampp 中使用 phpmyadmin 导入 sql 文件以生成教程课程的数据库,并得到此错误:

"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 '1'". “您的 SQL 语法有错误;请查看与您的 MariaDB 服务器版本相对应的手册,以了解在 '1' 附近使用的正确语法”。

Database server: Server version: 10.4.13-MariaDB数据库服务器:服务器版本:10.4.13-MariaDB

I searched this forum, it seems that there is a lot of similar questions, but there is no solution that can fix my problem.我搜索了这个论坛,似乎有很多类似的问题,但是没有可以解决我的问题的解决方案。

My questions:我的问题:

  1. What does "near '1'" mean? “接近'1'”是什么意思? What is wrong with line 8?第 8 行有什么问题?

  2. Is there a way to fix the whole sql file for importing without errors?有没有办法修复整个 sql 文件以便导入而不会出错? (I can provide the sql file if anyone is available to help. By the way, I don't know how to attach the sql file here.) (如果有人可以提供帮助,我可以提供 sql 文件。顺便说一句,我不知道如何在此处附加 sql 文件。)

Here is the portion of sql file that the errors points to:这是错误指向的 sql 文件的部分:

ENGINE=InnoDB AUTO_INCREMENT=764 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='帖子评论的互动数据表,记录了一条评论的点赞,分享,评论的数量';
CREATE TABLE `table_feeds_comment` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `comment_count` int(11) DEFAULT NULL,
  `comment_id` bigint(20) DEFAULT NULL,
  `comment_text` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
  `comment_type` int(11) DEFAULT '1',
  `create_time` bigint(20) DEFAULT NULL,
  `height` int(11) DEFAULT NULL,
  `image_url` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `item_id` bigint(20) DEFAULT NULL,
  `like_count` int(11) DEFAULT NULL,
  `video_url` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `width` int(11) DEFAULT NULL,
  `user_id` bigint(20) DEFAULT NULL,
  PRIMARY KEY (`id`)

这是phpmyadmin中的屏幕截图

Been a while I worked with PHP though but here's my submission below:虽然有一段时间我与 PHP 合作,但这是我提交的以下内容:

comment_type int(11) DEFAULT '1' comment_type int(11) 默认 '1'

You specified comment_type as an integer type but you supplied a DEFAULT that is of a char type.您将 comment_type 指定为 integer 类型,但您提供了一个 char 类型的 DEFAULT。 You may need to change it to 1 without the quotes.您可能需要在不带引号的情况下将其更改为 1。

I removed the following part of the sql file which is at the beginning, and imported it successfully.我删除了开头的sql文件的以下部分,并成功导入。 But I still don't know why these syntaxes have created the problem.但我仍然不知道为什么这些语法会产生问题。 Are these syntaxes not compatible with my MYSQL version?这些语法与我的 MYSQL 版本不兼容吗? In what version of MYSQL are these syntaxes are used?在哪个版本的 MYSQL 中使用了这些语法?

/*
MySQL Backup
Database: serverdemo
Backup Time: 2019-11-29 14:10:46
*/

SET FOREIGN_KEY_CHECKS=0;
DROP TABLE IF EXISTS `serverdemo`.`hibernate_sequence`;
DROP TABLE IF EXISTS `serverdemo`.`table_feed_comment_like`;
DROP TABLE IF EXISTS `serverdemo`.`table_feed_comment_ugc`;
DROP TABLE IF EXISTS `serverdemo`.`table_feeds_comment`;
DROP TABLE IF EXISTS `serverdemo`.`table_hot_feeds`;
DROP TABLE IF EXISTS `serverdemo`.`table_tag_list`;
DROP TABLE IF EXISTS `serverdemo`.`table_tag_list_like`;
DROP TABLE IF EXISTS `serverdemo`.`table_ugc`;
DROP TABLE IF EXISTS `serverdemo`.`table_ugc_like`;
DROP TABLE IF EXISTS `serverdemo`.`table_user`;
DROP TABLE IF EXISTS `serverdemo`.`table_user_banner`;
DROP TABLE IF EXISTS `serverdemo`.`table_user_follow`;
DROP TABLE IF EXISTS `serverdemo`.`table_watch_history`;

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

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