1

I have a large .sql. file and I'm trying to import it by using command line. Im going to the right directory and typing:

mysql -u rookie -h 127.0.0.1 -p database < file.sql

And somehow it gives me an error:

Mysql is not recognized as an internal or external command

Why?

Bizley
18.1k6 gold badges53 silver badges62 bronze badges
asked Jun 22, 2017 at 8:51
1
  • just a tip - if -h = localhost you don't need to specify it :) Commented Jun 22, 2017 at 9:15

1 Answer 1

1

Linux can't find the binary mysql.

Quick fix:

Check the location of the mysql binary with the following command: which mysql.

You will then see output similar to the following: /usr/bin/mysql

Rewrite your command as:

/usr/bin/mysql -u rookie -h 127.0.0.1 -p database < file.sql

Longterm solution:

Add mysql to your $PATH environment variable like so:

export PATH=$PATH:/usr/bin/mysql (of course put your own mysql path at the end here.)

answered Jun 22, 2017 at 9:04

5 Comments

+1 another solution worth adding - if you run mysql in terminal you can use source path/to.file.sql to import a file
Why when I'm writing which mysql it says that which is not recognized as an internal or external command. I'm writing the command into my project root directory. Is it ok?
You should check your .bashrc file to see how the $PATH variable is set there. The file can be found in your home directory.
I've tried to search bashrc or .bashrc over the whole xampp directory, but it didn't found any results..
@user7435747 that's because PdC is suggesting a solution for Linux - which isn't a Windows command. And .bashrc doesn't live in XAMPP - it lives in your ~ directory

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.