I have MySQL database version 5.1.36, that came with WAMP installation. I used it for development purposes on Windows XP SP3, and it has some data in it, which is cyrillic, and the collation for all of those tables/columns is set to utf8_general_ci.
Now the time has come to move this database to pseudo-production environment, which is on Debian Lenny. Version of MySQL here is 5.0.51a.
I tried the following:
I exported the databse with data from phpmyadmin on Windows and saved the .sql file to be in UTF8.
Then, I transferred it through WinSCP (both with default and binary transfer settings) to Linux machine.
I created the database through command line: mysqladmin -u root -p create nbs
Finally, I tried to create tables and fill the data:
mysql -u root -p --default-character-set=utf8 nbs < NBS_utf8_1.sql
However, this is where I'm getting the error, like:
ERROR 1064 (42000) at line 1: 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 '
CREATE TABLE IF NOT EXISTS `history_members` (
`id` int(11) NOT NULL AUTO_' at line 1
Something is messed up with encoding, I suppose... but don't know how and where. I think I read in the similar question on SO that binary mode for text transfer will only change the line breaks CRLF to LF (don't know if this is correct...). What am I missing here?
Thanks.
For this particular case, the problem was solved with the following modifications:
1) I set initial collation while creating the target database to utf8_general_ci,
2) I transferred the file with text mode through WinSCP,
3) I added SET NAMES 'utf8' COLLATE 'utf8_general_ci'; to the top of sql dump.
Here is what I found using PhpMyAdmin for a rough SQL import using remote shell :
/*!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 utf8mb4 */;
Related
im trying to upload my first wordpress website. Im using the local wordpress.org php my admin and the php my admin from 000webhost. Ive researched this a a lot here and changed all the settings people were saying from utf8mb4 to utf8 but it only caused more errors. I changed everything back to what it was (at least i think so and the error is the same as the beginning now). Anyone knows how i can get around this and import my db to 000.webhost with no errors? the Error is SQL query:
/*!40101 SET NAMES utf8mb4 */;
and
MySQL said: Documentation
1115 - Unknown character set: 'utf8mb4'
1) The first: If you can control ssh server. Please update mysql version. Your mysql too old. Maybe < 5.5.3.
2) The second: If you can't access ssh. Try to export your database with Mysql version 4.0.
With command line mysqldump --compatible=mysql40 -u user -p DB > dumpfile.sql
With web access phpmyadmin -> Select Database -> Export -> Custom - display all possible options -> Format-specific options ->
Database system or older MySQL server to maximize output compatibility with: Select MYSQL40.
Change content file .sql you exported
/*!50003 SET character_set_client = utf8mb4 */ ;
to utf8 only.
And replace by Ctrl H in Sublime change all from utf8mb4 => utf8
Hope this helps.
Just modify this into mysql Database.
wrong that modify ..... /*!40101 SET NAMES utf8mb4 /;
now corrected ..... /!40101 SET NAMES utf8 */;
just erase .... mb4 ....
its work now
I used this exported DB to move from one HostGator (call it A) account to another (call it B) about a year+ ago. I'm cleaning up a hacked website mess on HostGator account B so I'm restoring this website from my original files (from HostGator A) on my computer to another HostGator (call it C) account.
I vaguely remember having an issue when I tried to import them to HostGator B - and the chat tech and I came to the conclusion that when I was exporting from HostGator A my computer was saving it but also opening it in NotePad and from there I was saving it to the directory I wanted. I seem to recall him saying something about a space or character or something. I uploaded the .sql file and he fixed it and imported it.
I've been on chat tech with HostGator today for going on 3 hours. :-\
Error:
SQL query:
phpMyAdmin SQL Dump
-- version 3.5.5
-- phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Apr 30, 2014 at 12:53 PM
-- Server version: 5.5.33-31.1
-- PHP Version: 5.4.23
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
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 'phpMyAdmin SQL Dump
-- version 3.5.5
-- phpmyadmin.net
--
-- Host: lo' at line 1
Here are the first few lines:
-- phpMyAdmin SQL Dump
-- version 3.5.5
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Apr 30, 2014 at 12:53 PM
-- Server version: 5.5.33-31.1
-- PHP Version: 5.4.23
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: <code>hosting_NameChangedForThisPost</code>
--
--
Your query is missing the comment delimiter -- on the first line. This is why it's telling you there's an error "near 'phpMyAdmin SQL Dump". Make sure when you're copying and pasting that you're not missing the first couple of characters.
in this case, Instead of importing teh .sql. Go to your phpmysql and click on SQL.
Then open your .sql file you want to import in notepad. copy and paste .
In this way you will avoid the importing process removing the comment delimiter -- on the first line. T
I know that many had this problem, and solved it, but even with their solutions, I've gotten no luck..
I tried exporting my localhost phpadmin to my webserver, and i got:
SQL query:
/*!40101 SET NAMES utf8mb4 */;
MySQL said: Documentation
#1115 - Unknown character set: 'utf8mb4'
Local phpmyadmin:
Server type: MariaDB
Server charset: UTF-8 Unicode (utf8)
Version: 4.5.2
Webhost phpmyadmin:
Version: 2.11.4
Solved it. Downloaded MYSQL workbench, logged into my local database, and exported it from the program. Then, i simply imported the file, and it worked!
Im getting an error
SQL query:
-- --------------------------------------------------------
--
-- Table structure for table `wp_commentmeta`
--
DROP TABLE IF EXISTS `wp_commentmeta`;
MySQL said: Documentation
#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 '-------------------------------------------------------
--
-- Table structure f' at line 1
This seems to happen on random tables. I remove the preceding mysql block and it will continue a few more tables before stopping with a similar error. I think it might be something to do with basic syntax.
Using phpmyadmin to import. And the original database is running MYSQL 5.5.42-37.1-log
The new database is running MYSQL 10.0.20-MariaDB
On the export screen on the original database phpmyadmin I clicked Custom - display all possible options and under Format-specific options: I unticked Display comments (includes info such as export timestamp, PHP version, and server version)
This removed all comments from the sql dump. I also had to remove the following lines from the top of the file.
/*!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 */;
This solved all my problems and it imported correctly.
I have taken a dump from my mysql database on my own server (version 5.0.67) and I have tried to import it to my other database (version 5.0.54). However, I get the error:
ERROR 1193 (00000) at line 23: Unknown system variable 'character_set_client'
I think it refers to this part:
SET #saved_cs_client = ##character_set_client;
SET character_set_client = utf8;
I have tried removing all the above lines but that made the error worse:
ERROR 1064 (00000) at line 23: 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 'DEFAULT CHARSET=latin1 COMMENT='InnoDB free: 10240 kB; (`member
Any help would be greatly appreciated.
UPDATE
I used the compatibility option like so but when importing I still get the same error!? WTF
mysqldump -u root -p dbname --compatible=mysql40 > mrdb.sql
If you're using mysqldump to do the data dump, then there's a --compatibility option which you can set to some earlier version. 5.0.54 is kinda buggy so upgrade that beast when you have a chance.
If you install phpMyAdmin, you can use it to export the database. When you click 'Export' you will see an option for 'compatibly mode' where you can select MySQL 4 and 3.
Mightn't the order of the variables be wrong? Just a guess.
SET character_set_client = utf8;
SET #saved_cs_client = ##character_set_client;