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?
Related
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 get a couple of errors when trying to import a .sql dump file using the following command:
mysql -hIP -r -uroot -p db_test < C:\Users\Mark Hur\SQL Dumps\oct.sql;
The errors I get are as follows:
ERROR:
Unknown command '\U'.
ERROR:
Unknown command '\O'.
ERROR:
Unknown command '\P'.
ERROR:
Unknown command '\D'.
ERROR:
Unknown command '\S'.
ERROR:
Unknown command '\o'.
I guess these are due to the fact that I received a .sql dump from a database that resides on a linux machine. How do I import it then? I want to to import the data only
Since you are using a long filename with spaces it needs to be quoted:
mysql -hIP -r -uroot -p db_test < "C:\Users\Mark Hur\SQL Dumps\oct.sql"
Reference:
Long Filenames or Paths with Spaces Require Quotation Marks
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.
I am importing the follwoing mysql example
http://dev.mysql.com/doc/sakila/en/sakila-installation.html
when i try to import then i get this error on centos
SOURCE sakila-schema.sql;
ERROR 1548 (HY000) at line 446: Cannot load from mysql.proc. The table is probably corrupted
The seems to get imported
you should try this one and refer this link1 and link2
mysql_upgrade -u root -p
mysql_upgrade.exe -uroot -p --force
this is what I use in MySQL console (WAMP) (no password, as it is local)
mysql> mysql -u root -p dbase < table.sql
or this
mysql> mysql -u root -p dbase < C:\path\to\table.sql
this is what I get:
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 dbase < table.sql' at line 1
what may cause this problem?
The command you're using is meant to be run outside of the mysql shell. If you just exit out of the mysql shell and enter the same command, it should work.
OK - step by step - since, if someone is not used to it, any omission may get that "someone" lost.
remote nix server:
connect to mysql cli (command line interface) using e.g. Putty - type in: mysql -u user -pyourpassword
now you are connected to MySQL server and you can use e.g. LOAD INFILE command etc.
"exit" gets you back to "-bash" so you can use, e.g. database importing - just type: mysql -u root -p hmvc < table.sql
local WAMP - (setup: WAMP2.2 - Apache2.2.21 - MySQL5.5.20)
case I: using Windows "command prompt"
change directory to the one, where your mysql resides within WAMP root, e.g.:
C:\wamp\bin\mysql\mysql5.5.20\bin
connect to mysql cli:
mysql -u user -pyourpassword
now you are in, so you can use e.g. LOAD INFILE command etc.
"exit" gets you back to "C:\wamp\bin\mysql\mysql5.5.20\bin>" so you can use, e.g. database importing:
mysql -u root -p hmvc < table.sql
etc.
case 2: using mysql cli directly
WAMP offers a link to it in its tray icon command collection
link is called: MySQL console
it calls mysql server diretly by invoking C:\wamp\bin\mysql\mysql5.5.20\bin\mysql.exe
you can use all MySQL commands right away, like e.g. LOAD INFILE
you cannot import/dump database using this console
if you try to exit, MySQL console will do just that - it will exit (window gets closed)
I hope it will you some time.