Skip to content

Commit 8526b58

Browse files
author
Till Brehm
committed
Merge branch '6506-check-minimum-required-mysql-or-mariadb-version-during-installation-and-update' into 'develop'
Resolve "Check minimum required MySQL or MariaDB version during installation and update" Closes #6506 See merge request ispconfig/ispconfig3!1743
2 parents 098aaf2 + 90a7d00 commit 8526b58

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

install/install.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@
252252
include_once 'lib/mysql.lib.php';
253253
$inst->db = new db();
254254

255+
//* Check MySQL version
256+
$inst->check_mysql_version();
257+
255258
//** Begin with standard or expert installation
256259

257260
$conf['services']['mail'] = false;

install/lib/installer_base.lib.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,36 @@ public function check_prerequisites() {
262262
if($msg != '') die($msg);
263263
}
264264

265+
//** Check MySQL version
266+
public function check_mysql_version() {
267+
global $conf;
268+
269+
$min_mariadb_version = '10.0.5';
270+
// Set MySQL version to 8.0.4 after CentOS 7 support ended to allow preg_* functions in SQL queries
271+
$min_mysql_version = '5.5';
272+
273+
$rec = $this->db->queryOneRecord('SELECT VERSION() as mysql_version');
274+
if(is_array($rec)) {
275+
$version = $rec['mysql_version'];
276+
} else {
277+
die("Unable to get MySQL version\n");
278+
}
279+
280+
if(strpos($version,'MariaDB')) {
281+
// We have MariaDB
282+
$parts = explode('-',$version);
283+
$version = $parts[0];
284+
swriteln("MariaDB version ".$version);
285+
if(version_compare($version, $min_mariadb_version, '<')) die("Minimum required MariaDB version is ".$min_mariadb_version."\n");
286+
} else {
287+
// we have MySQL
288+
swriteln("MySQL version ".$version);
289+
if(version_compare($version, $min_mysql_version, '<')) die("Minimum required MySQL version is ".$min_mysql_version."\n");
290+
}
291+
292+
293+
}
294+
265295
public function force_configure_app($service, $enable_force=true) {
266296
$force = false;
267297
if(AUTOINSTALL == true) return false;

install/update.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,9 @@
274274
$inst->db->setDBData($conf['mysql']["host"], $conf['mysql']["ispconfig_user"], $conf['mysql']["ispconfig_password"], $conf['mysql']["port"]);
275275
$inst->db->setDBName($conf['mysql']['database']);
276276

277+
//* Check MySQL version
278+
$inst->check_mysql_version();
279+
277280
//* initialize the master DB, if we have a multiserver setup
278281
if($conf['mysql']['master_slave_setup'] == 'y') {
279282

0 commit comments

Comments
 (0)