ehowton: (Default)

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:
ehowton: (Default)

Because I seem to buy, build, and lose/destroy/rebuild/re-purpose a stupid number of VPS, I need a placeholder for a quick and dirty checklist. Well, that and every single postfix HOWTO is seemingly either written by a mail engineer, or a 10 year-old. It took me far too long to get only the pieces I needed (have the sever send only, and send through gmail) filtered from all the other fancy-schmancy mail minutia and the not-really-working-after-all HOWTOs.


new_vps:~#

USER ACCCOUNTS

new_vps:~#useradd ehowton
new_vps:~#passwd ehowton
new_vps:~#visudo
%wheel ALL=(ALL) ALL

new_vps:~#vi /etc/ssh/sshd_config
PermitRootLogin no

new_vps:~#service sshd restart

O/S UPDATE

new_vps:~#zypper up

DATABASE

new_vps:~#zypper install mariadb
new_vps:~#service mysql start
new_vps:~#mysql -u root
mysql> UPDATE mysql.user SET Password = PASSWORD('newpwd')
-> WHERE User = 'root';
mysql> FLUSH PRIVILEGES;
quit

MAIL

new_vps:~#zypper install postfix
new_vps:~#zypper install ca-certificates
new_vps:~#vi /etc/postfix/main.cf
relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/ssl/certs/Equifax_Secure_CA.pem
smtp_use_tls = yes

new_vps:~#vi /etc/postfix/saslpasswd
[smtp.gmail.com]:587 USERNAME@gmail.com:PASSWORD

new_vps:~#chmod 400 /etc/postfix/sasl_passwd
new_vps:~#postmap /etc/postfix/sasl_passwd

new_vps:~#service postfix restart

https://www.google.com/accounts/DisplayUnlockCaptcha

new_vps:~#echo "postfix test" | mail -s "postfix test" USERNAME@gmail.com

CHECK IN SPAM FOLDER



◾ Tags:
ehowton: (Default)

"What could go wrong?" I asked. What an enormous pain in my ass that was.

BEFORE AFTER
Ubuntu 10.04 --> openSUSE 31.1
(2.6.32) (3.11.10)
Apache 2.2.14 --> Apache 2.4.6
MySQL 5.1.7 --> MariaDB 5.5.33
PHP 5.3.2 --> PHP 5.4.20
SMF 2.0 RC1 --> SMF 2.0.7


This conversion did not complete without its challenges, but the reason I'm documenting it here boils down to the one thing which made all of this like, not work the first five times:

PHP 5.4.20 is configured to use sha256 which results in session IDs being 64 characters long. SMF 2.0.7 doesn't support session IDs longer than 32 characters, so when SMF goes to check the one from PHP with what's in the database, they won't match.

Either edit php.ini and replace [session.hash_function = sha256] with [session.hash_function = 0] to cause PHP to default to md5 for session IDs (resulting in standard 32-character session IDs), or alter the following tables in the database:



ALTER TABLE smf_log_errors CHANGE session session char(64) NOT NULL;
ALTER TABLE smf_log_online CHANGE session session char(64) NOT NULL;
ALTER TABLE smf_sessions CHANGE session_id session_id char(64) NOT NULL;


I've got to hand it to the hardcore support volunteers over at http://simplemachines.org who seriously know their code, despite the answer almost never being easy to find.

Additionally, saving uncompressed flat files (*.sql) rather than compressed files prior to importing them elsewhere seemed to add junk in the file header () visible in vi but not Notepad; exporting to a compressed file then importing solved that, and so did naming the exported file the same name as the database, which needs to be created prior to importation.

I ended up creating a virtual machine locally in which to perform all the upgrades and manipulate the data for testing purposes prior to exporting to the new server. It took me far longer than I expected.
◾ Tags:
ehowton: (Default)

For a veritable laundry list of reasons, I'm migrating my documentation server at work from one VM farm to another, and in doing so, moving from Ubuntu 10.04 LTS (uptime 370 days) to openSUSE 13.1. Sadly, I'm also wading hip-deep into the bane of my professional preference, the database. Yes, I prefer flat files. Its a shortcoming of which I'm painfully aware.

How my mind works fascinates even me. I've often wondered if I'm just dumber than my co-workers (most probable given I work amongst geniuses), or if I have some elusive, yet-to-be-discovered gift (less likely given my age) which offsets the fact that I have to re-learn the same highly-technical things (As opposed to, say simple physics) over and over and over when I don't utilize them. There is one affably-hyper-super-smart coworker who can remember detailed, nuanced configurations he worked on once, years ago. I remind him often not all of us have the mind of an engineer. Then there is the architect who is visibly aghast when I don't recall building a specific server from the countless servers I've built over the many, many years I've been building servers. Personally I like to think its because I reserve that area of my brain for having things like, "a personality." That said, it takes a diverse group of skills and personalities to do what we, as a group, succeed at day in and day out. Nothing at all would ever get done if everyone was exactly like me.

So each time I have to delve into mysql (now MariahDB) its like a brand-new experience. Granted, that's a little tongue-in-cheek. I remember how to log in, and to create databases. But that's usually about it...until I start working with them again, then I seem to remember more commands. A little more is retained each time, and the learning curve less steep. Databases look like they'd be a lot of fun actually, were it not for the forlorn DBAs wearing pickled faces they keep in jars on the shelves of their respective homes each day.

Migrating smf (my documentation platform) is as easy as upgrading the application, upgrading the database, manually backing up the database, moving it and the application to an upgraded system, restoring the database, and changing all the absolute paths within the tablespaces. What could go wrong?
◾ Tags:
ehowton: (Default)

The last time I was in Frankfurt I was awaiting a flight back to my home at Langley, Virginia. I was recently returned from a tour in Saudi Arabia where I'd simply gotten off the plane in Frankfurt to spend a week with friends in Germany, after which I had 3 days to kill awaiting the next military flight out.

I considered spending my days on the walkplatz shopping and people watching. I considered exploring parts of Frankfurt I had never before been. But would those have been the best use of what was probably going to be my last trip to Germany in a long while?

I settled on buying three cases of Schöfferhofer kristallweizen and locking myself in my room not unlike Captain Willard from Apocolypse Now. Looking back, that was a fantastic use of my time in Frankfurt and I have no regrets. That was in 1995.

Fast forward to The Year of Our Lord Twenty-Thirteen and no stateside vps is offering the month-old openSUSE 12.3 Dartmouth. So once again I turn to our Deutsch friends; the birthplace of SUSE. Sure enough, 64-bit 12.3 vps with half a gig of RAM and a 25GB slice of disk for $5/mo and I am cresting the green wave! (Although it was humorous putting a .us domain in Frankfurt after agreeing to that citizenship affidavit.)

It wasn't until I went to install MySQL that I noticed further repercussions of Oracle's asininity - MariaDB. Distros are dropping MySQL as default (much as we now have LibraOffice to replace Oracle's unholy dismemberment of OpenOffice). It supposed to be a "drop-in" replacement for MySQL (Maria is the daughter of the original MySQL delveloper or somesuch) but my favorite forum software, smf would not load. A fantastic (and uber-prolific) support engineer codenamed, "Arantor" (who bemusingly reminded me of our own [livejournal.com profile] swashbuckler332) deftly sorted me out with the following code, only AFTER reminding me that just because you may be 3rd level support for your specific and narrow area of expertise, doesn't mean you make a good end user to other 3rd level support personnel :D

MariaDB [smf]> UPDATE smf_settings SET value = 0 WHERE variable = `databaseSession_enable` ;

Then there were the Indian script-kiddies polling my new server for vulnerabilities from none other than Kansan News Private Limited - a North India media initiative. What the hell? So I found them on Facebook and asked them to stop trying to hack my site and sent them the relevant portions of my log file.

And installed blockhost to pwn them.
◾ Tags:
ehowton: (Default)
Can someone help me with mysql? I really have no idea what I'm doing.
◾ Tags:

July 2025

S M T W T F S
   1234 5
6 7 8 910 1112
13 14 15 1617 1819
20 21 222324 2526
27 2829 3031  

Most Popular Tags

Expand Cut Tags

No cut tags