Skip to content

Commit 2260712

Browse files
committed
feat: add script to fix MySQL FROZEN issue when downgrading from MariaDB
1 parent 53b0823 commit 2260712

4 files changed

Lines changed: 168 additions & 15 deletions

File tree

README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,18 @@ cd dotfiles_server
3434
3535
The runner has the following commands:
3636
37-
| Command | Description |
38-
|-----------------------|--------------------------------------------------------------------|
39-
| `setup`, `s`, `a` | Setup the server |
40-
| `ssh_port`, `sp` | Change the SSH port |
41-
| `ssh_timeout`, `st` | Configure SSH timeout (auto disconnect after 5min idle) |
42-
| `php`, `php-install` | Install PHP version you want |
43-
| `php_extension`, `pe` | Install PHP extensions |
44-
| `lazydocker`, `ld` | Install lazydocker |
45-
| `global_dev`, `gd` | Setup NVM, NPM, Yarn, ZSH globally for all users |
37+
| Command | Description |
38+
|-----------------------|---------------------------------------------------------|
39+
| `setup`, `s`, `a` | Setup the server |
40+
| `ssh_port`, `sp` | Change the SSH port |
41+
| `ssh_timeout`, `st` | Configure SSH timeout (auto disconnect after 5min idle) |
42+
| `php`, `php-install` | Install PHP version you want |
43+
| `php_extension`, `pe` | Install PHP extensions |
44+
| `lazydocker`, `ld` | Install lazydocker |
45+
| `global_dev`, `gd` | Setup NVM, NPM, Yarn, ZSH globally for all users |
46+
| `zabbix_server`, `zs` | Install Zabbix Server with auto web server detection |
47+
| `zabbix_client`, `zc` | Install Zabbix Agent (client) |
48+
| `fix_mysql`, `fmf` | Fix MySQL FROZEN issue (when downgrading from MariaDB) |
4649
4750
### Global Dev Setup
4851

install.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ case "${1:-}" in
152152
zabbix_client "$@"
153153
;;
154154

155+
fix_mysql | fix_mysql_frozen | fmf)
156+
fix_mysql_frozen
157+
;;
158+
155159
*)
156160
usage
157161
exit 1

setup/system/fix-mysql-frozen.sh

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/bin/bash
2+
3+
# Fix MySQL FROZEN issue when downgrading from MariaDB to MySQL
4+
5+
echo "=========================================="
6+
echo "🔧 Fixing MySQL FROZEN Issue"
7+
echo "=========================================="
8+
echo ""
9+
10+
if [ "$EUID" -ne 0 ]; then
11+
echo "❌ Please run as root or with sudo"
12+
exit 1
13+
fi
14+
15+
# Check if FROZEN file exists
16+
if [ ! -f /etc/mysql/FROZEN ]; then
17+
echo "✓ No FROZEN file found, MySQL is not frozen"
18+
exit 0
19+
fi
20+
21+
echo "Found FROZEN file:"
22+
cat /etc/mysql/FROZEN
23+
echo ""
24+
25+
echo "This happens when trying to downgrade from MariaDB 11.x to MySQL 8.0"
26+
echo ""
27+
echo "Choose an option:"
28+
echo " 1) Remove MySQL/MariaDB and clean everything (recommended)"
29+
echo " 2) Just remove FROZEN file (risky, may cause data corruption)"
30+
echo " 3) Cancel"
31+
read -p "Enter choice [1-3]: " choice
32+
33+
case "$choice" in
34+
1)
35+
echo ""
36+
echo "➜ Stopping database services..."
37+
systemctl stop mysql 2>/dev/null || true
38+
systemctl stop mariadb 2>/dev/null || true
39+
40+
echo "➜ Removing packages..."
41+
apt-get remove --purge -y mariadb-server mariadb-client mariadb-common \
42+
mysql-server mysql-client mysql-common 2>/dev/null || true
43+
44+
echo "➜ Cleaning up files..."
45+
rm -rf /etc/mysql
46+
rm -rf /var/lib/mysql
47+
rm -rf /var/log/mysql
48+
49+
echo "➜ Removing auto-installed packages..."
50+
apt-get autoremove -y
51+
52+
echo ""
53+
echo "✅ Cleanup complete!"
54+
echo ""
55+
echo "📌 Next steps:"
56+
echo " 1. Run: apt-get update"
57+
echo " 2. Install MySQL: apt-get install -y mysql-server"
58+
echo " 3. Or run Zabbix installation again"
59+
;;
60+
2)
61+
echo ""
62+
echo "⚠️ Removing FROZEN file only (risky)..."
63+
rm -f /etc/mysql/FROZEN
64+
echo "✓ FROZEN file removed"
65+
echo ""
66+
echo "📌 Try to start MySQL:"
67+
echo " systemctl start mysql"
68+
;;
69+
3)
70+
echo "Cancelled"
71+
exit 0
72+
;;
73+
*)
74+
echo "❌ Invalid choice"
75+
exit 1
76+
;;
77+
esac
78+

setup/system/zabbix.sh

Lines changed: 74 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,80 @@ install_zabbix_server() {
7474
apt-get update -qq
7575
print_success "Zabbix repository added"
7676

77-
# Install MySQL
78-
print_info "Installing MySQL server..."
79-
apt-get install -y mysql-server
80-
systemctl start mysql
81-
systemctl enable mysql
82-
print_success "MySQL installed and started"
77+
# Check for existing database installations
78+
print_info "Checking for existing database installations..."
79+
DB_INSTALLED=false
80+
DB_TYPE=""
81+
82+
if dpkg -l | grep -q "^ii.*mariadb-server"; then
83+
DB_INSTALLED=true
84+
DB_TYPE="MariaDB"
85+
elif dpkg -l | grep -q "^ii.*mysql-server"; then
86+
DB_INSTALLED=true
87+
DB_TYPE="MySQL"
88+
fi
89+
90+
if [ "$DB_INSTALLED" = true ]; then
91+
print_info "${DB_TYPE} is already installed"
92+
echo ""
93+
echo "Choose an option:"
94+
echo " 1) Use existing ${DB_TYPE} (recommended if working)"
95+
echo " 2) Remove ${DB_TYPE} and install fresh MySQL 8.0"
96+
echo " 3) Cancel installation"
97+
read -p "Enter choice [1-3]: " db_choice
98+
99+
case "$db_choice" in
100+
1)
101+
print_info "Using existing ${DB_TYPE}"
102+
# Check if database is running
103+
if ! systemctl is-active --quiet mysql && ! systemctl is-active --quiet mariadb; then
104+
print_info "Starting database service..."
105+
systemctl start mysql 2>/dev/null || systemctl start mariadb 2>/dev/null || true
106+
fi
107+
;;
108+
2)
109+
print_info "Removing existing ${DB_TYPE}..."
110+
# Stop services
111+
systemctl stop mysql 2>/dev/null || true
112+
systemctl stop mariadb 2>/dev/null || true
113+
114+
# Remove frozen file if exists
115+
rm -f /etc/mysql/FROZEN
116+
117+
# Purge old installations
118+
apt-get remove --purge -y mariadb-server mariadb-client mysql-server mysql-client 2>/dev/null || true
119+
apt-get autoremove -y
120+
121+
# Clean up config files
122+
rm -rf /etc/mysql
123+
rm -rf /var/lib/mysql
124+
125+
print_success "Old database removed"
126+
127+
# Install MySQL
128+
print_info "Installing MySQL server..."
129+
apt-get install -y mysql-server
130+
systemctl start mysql
131+
systemctl enable mysql
132+
print_success "MySQL installed and started"
133+
;;
134+
3)
135+
print_error "Installation cancelled"
136+
exit 1
137+
;;
138+
*)
139+
print_error "Invalid choice"
140+
exit 1
141+
;;
142+
esac
143+
else
144+
# Install MySQL - no existing database
145+
print_info "Installing MySQL server..."
146+
apt-get install -y mysql-server
147+
systemctl start mysql
148+
systemctl enable mysql
149+
print_success "MySQL installed and started"
150+
fi
83151

84152
# Detect or choose web server
85153
print_info "Detecting web server..."

0 commit comments

Comments
 (0)