How to Perform an Automatic BackUp in MySQL

2

This script I have advanced but I do not know why it does not work for me, do not place the error if someone can help me?

@echo off
mysqldump -h localhost  -u root  -p Dotado256   sixstar_almacen  >  AlmacenBeta _ 19082018.sql
Pause

Use Xammp the database is (sixstar_almacen) Obvious without parentheses, I want that when I click this Bat I do the .SQL on my PC but it does not come out

    
asked by Juan Carlos Villamizar Alvarez 19.05.2018 в 22:49
source

1 answer

1

In short notation: (check spaces well)

@echo off
mysqldump -h localhost -u root -pDotado256 sixstar_almacen > AlmacenBeta_19082018.sql
Pause

Extended Notation ( --result-file is for windows not to save the file in UTF-16 or replace the \n with \r\n )

@echo off
mysqldump --host=localhost --user=root -password=Dotado256 --databases sixstar_almacen --result-file=AlmacenBeta_19082018.sql
Pause

You may have to change localhost by 127.0.0.1 if the user's permissions are by ip and not by wildcard.

If the output file includes spaces, enclose it in double quotes:

"AlmacenBeta 19082018.sql"

Usually Xampp installs the mysql binaries in

C:\xampp\mysql\bin 

So an example with that route would be:

C:\xampp\mysql\bin\mysqldump.exe -h localhost -u root -pDotado256 sixstar_almacen > "AlmacenBeta_19082018.sql"

the sql file is going to record it where the batch is executed (if the desktop is going to leave it there) so you can also put the full path to the wave file: "C:\AlmacenBeta_19082018.sql" .

  • In several versions of windows (you should try typing a SET in a command line CMD to see if it exits) you can put "%USERPROFILE%\Documents\AlmacenBeta_19082018.sql" to be recorded in your user's documents folder ( Documents it can be Mis Documentos in Spanish versions but I think there is a symlink that takes it the same)
answered by 20.05.2018 / 01:39
source