I'm trying to import an SQL file I have on a server and put it into the database. But I keep failing and it gives me an error.
This is the command and error I get:
try logging into mysql first
mysql -p username
enter your password:
mysql> source yourfile.sql;
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 use remote login to connect to the database (residing on AWS). I'd like to truncate one of my tables. But this command does not seem to work on bash:
mysql --login-path=remote --database=marketing 'truncate table my_test_table'
I get the message
ERROR 1044 (42000): Access denied for user 'mdb_updater'#'%' to
database 'truncate table pedram_test_table'
mdb_updater is my username on the database.
This is when I can successfully run mysqlimport and mysqldump using the same credentials.
MySQL cli treats positional argument as database name, pass statement you want to run with --execute option:
mysql --login-path=remote --database=marketing --execute 'truncate table my_test_table'
I am trying to restore mysql server from file.sql.
I am trying following command
mysql -u root -p database_name< file.sql
Enter password:
After entering password I am getting following error
ERROR 1067 (42000) at line 7183: Invalid default value for 'delete_time'
How to resolve this problem and recover my database back to servermysql
Solved by including following query in backup file
SET SQL_MODE='ALLOW_INVALID_DATES';
I'm moving my wordpress website to local for testing purpose.
I encountered the error below when I'm trying to import the .sql that I export from CPanel PHPMyadmin into local MYSQL Workbench.
FYI, I'm using MYSQL Workbench 6.0 and MYSQL Administrator 1.2.17
15:08:07 Restoring C:\Users\abc\Desktop\db.sql
Running: mysql.exe --defaults-extra-file="c:\users\abc\appdata\local\temp\3\tmpdemide.cnf" --host=localhost --user=root --port=3307 --default-character-set=utf8 --comments --database=db < "C:\\Users\\abc\\Desktop\\db.sql"
ERROR 1049 (42000): Unknown database 'db'
Operation failed with exitcode 1
15:08:08 Import of C:\Users\abc\Desktop\db.sql has finished with 1 errors
Apparently the export was done without specifying a database (schema), so you have to create it manually first before you can import the dump. MySQL Workbench allows to import a dump to a different (including a new) schema. You can specify this on the import page:
You looks like you have to create a database first
CREATE DATABASE db;
and then import your sql file.
I'm using WAMP Server in a local PC.
I'm trying to export a big database using MySQL console but its just not working. I always get a syntax error 1064
The queries I tried:
mysqldump -u USER -p DATABASE > backup.sql;
mysqldump -u USER -pPASSWORD DATABASE > backup.sql;
(of course I'm replacing USER, PASSWORD and DATABASE with real values)
I also tried some more similar queries but I'm getting the same syntax error every time.
Please help!!!!!
You should type this in your command prompt not in MySQL console.
mysqldump is an application not MySQL command.