Run this query from .Bat

1

Hello, would you like to help me? Thank you, I have the following query:

CREATE DATABASE almacen;

which I want to execute through a Bat, I thought of something like this:

@echo off
echo --test >crear.sql
echo CREATE DATABASE almacen1;>>crear.sql
C:\xampp\mysql\bin\mysql.exe -h localhost -u root -ptresa456 < "crear.sql"

but it does not run, how can I run it from batch?

    
asked by Juan Carlos Villamizar Alvarez 18.06.2018 в 08:44
source

2 answers

1

Try to pass the SQL in the same line, so you avoid that the mysql.exe can not find the file

C:\xampp\mysql\bin\mysql.exe -h localhost -u root -ptresa456 -e "CREATE DATABASE IF NOT EXISTS almacen1;"
    
answered by 19.06.2018 / 01:23
source
1
C:\xampp\mysql\bin\mysql.exe -h localhost -u root -ptresa456 -e "create database almacen1"
    
answered by 19.06.2018 в 01:23