From 696494ff41ea0a97ea1c1012585c31aa0c3bde14 Mon Sep 17 00:00:00 2001 From: Etienne Pallier Date: Tue, 18 Jun 2019 18:08:19 +0200 Subject: [PATCH] debug mysql dans install.py --- install/install.py | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/install/install.py b/install/install.py index 1411bc1..649310a 100755 --- a/install/install.py +++ b/install/install.py @@ -269,7 +269,7 @@ def install_database(venv): # -------------------------------------------- # --- Prepare the SQL query to create and initialize the pyros database if needed # -------------------------------------------- - if sql_version<5.5: + if sql_version < 5.5: #sql_query = "drop database "+SQL_DATABASE+" ; CREATE DATABASE "+SQL_DATABASE+"; drop database "+SQL_DATABASE_TEST+" ; CREATE DATABASE "+SQL_DATABASE_TEST+"; CREATE USER "+SQL_USER+" ; GRANT USAGE ON *.* TO '"+SQL_USER+"'@'localhost' IDENTIFIED BY '"+SQL_PSWD+"' WITH GRANT OPTION; DROP USER '"+SQL_USER+"'@'localhost'; GRANT ALL ON "+SQL_DATABASE+".* TO '"+SQL_USER+"'@'localhost' IDENTIFIED BY '"+SQL_PSWD+"'; GRANT ALL PRIVILEGES ON "+SQL_DATABASE+".* TO '"+SQL_USER+"'@'localhost' IDENTIFIED BY '"+SQL_PSWD+"' WITH GRANT OPTION; GRANT ALL PRIVILEGES ON "+SQL_DATABASE_TEST+".* TO "+SQL_USER+"@localhost IDENTIFIED BY '"+SQL_PSWD+"' WITH GRANT OPTION;" sql_query = "" sql_query += "drop database "+SQL_DATABASE+" ; CREATE DATABASE "+SQL_DATABASE+"; " @@ -279,17 +279,29 @@ def install_database(venv): sql_query += "GRANT ALL ON "+SQL_DATABASE+".* TO '"+SQL_USER+"'@'localhost' IDENTIFIED BY '"+SQL_PSWD+"'; " sql_query += "GRANT ALL PRIVILEGES ON "+SQL_DATABASE+".* TO '"+SQL_USER+"'@'localhost' IDENTIFIED BY '"+SQL_PSWD+"' WITH GRANT OPTION; " sql_query += "GRANT ALL PRIVILEGES ON "+SQL_DATABASE_TEST+".* TO "+SQL_USER+"@localhost IDENTIFIED BY '"+SQL_PSWD+"' WITH GRANT OPTION; " - else: - # Ne marche pas sur mysql 5.5.60 : - #"CREATE USER IF NOT EXISTS "+SQL_USER+"; " +\ - sql_query = "CREATE DATABASE IF NOT EXISTS " + SQL_DATABASE +"; " +\ - "CREATE DATABASE IF NOT EXISTS "+SQL_DATABASE_TEST+"; " +\ - "CREATE USER "+SQL_USER+"; " +\ - "GRANT USAGE ON *.* TO '"+SQL_USER+"'; " +\ - "DROP USER '"+SQL_USER+"'; " +\ - "GRANT ALL ON "+SQL_DATABASE+".* TO '"+SQL_USER+"'@'localhost' IDENTIFIED BY '"+SQL_PSWD+"'; " +\ - "GRANT ALL ON "+SQL_DATABASE_TEST+".* TO '"+SQL_USER+"'@'localhost'; " +\ - "GRANT ALL PRIVILEGES ON "+SQL_DATABASE_TEST+".* TO '"+SQL_USER+"'@'localhost'; " +\ + else: # (EP 18/6/19, tout refait) + sql_query = \ + "CREATE DATABASE IF NOT EXISTS " + SQL_DATABASE +"; " +\ + "CREATE DATABASE IF NOT EXISTS " + SQL_DATABASE_TEST +"; " + if sql_version >= 5.7: + sql_create_user = "CREATE USER IF NOT EXISTS "+SQL_USER+"; " + else: # 5.5 <= version < 5.7 + # Si user n'existe pas => est créé ; Si user existe => pas d'erreur ; DONC ok dans les 2 cas + sql_create_user = "GRANT ALL ON "+SQL_DATABASE+".* TO '"+SQL_USER+"'@'localhost' IDENTIFIED BY '"+SQL_PSWD+"'; " + sql_query += sql_create_user + # Ne marche pas si l'utilisateur existe déjà => erreur + #"CREATE USER "+SQL_USER+"; " +\ + ''' + # (EP) AVANT, y avait tout ça..., vraiment utile ? + "GRANT USAGE ON *.* TO '"+SQL_USER+"'; " +\ + "DROP USER '"+SQL_USER+"'; " +\ + "GRANT ALL ON "+SQL_DATABASE+".* TO '"+SQL_USER+"'@'localhost' IDENTIFIED BY '"+SQL_PSWD+"'; " +\ + "GRANT ALL ON "+SQL_DATABASE_TEST+".* TO '"+SQL_USER+"'@'localhost'; " +\ + "GRANT ALL PRIVILEGES ON "+SQL_DATABASE_TEST+".* TO '"+SQL_USER+"'@'localhost'; " +\ + "GRANT ALL ON "+SQL_DATABASE_TEST+".* TO '"+SQL_USER+"'@'localhost' IDENTIFIED BY '"+SQL_PSWD+"' ;" + # J'ai simplifié comme ça : + ''' + sql_query += \ "GRANT ALL ON "+SQL_DATABASE_TEST+".* TO '"+SQL_USER+"'@'localhost' IDENTIFIED BY '"+SQL_PSWD+"' ;" # NEWER MYSQL: # OLDER MYSQL: Try this instead for OLDER mysql (works on CentOS 6.4 and Centos 7.5 with mysql 5.5): -- libgit2 0.21.2