Entries Tagged as 'MySQL'

Dumping MySQL databases using Groovy

Today I needed to use Groovy to create a dump of all MySQL databases on the MySQL server running on my local machine.

So I looked at my earlier blog entry on how to dump MySQL databases using the "mysqldump" command.

So when I issued the command create a dump from console, the contents of the database are dumped to a sql file as expected.

// Works in command line
mysqldump --all-databases -u [username] -p[password] -C > alldatabases.sql

As you might know, it is fairly straight-forward to execute shell commands from Groovy. You simply put the command in quotes and call the execute() method.

However, when I issued the same command using Groovy, the command did not work... well, at least not at first.

Read more...

Backing up and restoring all MySQL databases

This is another one of those "lest I forget" type of blog entries. There are times one has to migrate all MySQL databases to another box (like now when I have to give my Mac for repair and I have to work in a Windows machine!) This is the command to backup all MySQL databases

mysqldump --all-databases -u [username] -p -C > alldatabases.sql

Replace [username] with the name of the MySQL user. I used "root" as it has access to all databases. This will create a file called "alldatabases.sql" containing all the SQL commands for creating the databases and inserting data into them. To restore from this SQL file, use this command

mysql -h localhost -u [username] -p < alldatabases.sql

Now, I won't have to rummage through the big wild web for this!

Adding the PATH variable on Mac OSX

This is another one of those blog entries where I want to blog for the sake of remembering tedious details...

The issue that I was facing was how to add a directory to the PATH environment variable on my Mac.

I wanted to add a path to MySQL install. So I'll use that example. The following command in a Terminal window created my .bash_profile file. If the file already exists, it would have added to that file.

echo 'export PATH=/usr/local/mysql/bin:$PATH' >> ~/.bash_profile

The PATH information is stored in /Users/username/.bash_profile file.