Wednesday, December 31, 2025

How to Stop MySQL from Auto-Updating on Ubuntu Server 22.04 (and Verify It Won’t Happen)

If you run MySQL on Ubuntu Server 22.04, you already know the problem:
Ubuntu is very helpful about updates — sometimes too helpful.

An unattended MySQL upgrade can:

  • Restart the service

  • Break replication

  • Introduce subtle behavior changes

  • Ruin a carefully controlled production setup

This post shows how to stop MySQL from auto-updating and how to prove in advance that no update will sneak in.

No hand-waving. Real commands. Verifiable results.


The Real Culprit: Unattended Upgrades

Ubuntu uses a background service called unattended-upgrades to silently install updates. That includes MySQL unless you explicitly stop it.

You have three levels of control. Most servers should use Level 1 or 2.


Option 1 — Freeze MySQL with apt-mark hold (Recommended)

This is the simplest and safest approach.

sudo apt-mark hold mysql-server mysql-client mysql-common

What this does:

  • APT will refuse to upgrade these packages

  • Even if someone runs apt upgrade

  • Even if unattended-upgrades runs overnight

Verify the hold:

apt-mark showhold

Expected output:

mysql-server mysql-client mysql-common

To undo later:

sudo apt-mark unhold mysql-server mysql-client mysql-common

Option 2 — Let Ubuntu Update Everything Except MySQL

If you want security updates for the OS but not for MySQL, blacklist it from unattended upgrades.

Edit the config:

sudo nano /etc/apt/apt.conf.d/50unattended-upgrades

Find:

Unattended-Upgrade::Package-Blacklist { };

Add:

Unattended-Upgrade::Package-Blacklist { "mysql-server"; "mysql-client"; "mysql-common"; };

Restart the service:

sudo systemctl restart unattended-upgrades

This keeps the system secure while freezing MySQL.


Option 3 — Disable Automatic Updates Entirely (Use With Caution)

This is a blunt instrument.

sudo systemctl disable --now unattended-upgrades

Or:

sudo nano /etc/apt/apt.conf.d/20auto-upgrades

Set:

APT::Periodic::Unattended-Upgrade "0";

Only do this if you commit to manual patching.


How to Verify Beforehand That MySQL Will NOT Update

This is the part most guides skip. Don’t trust configuration — verify behavior.


1. Check What APT Thinks Is Upgradable

apt list --upgradable | grep -i mysql

Correct result: no output
If you see MySQL packages here, they are not frozen.


2. Simulate a Full Upgrade (Dry Run)

sudo apt -s upgrade | grep -i mysql

The -s flag means simulate only.
Nothing will be installed.

Correct result: no MySQL packages listed.


3. Simulate Unattended Upgrades Directly

This tests the exact logic Ubuntu uses overnight.

sudo unattended-upgrades --dry-run --debug | grep -i mysql

If MySQL is held or blacklisted, it will be skipped.


4. Double-Check Package Holds

apt-mark showhold

If MySQL isn’t listed, it’s not protected.


5. (Optional) Verify Pinning Rules

If you’re using apt pinning:

apt-cache policy mysql-server

You should see a pin priority preventing upgrades.


The “I’m Safe” Checklist

Run these three commands:

apt list --upgradable | grep -i mysql apt -s upgrade | grep -i mysql unattended-upgrades --dry-run --debug | grep -i mysql

If all three return empty, MySQL will not update. Period.


Final Advice

  • Production server? Use apt-mark hold

  • Security-conscious server? Use unattended-upgrade blacklist

  • Never rely on assumptions — always simulate

Ubuntu does exactly what you tell it to do.
The problem is most admins never tell it not to touch MySQL.

My Year with ChatGPT













 

See here: https://chatgpt.com/share/695563c9-a894-800c-ab7e-7ee18881a635 

Another year of walking

I failed again reaching my 1800 miles goal, 150 miles monthly. August was my weakest month.

Let's see on 2026. 

 

SQL Queries

I have written so many SQL queries during my life as a software developer that I lost count.

SQL-Queries is a GitHub repository that I'm going to use for publishing those queries.

This is a work in progress.

 

Java code to create a .XLSX Excel file from a PDF file

I uploaded some Java code that I wrote earlier this year that creates a .XLSX Excel file from PDF file.

GitHub code: https://github.com/64board/account_summary_u 

Excel VBA code to create XLSX file from a CSV file

VBA code to create a XLSX file from a CSV file. It also shows how to auto fit all columns, apply an auto filter to all columns and freeze the first row.

GitHub code: https://github.com/64board/ExcelVBA/blob/master/CreateXLSX.bas

Another interesting idea is to control running code when the workbook is opened using a flag file.

GitHub code: https://github.com/64board/ExcelVBA/blob/master/ThisWorkbook.cls 

Tuesday, December 30, 2025

Python Selenium examples

See below two examples of using Python Selenium:

Chrome version: https://github.com/64board/Python/blob/main/fixing_price_es_chrome.py

Firefox version: https://github.com/64board/Python/blob/main/fixing_price_es_gecko.py  

7-Zip archive Python API

py7zr is a Python module that provides tools to read, write and list 7z file. The 7z file format is a popular archive and compression format in recent days.

See documentation: https://py7zr.readthedocs.io/en/latest/index.html 

I wrote some code demonstrating the API's use: https://github.com/64board/Python/blob/main/py7zr_test.py

Monday, December 29, 2025

Handle of fractions in Perl using BigFloat and the GNU Multiple Precision Library or the Pary library

I just uploaded a program that shows the handling of numerical fractions representation using BigFloat and GNU Multiple Precision Library or the Pary library on the parse_number_fraction procedure.

Github: https://github.com/64board/Perl/blob/main/sto-open-positions-25.pl 

 

Sunday, December 28, 2025

Perl multiple lines REGEX

The code in the the following link illustrates a Perl REGEX written in multiple lines using modifier '/x.'

The `/x` modifier in Perl regular expressions allows you to write more readable patterns by ignoring white space and allowing comments within the regex. This means you can format your regex with spaces and add comments for clarity without affecting its functionality.

Github: https://github.com/64board/Perl/blob/main/get-report-date.pl 

 

Friday, December 26, 2025

Bash program that lists all the years when weekday of your birthday matches your birthday weekday

 

List all years between birthday's year and current one when day of the week matches birthday's day of the week, also lists next year after the last on the list that matches. 

* Uses DATE(1) bash command to do date calculations.

* No other external command required.

Source code: https://github.com/64board/Bash/blob/main/bdates.sh

Python program for calculating office's dates

 mbf_date: A small command-line tool that prints dates based on simple rules.

It can output:

  • the current date
  • the previous date
  • the next date

Optionally, it can treat Saturday and Sunday as non-business days, so:

  • previous business date skips weekends backward
  • next business date skips weekends forward

You can also specify the output format using Python strftime patterns.

Source code:  https://github.com/64board/Python/blob/main/mbf_date.py

 

My First use of ChatGPT

This was my first use of ChatGPT earlier this year: https://chatgpt.com/share/694eca69-8d50-800c-b507-4544ecbd6541

Replacing the seal in a Fluidmaster toilet fill valve is a simple and cost-effective fix if your toilet is running or filling slowly. Here's a step-by-step guide:


🛠️ Tools & Materials Needed:

  • Replacement Fluidmaster seal (usually part #242)

  • Towel or small container (to catch water)

  • Adjustable wrench (optional)


🔧 Step-by-Step Instructions:

1. Turn Off the Water Supply

  • Locate the shut-off valve (usually behind or below the toilet).

  • Turn it clockwise to stop water flow.

2. Flush the Toilet

  • Flush to empty the tank.

  • Hold the handle down to get as much water out as possible.

  • Use a towel or sponge to soak up any remaining water at the bottom of the tank if needed.

3. Remove the Fill Valve Cap

  • The Fluidmaster fill valve cap is usually secured with a twist-lock mechanism.

  • Hold the shaft of the fill valve with one hand.

  • With the other hand, twist the top cap counterclockwise about 1/8 of a turn and lift it off.

  • Some models require gently squeezing side tabs before twisting.

4. Replace the Seal

  • Inside the cap, you’ll see a small rubber seal (usually red or black).

  • Remove the old seal (you can use a small flathead screwdriver or your fingers).

  • Insert the new seal in the same position, making sure it sits flat and centered.

5. Reinstall the Cap

  • Line up the cap on top of the valve body.

  • Twist it clockwise to lock it back into place.

6. Turn the Water Back On

  • Slowly open the shut-off valve.

  • Let the tank fill and check for leaks.

  • Flush the toilet to ensure proper operation.


✅ Tips:

  • The Fluidmaster 400A is the most common model. Make sure you’re using the right seal for your valve.

  • If replacing the seal doesn’t solve the issue, the whole fill valve may need to be replaced (also inexpensive and easy).



Java Trim

 

When String.trim() “Fails” in Java (And Why It’s Not a Bug)

Every Java developer eventually runs into this head-scratcher:

String s = " hello "; System.out.println(s.trim());

And yet… the output still looks padded.

At first glance, it feels like trim() is broken.

It isn’t.

What’s broken is the assumption about what trim() actually removes.

Let’s clear this up once and for all.


What String.trim() Really Does

In Java, String.trim() removes leading and trailing characters whose Unicode code point is ≤ U+0020.

That’s it.

This includes:

  • Regular space (U+0020)

  • Tabs (\t)

  • Newlines (\n)

  • Carriage returns (\r)

  • A handful of other low-level control characters

If the character’s Unicode value is greater than 0x20, trim() will leave it alone, even if it looks like whitespace.


The #1 Reason trim() Appears to Fail

Non-breaking spaces (U+00A0)

This is the usual culprit.

Non-breaking spaces:

  • Look exactly like normal spaces

  • Commonly appear when copying text from:

    • Web pages

    • PDFs

    • Excel

    • Word documents

  • Are not removed by trim()

Example:

String s = "\u00A0hello\u00A0"; System.out.println(s.trim()); // still padded

This isn’t a bug. Java is doing exactly what it’s documented to do.


Other Invisible Characters That trim() Won’t Touch

Some especially nasty ones:

  • \u00A0 – non-breaking space

  • \u200B – zero-width space

  • \u2007 – figure space

  • \u202F – narrow no-break space

These characters:

  • Render invisibly

  • Survive trim()

  • Can break comparisons, parsing, validation, and logging


Common Misunderstandings

❌ “trim removes all whitespace”

Nope. Only specific characters.

❌ “trim cleans the whole string”

Nope. Only leading and trailing characters. Internal whitespace is untouched.

❌ “trim failed, so Java is buggy”

Also nope. This behavior is explicitly defined in the JDK.


How to Prove What’s Actually in Your String

When a string refuses to trim, inspect the Unicode values:

for (int i = 0; i < s.length(); i++) { System.out.printf( "char[%d] = '%c' (U+%04X)%n", i, s.charAt(i), (int) s.charAt(i) ); }

Once you see U+00A0 or U+200B, the mystery is over.


The Right Way to Trim All Whitespace

If your input comes from:

  • Files

  • Excel

  • Web APIs

  • Copy-paste

  • User input

…then trim() is usually not enough.

Unicode-aware trim using regex

s = s.replaceAll("^\\s+|\\s+$", "");

This handles:

  • Standard whitespace

  • Unicode whitespace

  • Much closer to what people expect “trim” to mean

Aggressive cleanup (separators + control chars)

s = s.replaceAll("^[\\p{Z}\\p{C}]+|[\\p{Z}\\p{C}]+$", "");

Where:

  • \p{Z} = Unicode separators (spaces of all kinds)

  • \p{C} = control and invisible characters

Use this when dealing with truly messy input.


One Last Gotcha: null

Don’t forget:

s.trim(); // throws NullPointerException if s == null

If there’s any chance of nulls, guard it or normalize earlier.


Takeaway

String.trim() doesn’t fail.

It just:

  • Works exactly as specified

  • Assumes you know Unicode

  • Is often insufficient for real-world data

If your strings come from outside your JVM, assume they’re dirty—and clean them properly.

If you’ve ever lost time debugging a “trim bug”, now you know: it wasn’t Java.

US Holidays for 2025 and beyond

 I wrote some Excel VBA code to create a list of US Federal holidays.

My GitHub link: https://github.com/64board/ExcelVBA/blob/master/USHolidays.bas