24 Nov

Database Data to Download Variables

Gets data from a MySql database, splits the data into separate columns, then uses one column in a URL to download something – and uses other column to name the file thats downloaded

for i in $(mysql -u root Project_Madapp -sNe 'SELECT CONCAT(id,",",name) AS yo FROM City WHERE type="actual"'); do parts=(${i//,/ }); wget -O "${parts[1]}.csv" "http://localhost/student_allocation_csv.php?format=csv&city_id=${parts[0]}"; done

17 Mar

MySQL Database Backup/Restore

This command can be used to backup MySQL database.

mysqldump -u <User> -p <Database name> [<Table name>] > backup.sql

This command will create a file ‘backup.sql’ that will have all the data of the Database. The <Table name> is optional.

The database can be restored from such a dump using the command

mysql -u <User> <Database name> < backup.sql

Example

I backup all the task in Nexty using this command.

mysqldump -u root Apps_Nexty > nexty.sql

This will create a file called ‘nexty.sql’ – which can be restored using the command…

mysql -u root Apps_nexty < nexty.sql