MySQL 导入mysql时出现语法错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16449996/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
syntax error on import mysql
提问by user1973003
this is my sql i want to use in my database but i have a problem with that:
这是我想在我的数据库中使用的 sql,但我有一个问题:
-- phpMyAdmin SQL Dump
-- version 3.5.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Dec 27, 2012 at 07:12 PM
-- Server version: 5.5.19
-- PHP Version: 5.3.8
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `lol`
--
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE IF NOT EXISTS `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(48) CHARACTER SET utf8 NOT NULL,
`password` varchar(48) CHARACTER SET utf8 NOT NULL,
`email` varchar(255) CHARACTER SET utf8 NOT NULL,
`sid` varchar(32) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1020 ;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `username`, `password`, `email`, `sid`) VALUES
(1001, 'Larry', 'md5passhere', ' @', ''),
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
when i want to import that into database i have this error:
当我想将其导入数据库时,出现此错误:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */' at line 8
i don't know how to fix that with search on web i cannot find useful thing about my problem so you think how i can resolve that problem?
我不知道如何通过网络搜索解决这个问题,我找不到关于我的问题的有用信息,所以您认为我如何解决该问题?
采纳答案by Niels
At the end of you INSERT INTO users
you have a ,
Which does not belong there, and also you might want to remove the other ;
after the /* */;
?
最后INSERT INTO users
你有一个,
不属于那里的,而且你可能想;
在/* */;
?
Update
更新
-- phpMyAdmin SQL Dump
-- version 3.5.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Dec 27, 2012 at 07:12 PM
-- Server version: 5.5.19
-- PHP Version: 5.3.8
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT; */
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS; */
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION; */
/*!40101 SET NAMES utf8 */;
--
-- Database: `lol`
--
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE IF NOT EXISTS `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(48) CHARACTER SET utf8 NOT NULL,
`password` varchar(48) CHARACTER SET utf8 NOT NULL,
`email` varchar(255) CHARACTER SET utf8 NOT NULL,
`sid` varchar(32) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1020 ;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `username`, `password`, `email`, `sid`) VALUES
(1001, 'Larry', 'md5passhere', ' @', '');
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT; */
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS; */
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION; */
回答by br araujo
Remove the commented parts of your SQL Script, specially the ";"
删除 SQL 脚本的注释部分,特别是“;”