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?
-
just a tip - if -h = localhost you don't need to specify it :)treyBake– treyBake2017年06月22日 09:15:27 +00:00Commented Jun 22, 2017 at 9:15
1 Answer 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.)
5 Comments
source path/to.file.sql
to import a filewhich 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?.bashrc
file to see how the $PATH
variable is set there. The file can be found in your home directory.bashrc
or .bashrc
over the whole xampp directory, but it didn't found any results..which
isn't a Windows command. And .bashrc
doesn't live in XAMPP - it lives in your ~ directory