0

I want to import a sql file to a database. I work on Windows 10 and I want to use the commands lines.

I tried this :

C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql -u {username} -p{password} db_test < F:\BDD\_databasetest\test.sql

But I have an error : "C:\Program not recognized"

So I tried to go by step :

cd C:\Program Files\MySQL\MySQL Server 8.0\bin
mysql -u {username} -p{password}
mysql db_test < F:\BDD\_databasetest\test.sql

But at the third command, I have this error :

ERROR: Unknown command '\B'. ERROR: Unknown command '_'. Outfile disabled.

For the command "mysql db_test < F:\BDD_databasetest\test.sql" I'm not sure about the "mysql" part so I tried both, with the same error. I tried to double the \ in the path, and I tried to used '' and "" for the path, without succes.

PS : english is not my native language. I clarifications are needed, don't hesitate.

asked Feb 9, 2022 at 21:19
2
  • 1
    put the path in double-quotes, that may help. "C:\Progam Files...." Commented Feb 9, 2022 at 21:21
  • 1
    it worked ! thanks ! Commented Feb 9, 2022 at 21:31

2 Answers 2

1

So as the OP confirmed, double-quoting the Windows path helped: "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql" -u {username} -p{password} db_test < F:\BDD\_databasetest\test.sql

The error message 'error : "C:\Program not recognized"' suggest that it is not a mysql-related issue.

answered Feb 10, 2022 at 14:49

Comments

0

with the first mysql commad you can't to the database so the mnexe must be a sql command

For both options the database has to exit already, if in the sql is no CREATE DATABASE ...

use

mysql -u root -p db_test < D:\BDD\_databasetest\test.sql

or

mysql -u {username} -p{password}
mysql> use db_test ;
mysql> source D:/BDD/_databasetest/test.sql;

Note in the last command the / instad of \

answered Feb 9, 2022 at 21:34

Comments

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.