Search

I'll be at


My Twitter

    Subscribe

    Recent entries

    No recent entries.

    Archives by subject

    Archives by date

    Sun Mon Tue Wed Thu Fri Sat
        1 2 3 4 5
    6 7 8 9 10 11 12
    13 14 15 16 17 18 19
    20 21 22 23 24 25 26
    27 28 29 30 31    
    20
    Mar

    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.

    » Continue reading "Dumping MySQL databases using Groovy"

    27
    Feb

    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!

    5
    Sep

    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.

    5
    Feb

    Running MySQL 5 as MySQL 4

    I use MySQL 5 as the default database for the work that I usually do.

    Today I came across a situation where I needed to test some MySQL 4 functionality.

    An option was to install MySQL 4 on another port (not the standard 3306).

    However, an easier option is to simply switch the MySQL mode.

    /* show the current sql mode */
    SELECT @@GLOBAL.sql_mode;

    /* change the settings to mysql 4 mode */
    /* the 'GLOBAL' keyword changes the mode for all clients that connect from that time on */

    SET GLOBAL sql_mode = 'NO_FIELD_OPTIONS,HIGH_NOT_PRECEDENCE';
    More information can be found at: http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html