Syntax error in importing .sql file to fresh database - mysql

I have a perfectly working database and currently want to copy that to another server machine running CentOS7 VM. In the original server, I used phpMyAdmin to export .sql file for the database with "Quick setting" as shown below:
Then I uploaded the .sql file to the VM through FTP. Everything was still good until I ran the cmd mysql -u root new_db < some.sql. The error said:
ERROR 1064 (42000) at line 2553295: 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 '<br />
<b>Fatal error</b>: Maximum execution time of 300 seconds exceeded in <b' at line 16
I'm 100% sure that the db worked without issues in the original server, and I haven't touched any source code in the .sql file. What may the near <br /> warning suggest? Thanks a lot for any suggestions and help.

Related

Error code: 1064 in MySQL when create SOURCE?

I want to use my SQL'book_data2' file from the desktop E drive as a 'SOURCE'. But I am getting an error code 1064 in MySQL workbench. Could you help me for that issue? I am giving the code and action output below.
Code:
SOURCE E:\DataPractice\Practice\book_data2.sql;
Action Output:
Error Code: 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 'SOURCE E:\DataPractice\Practice\book_data2.sql' at
line 1 0.000 sec
There are a number of commands that are supported by the mysql client (that is, the command-line client, not MySQL Workbench), but they are parsed in the client, not sent to the server as SQL statements. The MySQL Server does not recognize these commands.
It can be confusing, but remember both the client and the server may process commands. You just have to read the documentation to learn which commands are in the list of client-only commands:
https://dev.mysql.com/doc/refman/8.0/en/mysql-commands.html
(Except USE, which is recognized by both mysql client and server, just to make sure there's an exception to every rule!)
If you want to use MySQL Workbench to "source" an SQL file, in other words load a file, read the SQL commands in that file, and execute them, Workbench does support this action, but they call it Data Import/Restore. It's documented here: https://dev.mysql.com/doc/workbench/en/wb-admin-export-import-management.html

Error when importing SQL Dump from an equal source

I need to sync the database of a live server to our development system, so I did create a dump with mysqldump, zipped it, piped it to the other server, unzipped it and wanted to import said dump. Quite the no-brainer, right?
mysql -uroot -pPASS DBNAME < dump.sql
This is where the error occurs.
ERROR 1064 (42000) at line 270: 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 ''{\n \"parsed_parameters\":91,\n \"max_result\":[\n {\"time\":5076987.68,\"outp' at line 1
Edit: This does also happen if I use the MySQL CL with source.
This is odd, as every technical aspect of the live system is equal to the dev system, the only difference is the backend and the data in the database.
So I am wondering why I can't insert this dump despite having a comparable database with the same schema as the source.
Edit: Just for testing I created an empty database and got the same error.
But the thing I don't get is, that the process successfully imported exactly 500 rows with similar values. Maybe there is something with this 500 rows threshold?
You need to login first using below cmd
mysql -u <your-username> -p
After click enter it will asking for password please enter it, then using below you can import dump in specific schema.
use <schema-name>;
source database/filepath/dump.sql;
If you have not created schema then create it using below cmd first after login.
create schema your_schema_name;

How to find the file causing a mysql syntax error

I'm a newbie. I just set up Ubuntu to run on my Chromebook (via Crouton) last week and am currently in the process of setting up several Wordpress sites on localhost. I successfully installed a new Wordpress site yesterday, and I'm able to access the frontend and backend of the site via localhost no problem.
Today I wanted to create another Wordpress site. But when I try to create a new database in mysql using Terminal, I get the following error:
mysql> CREATE DATABASE;
ERROR 1064 (42000): 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 1
How do I figure out which file is causing the syntax error? I checked php.ini, which I edited yesterday, but line 1 looks fine.
The right way to use Mysql CREATE DATABASE statement
CREATE DATABASE my_db;
To my belief, you are missing the database name:
mysql>CREATE DATABASE database_name;

Getting Error 1064 when trying to import db file

ERROR 1064 (42000) at line 33892 in file: 'contarproducts.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 ''\r\n \r\n
How can I resolve this issue?
Your help will be much appreciated.
1) You have this tagged as MySQL but then you seem to be running MariaDB, those aren't the same thing.
2) If there's an error in your SQL (which is what this is saying) and this SQL file was exported from the database it seems as though copying or moving the file cut it off and it didn't finish copying. If the file doesn't get fully copied and the end of the file looks like SELECT * FRO then that will be a syntax error.
Try re-exporting the file before importing it again.

Import multiple large sql dump mysql

I want to import several .sql files into database using source command (mysql command line). But when I get this error:
source E:\Progs\Backups\DBs\file01.sql
ERROR:
Unknown command '\P'.
ERROR 1064 (42000): 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 'sourc
e E:\Progs' at line 1
....
I used source command to import large files hundreds times but now I can not understand what I'm doing wrong. This is my system(I'm using XAMPP (Basis Package) version 1.7.3 :
Windows 7x64
MySQL 5.1.41 (Community Server) with PBXT engine 1.0.09-rc
Any help would be appreciated.
Thanks!
Edit:
I tried this one, but same error:
source 'E:\Progs\Backups\DBs\file01.sql'
MySQL sees the \P in E:\Progs as a command. Because that command does not exist, it complains.
Forward slashes are understood in many cases. Try:
source E:/Progs/Backups/DBs/file01.sql