Fix MariaDB connections issues
* allow new unix_socket auth system * add socket path in /etc/mysql/conf.d/my.cnf
This commit is contained in:
@@ -51,6 +51,7 @@ def pre_pref(self, apt_packages):
|
||||
[client]
|
||||
user = root
|
||||
password = {chars}
|
||||
socket = /run/mysqld/mysqld.sock
|
||||
""".format(chars=chars)
|
||||
config = configparser.ConfigParser()
|
||||
config.read_string(mysql_config)
|
||||
@@ -939,16 +940,11 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
||||
config = configparser.ConfigParser()
|
||||
config.read('/etc/mysql/conf.d/my.cnf.tmp')
|
||||
chars = config['client']['password']
|
||||
WOShellExec.cmd_exec(
|
||||
self,
|
||||
'mysql -e "ALTER USER root@localhost '
|
||||
'IDENTIFIED VIA mysql_native_password;"')
|
||||
WOShellExec.cmd_exec(
|
||||
self,
|
||||
'mysql -e "SET PASSWORD = '
|
||||
'PASSWORD(\'{0}\');"'.format(chars))
|
||||
WOShellExec.cmd_exec(
|
||||
self, 'mysql -e "flush privileges;"')
|
||||
'PASSWORD(\'{0}\'); flush privileges;"'
|
||||
.format(chars))
|
||||
WOFileUtils.mvfile(
|
||||
self, '/etc/mysql/conf.d/my.cnf.tmp',
|
||||
'/etc/mysql/conf.d/my.cnf')
|
||||
@@ -956,6 +952,30 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
||||
Log.error(self, "Unable to set MySQL password")
|
||||
WOGit.add(self, ["/etc/mysql"],
|
||||
msg="Adding MySQL into Git")
|
||||
elif os.path.exists('/etc/mysql/conf.d/my.cnf'):
|
||||
if ((WOAptGet.is_installed(
|
||||
self, 'mariadb-server-10.5')) and
|
||||
not (WOFileUtils.grepcheck(
|
||||
self, '/etc/mysql/conf.d/my.cnf', 'socket'))):
|
||||
try:
|
||||
config = configparser.ConfigParser()
|
||||
config.read('/etc/mysql/conf.d/my.cnf')
|
||||
chars = config['client']['password']
|
||||
WOShellExec.cmd_exec(
|
||||
self,
|
||||
'mysql -e "ALTER USER root@localhost '
|
||||
'IDENTIFIED VIA unix_socket OR '
|
||||
'mysql_native_password; '
|
||||
'SET PASSWORD = PASSWORD(\'{0}\'); '
|
||||
'flush privileges;"'.format(chars))
|
||||
WOFileUtils.textappend(
|
||||
self, '/etc/mysql/conf.d/my.cnf',
|
||||
'socket = /run/mysqld/mysqld.sock')
|
||||
except CommandExecutionError:
|
||||
Log.error(self, "Unable to set MySQL password")
|
||||
WOGit.add(self, ["/etc/mysql"],
|
||||
msg="Adding MySQL into Git")
|
||||
|
||||
Log.wait(self, "Tuning MariaDB configuration")
|
||||
if not os.path.isfile("/etc/mysql/my.cnf.default-pkg"):
|
||||
WOFileUtils.copyfile(self, "/etc/mysql/my.cnf",
|
||||
|
||||
Reference in New Issue
Block a user