How to execute remote .sql at mysql command line

I have a file located in E:\Backup\sql\mybackup.sql

I enter the command line and I am on the command line mysql>

How to restore mydatabase?

I thought it

mydatabase > "E:\Backup\sql\mybackup.sql"

but he keeps talking

unknown team on each \

+3
source share
4 answers

Run it like this:

mysql -h localhost -u root -p mydatabase < "E:/Backup/sql/mybackup.sql"
+6
source

In addition to the escaping issue, your redirect statement does not work correctly. Assuming you are using a shell that supports STDIN redirection, you could try:

mysql mydatabase < E:\\Backup\\sql\\mybackup.sql
+3
source

\ . \\, \.

Windows . . , :

mysql > C:/Documents and Settings/ /My /spike_loadingMySQLDB/createTables.sql;

As stated in the comment at https://dev.mysql.com/doc/refman/5.7/en/mysql-batch-commands.html

0
source

Team

source "E:/Backup/sql/mybackup.sql"

First specify the database ( use dbname) - if it is not specified in the backup file

0
source

All Articles