1

I was wondering if it's possible to import a mysql database using the mysql command line.

Most solutions give mysql -u root -p nameofdatabase < mysqlfile.sql

I was wondering if it's possible to do this inside the mysql commmand line, instead of passing arguments to the executable.

If I just do

 mysql> mydatabase < mysqlfile.sql;

That just doesn't work. Thank you.

1 Answer 1

1

Did you mean something like this?

mysql> use nameofdatabase;
mysql> SET autocommit=0 ; source the_sql_file.sql ; COMMIT ;

The important part, what you were looking for, is the source command. I usually switch off autocommit because of the execution time.

Sign up to request clarification or add additional context in comments.

1 Comment

Is the source command doing the same thing (importing) as < in command like this, mysql -u root -t < employees.sql ?

Your Answer

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.