Browse Source

Fix credential issue of Mysql

feature/refactor-php
prabuddha 10 years ago
parent
commit
2096280690
  1. 7
      ee/cli/plugins/stack.py
  2. 2
      ee/cli/plugins/stack_migrate.py
  3. 6
      ee/core/mysql.py
  4. 2
      ee/core/variables.py

7
ee/cli/plugins/stack.py

@ -153,9 +153,14 @@ class EEStackController(CementBaseController):
config = configparser.ConfigParser()
config.read_string(mysql_config)
Log.debug(self, 'Writting configuration into MySQL file')
with open(os.path.expanduser("~")+'/.my.cnf', encoding='utf-8',
conf_path = "/etc/mysql/conf.d/my.cnf"
os.makedirs(os.path.dirname(conf_path), exist_ok=True)
with open(conf_path, encoding='utf-8',
mode='w') as configfile:
config.write(configfile)
Log.debug(self, 'Setting my.cnf permission')
EEFileUtils.chmod(self, "/etc/mysql/conf.d/my.cnf", 0o600)
if set(EEVariables.ee_nginx).issubset(set(apt_packages)):
Log.info(self, "Adding repository for NGINX, please wait...")

2
ee/cli/plugins/stack_migrate.py

@ -46,7 +46,7 @@ class EEStackMigrateController(CementBaseController):
keyserver="keyserver.ubuntu.com")
config = configparser.ConfigParser()
config.read(os.path.expanduser("~")+'/.my.cnf')
config.read('/etc/mysql/conf.d/my.cnf')
try:
chars = config['client']['password']
except Exception as e:

6
ee/core/mysql.py

@ -30,7 +30,7 @@ class EEMysql():
def connect(self):
"""Makes connection with MySQL server"""
try:
connection = pymysql.connect(read_default_file='~/.my.cnf')
connection = pymysql.connect(read_default_file='/etc/mysql/conf.d/my.cnf')
return connection
except ValueError as e:
Log.debug(self, str(e))
@ -42,7 +42,7 @@ class EEMysql():
def dbConnection(self, db_name):
try:
connection = pymysql.connect(db=db_name,
read_default_file='~/.my.cnf')
read_default_file='/etc/mysql/conf.d/my.cnf')
return connection
except DatabaseError as e:
if e.args[1] == '#42000Unknown database \'{0}\''.format(db_name):
@ -57,7 +57,7 @@ class EEMysql():
raise MySQLConnectionError
def execute(self, statement, errormsg='', log=True):
"""Get login details from ~/.my.cnf & Execute MySQL query"""
"""Get login details from /etc/mysql/conf.d/my.cnf & Execute MySQL query"""
connection = EEMysql.connect(self)
log and Log.debug(self, "Exceuting MySQL Statement : {0}"
.format(statement))

2
ee/core/variables.py

@ -70,7 +70,7 @@ class EEVariables():
# MySQL hostname
ee_mysql_host = ""
config = configparser.RawConfigParser()
cnfpath = os.path.expanduser("~")+"/.my.cnf"
cnfpath = "/etc/mysql/conf.d/my.cnf"
if [cnfpath] == config.read(cnfpath):
try:
ee_mysql_host = config.get('client', 'host')

Loading…
Cancel
Save