1

I have been building a Drupal 7 site on my Mac. Using PHPMyAdmin, I have exported a sql dump of the database. When I upload this sql file to my host, I get the following error message:

There seems to be an error in your SQL query. The MySQL server error output below, if there is any, may also help you in diagnosing the problem

ERROR: Unknown Punctuation String @ 280
STR: =,
SQL: 

-- --------------------------------------------------------

--
-- Table structure for table `themekey_properties`
--

CREATE TABLE `themekey_properties` (
  `id` int(10) UNSIGNED NOT NULL,
  `property` varchar(255) NOT NULL DEFAULT '',
  `operator` varchar(2) NOT NULL DEFAULT=,
) ;

SQL query:

-- -------------------------------------------------------- -- -- Table structure for table `themekey_properties` -- CREATE TABLE `themekey_properties` ( `id` int(10) UNSIGNED NOT NULL, `property` varchar(255) NOT NULL DEFAULT '', `operator` varchar(2) NOT NULL DEFAULT=, ) ;

MySQL said: Documentation

#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 '=,
)' at line 10 

How would I go about debugging this? I have searched extensively, but not found any websites that explain how.

The website functions perfectly on my localhost. I have done this process hundreds of times before, and never had any problems.

I seem to have this exact problem when transfering other sites from my Mac to my host, so I am not sure if it is a global problem. The affected sites all use themekey module which is referenced in the error message, but I can't find anything online which indicates why themekey would be causing the problem.


Updated.

I followed the @Erin McLaughlin's answer, but now I get the following error:

CREATE TABLE `themekey_properties` (
  `id` int(10) UNSIGNED NOT NULL,
  `property` varchar(255) NOT NULL DEFAULT '',
   `operator` varchar(2) NOT NULL DEFAULT '=',
)
MySQL said: Documentation

#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 ')' at line 5

Updated.

I followed @Erin McLaughlin's second suggestions, but now I get the following error:

SQL query:


INSERT INTO `themekey_properties` (`id`, `property`, `operator`, `value`, `weight`, `theme`, `enabled`, `wildcards`, `parent`, `module`) VALUES
(1, 'themekey_compat:module_system_triggers_theme', '=', 'static', 5, 'default', 1, 'a:0:{}', 0, 'themekey'),
(2, 'drupal:path', '=', 'user/#/edit', 2, 'default', 1, 'a:0:{}', 0, 'themekey')
MySQL said: Documentation

#1054 - Unknown column 'value' in 'field list'
  • 1
    The answer below is correct, but if the question philosophically is "How do I debug this?" then you've already accomplished that. If the end result of debugging is to find the source of the error, well, MySQL reported that there was a syntax error, the line number, and the location of the error. Debugging can take you that far, but you still need enough domain knowledge to be able to identify the bug, and that's no longer a process question. Until then, "Ask about the problem on Stack Exchange" is a perfectly good approach. – Les Lim Oct 22 '15 at 23:36
5

It has got to do with the line:

`operator` varchar(2) NOT NULL DEFAULT=, 

It's because the equals sign isn't surrounded with a space and then quotes, which is breaking everything. If you want to have = be the default operator, that line needs to be:

 `operator` varchar(2) NOT NULL DEFAULT '=',
  • thanks, but now I get a new error (see original post). – big_smile Oct 24 '15 at 16:30
  • 1
    This is just a guess, but try removing the final comma? – Erin McLaughlin Oct 24 '15 at 21:03
  • I still get an error. Do you think it might be something else that is not related to the database contents. Although I'm not sure what it could be!! – big_smile Oct 25 '15 at 13:18
  • 1
    Erin answered the original question. A new question should go into a new question. – greggles Oct 27 '15 at 12:18
1

Erin's answer is correct to the original question, so I have marked it correct. However, the problem had nothing to do with importing the mysql code. It was to do with how I was exporting the mysql in the first place.

I was simply using PhpMyAdmin's built in export tools, but for some reason, this was creating errors.

I solved the problem by using mysql commands in the command line.

If anyone has problems where the database's don't import properly, then it might be worth exporting them using the method below:

  1. Use this command in the command line:

    mysqldump -u DATABASEUSER -p'PASSWORD' DATABASENAME > dump.sql

In this command, you mustn't have a space after -p. So your command might look like this:

mysqldump -u host_mary -p'pass123' marywebsite > dump.sql 
  1. Create new databases. You can do this in PhpMyAdmin as normal.

  2. Finally, import code into the new databases using this command

    mysql -u DATABASEUSER -p'PASSWORD' DATABASENAME < dump.sql

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.