ehowton (ehowton) wrote,
ehowton
ehowton

mysql> ?


I am decidedly NOT a database administrator. So when I needed to find an errant string within a database and replace it with something else, SELECTING text from ROWS within TABLES was simply not in my area of expertise. Thankfully, dude Dave Burke of NIXMASH does there what I like to do here - leave himself notes, and maybe help a brother out.

Because I had specifically searched for use sed to find and replace database in hopes I could find something remotely usable using regex (I'd already grep'd the variable from the strings command so I knew it was there somewhere), Mr. Burke shows us how to turn a database into a flat-file, then back into a database, easily making regex changes in between.


  • Create a mysqldump of the database

    • #mysqldump -u root -p database_name > /tmp/database_name.sql

  • Manipulate your strings with sed

    • #sed `s/url\.com\/subdirectory_to_remove/url\.com/g`

  • Re-import the database using mysql

    • mysql -u root -p database_name < /tmp/database_name.sql



Thanks, Dave!
Tags: linux, mysql
Subscribe

  • Game Face

    I awoke after a blissful 10-hour slumber, ensconced in my flannel cocoon on an unseasonably cool morning. I tucked my arms close, pulling the…

  • Query a List of Hostnames to Create /etc/hosts File

    for x in `cat hostnames`; do echo $(nslookup $x | grep -e Address | sed -n 2p | sed -r 's/.{9}//') $x ; done >> hostfile Or, add SHORTNAME…

  • Speeding in Reverse, Pt. VII

    Two dreams, a week apart (or there about). First dream, I was Mormon. It was weird to be sure, but the girls were hot and I was working the room…

  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 2 comments