Testing MariaDB 10.5

This commit is contained in:
VirtuBox
2020-10-22 11:04:23 +02:00
parent fd66b5475f
commit dff13eb345
3 changed files with 16 additions and 43 deletions

View File

@@ -45,39 +45,6 @@ def pre_pref(self, apt_packages):
if "mariadb-server" in apt_packages: if "mariadb-server" in apt_packages:
# generate random 24 characters root password # generate random 24 characters root password
chars = ''.join(random.sample(string.ascii_letters, 24)) chars = ''.join(random.sample(string.ascii_letters, 24))
Log.debug(self, "Pre-seeding MySQL")
Log.debug(self, "echo \"mariadb-server-{0} "
"mysql-server/root_password "
"password \" | "
"debconf-set-selections"
.format(WOVar.mariadb_ver))
try:
WOShellExec.cmd_exec(self, "echo \"mariadb-server-{0} "
"mysql-server/root_password "
"password {chars}\" | "
"debconf-set-selections"
.format(WOVar.mariadb_ver, chars=chars),
log=False)
except CommandExecutionError as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Failed to initialize MySQL package")
Log.debug(self, "echo \"mariadb-server-{0} "
"mysql-server/root_password_again "
"password \" | "
"debconf-set-selections"
.format(WOVar.mariadb_ver))
try:
WOShellExec.cmd_exec(self, "echo \"mariadb-server-{0} "
"mysql-server/root_password_again "
"password {chars}\" | "
"debconf-set-selections"
.format(WOVar.mariadb_ver, chars=chars),
log=False)
except CommandExecutionError as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Failed to initialize MySQL package")
# generate my.cnf root credentials # generate my.cnf root credentials
mysql_config = """ mysql_config = """
[client] [client]
@@ -966,7 +933,7 @@ def post_pref(self, apt_packages, packages, upgrade=False):
config_file.close() config_file.close()
else: else:
# make sure root account have all privileges # make sure root account have all privileges
if "PASSWORD" not in WOShellExec.cmd_exec_stdout( if "IDENTIFIED BY PASSWORD" not in WOShellExec.cmd_exec_stdout(
self, 'mysql -e "use mysql; show grants;"'): self, 'mysql -e "use mysql; show grants;"'):
try: try:
if not os.path.exists('/etc/mysql/conf.d/my.cnf'): if not os.path.exists('/etc/mysql/conf.d/my.cnf'):
@@ -975,10 +942,13 @@ def post_pref(self, apt_packages, packages, upgrade=False):
config.read('/etc/mysql/conf.d/my.cnf') config.read('/etc/mysql/conf.d/my.cnf')
chars = config['client']['password'] chars = config['client']['password']
WOShellExec.cmd_exec( WOShellExec.cmd_exec(
self, "mysql -e \"use mysql; " self,
"GRANT ALL PRIVILEGES on " 'mysql -e "ALTER USER root@localhost '
"*.* TO 'root'@'127.0.0.1' IDENTIFIED by " 'IDENTIFIED VIA mysql_native_password;"')
"'{0}' WITH GRANT OPTION\"".format(chars)) WOShellExec.cmd_exec(
self,
'mysql -e "SET PASSWORD = '
'PASSWORD(\'{0}\');"'.format(chars))
WOShellExec.cmd_exec( WOShellExec.cmd_exec(
self, 'mysql -e "flush privileges;"') self, 'mysql -e "flush privileges;"')
except CommandExecutionError: except CommandExecutionError:
@@ -1001,11 +971,14 @@ def post_pref(self, apt_packages, packages, upgrade=False):
elif (wo_ram > 64000): elif (wo_ram > 64000):
wo_innodb_instance = int(64) wo_innodb_instance = int(64)
tmp_table_size = int(256) tmp_table_size = int(256)
mariadbconf = bool(not os.path.exists(
'/etc/mysql/mariadb.conf.d/50-server.cnf'))
data = dict( data = dict(
tmp_table_size=tmp_table_size, inno_log=wo_ram_log_size, tmp_table_size=tmp_table_size, inno_log=wo_ram_log_size,
inno_buffer=wo_ram_innodb, inno_buffer=wo_ram_innodb,
inno_log_buffer=wo_ram_log_buffer, inno_log_buffer=wo_ram_log_buffer,
innodb_instances=wo_innodb_instance) innodb_instances=wo_innodb_instance,
newmariadb=mariadbconf)
if os.path.exists('/etc/mysql/mariadb.conf.d/50-server.cnf'): if os.path.exists('/etc/mysql/mariadb.conf.d/50-server.cnf'):
WOTemplate.deploy( WOTemplate.deploy(
self, '/etc/mysql/my.cnf', 'my.mustache', data) self, '/etc/mysql/my.cnf', 'my.mustache', data)

View File

@@ -41,7 +41,6 @@ tmpdir = /tmp
lc_messages_dir = /usr/share/mysql lc_messages_dir = /usr/share/mysql
lc_messages = en_US lc_messages = en_US
skip-external-locking skip-external-locking
skip-name-resolve = 1
# #
# Instead of skip-networking the default is now to listen only on # Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure. # localhost which is more compatible and is not less secure.
@@ -191,5 +190,6 @@ key_buffer = 16M
# * IMPORTANT: Additional settings that can override those from this file! # * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored. # The files must end with '.cnf', otherwise they'll be ignored.
# #
{{#newmariadb}}
!include /etc/mysql/mariadb.cnf !include /etc/mysql/mariadb.cnf
!includedir /etc/mysql/conf.d/ !includedir /etc/mysql/conf.d/{{/newmariadb}}

View File

@@ -166,7 +166,7 @@ class WOVar():
else: else:
mariadb_ver = '10.3' mariadb_ver = '10.3'
else: else:
mariadb_ver = '10.3' mariadb_ver = '10.5'
if wo_platform_codename == 'jessie': if wo_platform_codename == 'jessie':
wo_mysql = wo_mysql + ["python3-mysql.connector"] wo_mysql = wo_mysql + ["python3-mysql.connector"]
else: else:
@@ -185,7 +185,7 @@ class WOVar():
# APT repositories # APT repositories
wo_mysql_repo = ("deb [arch=amd64,ppc64el] " wo_mysql_repo = ("deb [arch=amd64,ppc64el] "
"http://mariadb.mirrors.ovh.net/MariaDB/repo/" "http://mariadb.mirrors.ovh.net/MariaDB/repo/"
"10.3/{distro} {codename} main" "10.5/{distro} {codename} main"
.format(distro=wo_distro, .format(distro=wo_distro,
codename=wo_platform_codename)) codename=wo_platform_codename))
if wo_distro == 'ubuntu': if wo_distro == 'ubuntu':