Centos7 / Mariadb fixes
* Add mariadb-server package to the yum installation
* Add root password initial settings ("post"seed fashion)
* Handle centos "mysql" service name according to MariaDB switch
* add modoboa@localhost in order to give access
This commit is contained in:
committed by
GitHub
parent
3be02b9076
commit
2898c57127
@@ -123,9 +123,9 @@ class MySQL(Database):
|
|||||||
|
|
||||||
packages = {
|
packages = {
|
||||||
"deb": ["mysql-server", "libmysqlclient-dev"],
|
"deb": ["mysql-server", "libmysqlclient-dev"],
|
||||||
"rpm": ["mariadb", "mariadb-devel"],
|
"rpm": ["mariadb", "mariadb-devel","mariadb-server"],
|
||||||
}
|
}
|
||||||
service = "mysql"
|
service = "mariadb" if package.backend.FORMAT == "rpm" else "mysql"
|
||||||
|
|
||||||
def install_package(self):
|
def install_package(self):
|
||||||
"""Preseed package installation."""
|
"""Preseed package installation."""
|
||||||
@@ -134,9 +134,11 @@ class MySQL(Database):
|
|||||||
package.backend.preconfigure(
|
package.backend.preconfigure(
|
||||||
"mysql-server", "root_password_again", "password", self.dbpassword)
|
"mysql-server", "root_password_again", "password", self.dbpassword)
|
||||||
super(MySQL, self).install_package()
|
super(MySQL, self).install_package()
|
||||||
|
if package.backend.FORMAT == "rpm":
|
||||||
|
utils.exec_cmd("mysqladmin -u root password '{}'".format(self.dbpassword))
|
||||||
|
|
||||||
def _exec_query(self, query, dbname=None, dbuser=None, dbpassword=None):
|
def _exec_query(self, query, dbname=None, dbuser=None, dbpassword=None):
|
||||||
"""Exec a postgresql query."""
|
"""Exec a mysql query."""
|
||||||
if dbuser is None and dbpassword is None:
|
if dbuser is None and dbpassword is None:
|
||||||
dbuser = self.dbuser
|
dbuser = self.dbuser
|
||||||
dbpassword = self.dbpassword
|
dbpassword = self.dbpassword
|
||||||
@@ -150,6 +152,9 @@ class MySQL(Database):
|
|||||||
self._exec_query(
|
self._exec_query(
|
||||||
"CREATE USER '{}'@'%' IDENTIFIED BY '{}'".format(
|
"CREATE USER '{}'@'%' IDENTIFIED BY '{}'".format(
|
||||||
name, password))
|
name, password))
|
||||||
|
self._exec_query(
|
||||||
|
"CREATE USER '{}'@'localhost' IDENTIFIED BY '{}'".format(
|
||||||
|
name, password))
|
||||||
|
|
||||||
def create_database(self, name, owner):
|
def create_database(self, name, owner):
|
||||||
"""Create a database."""
|
"""Create a database."""
|
||||||
@@ -162,6 +167,9 @@ class MySQL(Database):
|
|||||||
self._exec_query(
|
self._exec_query(
|
||||||
"GRANT ALL PRIVILEGES ON {}.* to '{}'@'%'"
|
"GRANT ALL PRIVILEGES ON {}.* to '{}'@'%'"
|
||||||
.format(dbname, user))
|
.format(dbname, user))
|
||||||
|
self._exec_query(
|
||||||
|
"GRANT ALL PRIVILEGES ON {}.* to '{}'@'localhost'"
|
||||||
|
.format(dbname, user))
|
||||||
|
|
||||||
def load_sql_file(self, dbname, dbuser, dbpassword, path):
|
def load_sql_file(self, dbname, dbuser, dbpassword, path):
|
||||||
"""Load SQL file."""
|
"""Load SQL file."""
|
||||||
|
|||||||
Reference in New Issue
Block a user