I've tried to import a sql file (340Mb) with this statement:
mysql -u <user> -p --max_allowed_packet=1024M <database> < <file>.sql
And I get the error message after a while:
"ERROR 2006 (HY000) at line : MySQL server has gone away"
However if I use a MySQL manager like in this case Sequel Pro it works fine.
Can't understand why it doesn't work on the command line.
Related
I am trying to import mysql data dump to Maria DB with below command
mysql -u root -p --one-database new_db < data_dump.sql;
But I am getting below error
ERROR 1064 (42000): 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 'mysql -u root -p --one-database zapcheck <
zapcheck.sql' at line 1
I tried different combinations but nothing worked. Its not even telling what's the issue.
Please let me know the issue here or is there any other way I can import?
You can try the command below to import the file:
Note: Open the terminal where dump.sql is located
After opening the terminal:
//Skip this process if you have already created a database.
Mysql> create database newdb;
// Using the new created database
Mysql> use newdb;
// Importing the dump.sql file to newdb database
Mysql> source dump.sql
I'm trying to import a SQL database with mysql but not all of the rows are imported.
I'm using Ubuntu 17, mysql Ver 14.14, Distrib 5.7.26. First, I'm opening mysql with "mysql -u root -p", then "use db;", then "source [fullpath]/db.sql". Using this I get error message:
ASCII '\0' appeared in the statement, but this is not allowed unless option --binary-mode is enabled and mysql is run in non-interactive mode. Set --binary-mode to 1 if ASCII '\0' is expected
Unfortunately, I check if all tables are imported with "show tables;" and only 2 of 5 tables are imported. Furthermore, not all rows from second table are imported. I'm sure that there must be 5 tables and X number of rows.
To prevent this I used this command:
mysql -u root -p -h localhost -D db --binary-mode -o < [fullpath]/db.sql
But it gives me "ERROR at line 144: Unknown command '\�'."
I've also tried converting database to utf-8 format with this command:
sudo iconv -f utf-16 -t utf-8 db.sql > db_utf8.sql
Then tried using "source" command for "db_utf8.sql" but got this error:
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 42
Current database: db
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 43
Current database: db
ERROR 2006 (HY000): MySQL server has gone away
Please, does someone know what to do.
My coworkers are using the same file and everything is okay for them so maybe I'm not using the correct commands.
Edit: In some questions there are tips about (un)ziping the file but this one was never ziped or unziped.
It works now. I'm lucky that I have a coworker that tried the same and everything was okay. So I mysqldump'ed the database from that computer, moved the .sql file to my computer and tried to import this dumped file. Now everything works fine.
I am getting the following error when importing a file into MySQL on a Vagrant box
ERROR 2005 (HY000) at line 1: Unknown MySQL server host '-' (0)
I first run to extract the data
gunzip < /vagrant/app/data/bkup.sql.gz > /tmp/blu.sql
And then run the following to import
mysql -u root -proot blu < /tmp/blu.sql
This gives me the above errors related to an unknown host. I have now idea why this is occurring because the following works just fine and logs me in
mysql -u root -proot blu
The data I am importing is from a mysqldump so should be clean and not contain any errors.
Why is the host issue occurring and how can I solve it?
In the Command Line I created a database with:
create database mysql;
but when i try to upload a database file with the command:
mysql -u root -p database < dbdump.sql;
i receive a syntax error and i don't understand where i'm wrong
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 'mysql
-u root -p database < dbdump.sql' at line 1
confirm you're running the command from a shell and not from mysql.
I recall needing to be in mysql.exe directory when running such commands
remove the spaces around <. Ie, write mysql -u root -p database<dbdump.sql
i am trying to import sql file through putty
below are my details of DB
dbname - test,
password - test123,
username -utest,
i tried the below code
mysql -u utest -p test123 test< /home/path/public_html/file.sql
when i run this command i saw a error message
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 'mysql -u utest -p test123 test < file' at line 1
please suggest how to import sql file
Thank Sanjib
try this
mysql -utest -ptest123 test < /home/path/public_html/file.sql
and make sure that you run this command from your console not in mysql
if you are in mysql prompt than it would be somehting like this
mysql> use test;
mysql> source /home/path/public_html/file.sql;
OR
mysql>SET autocommit=0; source /home/path/public_html/file.sql; COMMIT;
You should run this command in your console, outside of the mysql tool.