Categories
Hosting

🤦🏼‍♂️

There comes a time when everyone makes a mistake with computers. Garbage In Garbage Out and all that jazz. I seem to just like shovelling a large amount of Garbage into my servers. Take this evening for example.

I have one domain left to transfer to my new servers. The third last one was this blog and that went almost without a hitch. There were some wordpress-related things I hadn’t accounted for but nothing I couldn’t handle. The penultimate one was another wordpress installation that went much smoother after I transferred this blog.

And then I started preparing the move for the last domain. I’m being careful with this one because I know things will go wrong given half a chance. I’ve been checking and re-checking everything and decided to start to the process this evening.

First up was to update the existing code on that domain so that I could transfer everything fresh. That has a small hiccup which ended with me erasing (thanks to an errant FTP command) almost every folder and leaving but a handful of files behind.

Panicking, I managed to copy a new instance of the software over however in my haste this overwrote the main configuration file. Thank goodness I managed to remember some very old username/password/database combinations.

That ended up being rescued and is now working fine on the old host.

Whilst running about I then tried to login to my new host and managed to type with my ham-fists the incorrect password a few times and put my own IP address in a fail2ban jail.

I managed to get a remote KVM Console running via my hosting provider, and took myself out of the fail2ban jail. Now, I’m not entirely sure why I thought this was a good idea but I seen this button and figured I should click it.

CTRL+ALT+DEL

Now I’m no new entrant to linux and its ilk. I’m also not a stranger to Windows – and my organisation requires the use of Ctrl+Alt+Del to initiate a login. Completely forgetting that Ctrl+Alt+Del on Linux restarts the server I click the button. No confirmation. No warning. Just a graceful restart.

Remember how I didn’t want any downtime? 🤦🏼‍♂️

I am not a smart man.

On the plus side, I today confirmed that a reboot would bring all services back online in a sane manner!

But the last site move has been postponed.

Categories
Hosting

Easy root MySQL Password reset

I’ve recently found myself in that awkward situation where I’ve chosen a (very) secure password for a root MySQL user and I’ve forgotten it. I suppose its the most secure password I’ve had then because even I cant use it to login to the MySQL database – not that you should be using a root account under any circumstances – this was debugging.

I’ve had this happen before and I’ve used the

--skip-grant-tables

trick that stops the MySQL server, starts it up with no password, allows you to change the password, then stop and restart the server with the new password in force.

Ideally I wanted no downtime (even for those few precious seconds). As usual, google ended up pointing (to me) to a unknown way to reset the root password using another account that has full root privileges in a standard Ubuntu install.

Full credit to https://www.configserverfirewall.com/ubuntu-linux/reset-mysql-root-password-ubuntu/, and the main parts are only reproduced here in case the original site goes offline.

The debian-sys-maint user account is an administrative user account automatically created when installing MySQL Server on Ubuntu and this user have full access to all databases.

Quote from https://www.configserverfirewall.com/ubuntu-linux/reset-mysql-root-password-ubuntu/https://www.configserverfirewall.com/ubuntu-linux/reset-mysql-root-password-ubuntu/

This means that viewing the debian.cnf file using cat

sudo cat /etc/mysql/debian.cnf

nets us directly the login details including password for this account. Looking under

user = debian-sys-maint

is a

password = LongAndRandomPassword

so, using these details, a a quick

mysql -udebian-sys-maint -p

and

FLUSH PRIVILEGES;
 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'NewVerySecurePassword';
 FLUSH PRIVILEGES;

nets you with an uninterrupted uptime MySQL password reset.

Now. To read about this account that has MySQL Root Privileges that I’ve never noticed before.

Categories
Hosting

Time for an update.

Update 1 below, posted at 12/12/2019 @ 1910Hrs


It’s Annual Leave time. Seeing as I’m not going away anywhere that means I have to fill my time with other things. This time, I’ve decided to migrate hosts. Oh the joys.

I have approximately 10 domains to move, database to migrate, files to transfer and DNS changes to propagate. This is going to be fun.

Why? Cost. I currently pay around £9 a month for my current hosting, which is to a company based in the US. I recon I can (safely) get it down to around £2 per month, maximum. Thats roughly 77% less. The hosting for the sites I do isn’t mission critical. Its still just a hobby. The £2 a month hosting should be more than adequate for my needs.

Because I’m lazy I figure a script will help with some of the automation. I’m using Apache VirtualHosts, and because each domain requires a separate VirtualHosts configuration file, I created this script. It doesn’t have the full configuration in it, but its enough to help you get started. I also output the command required to enable each configuration into a separate file, which can be viewed here.

Update 1: Most of my sites have been transferred over with no issues. All DNS records have been updated and appear to be working fine, apart from Virgin Media dragging its heels and apparently (still) not adhering to TTL values.

This one, and my busiest have yet to be moved. Im contemplating moving these two to a separate server, and at £1 per month, I don’t see why not.