2

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.

enter image description here

Please let me know the issue here or is there any other way I can import?

9
  • 3
    mysql is a shell command, you don't use it inside the mysql program. Commented Sep 23, 2021 at 4:01
  • @Barmar ahh I see.. now its showing the error if I run outside maria db. Where I am supposed to keep the dump file? Its not able to access it Commented Sep 23, 2021 at 4:10
  • @Barmar Or how can I specify the complete path? Commented Sep 23, 2021 at 4:12
  • What error is it showing now? Commented Sep 23, 2021 at 4:14
  • @Barmar getting this error The system cannot find the file specified.. When I run mysql -u root -p --one-database new_db < data_dump.sql; Commented Sep 23, 2021 at 4:17

1 Answer 1

9

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
Sign up to request clarification or add additional context in comments.

4 Comments

What is zapcheck?
Did you read the error message? The problem is that he's trying to run the command as a SQL query.
Getting this error while running second command -> ERROR: Failed to open file 'zapcheck.sql', error: 2. File path is not proper I guess. Where I am supposed to keep the dump?
Now it worked after directing to correct path. Thanks

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.