Skip to content

Commit e9a4a2f

Browse files
committed
Support for remote mysql #147
1 parent 1332986 commit e9a4a2f

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

config/easyengine/ee.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
ip-address =
77

88
[mysql]
9-
host = localhost
9+
client-host = localhost
1010
db-name = false
1111
db-user = false
1212

src/lib/ee_lib_mysql_info.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ function ee_lib_mysql_info()
1212
local ee_mysql_max_used_connections=$(mysql -e "show global status" | grep Max_used_connections | awk '{print($2)}')
1313

1414
ee_lib_echo
15-
ee_lib_echo "MySQL ($ee_mysql_version):"
16-
ee_lib_echo_escape "user\t\t\t\t \033[37m$EE_MYSQL_USER"
15+
ee_lib_echo "MySQL ($ee_mysql_version) on $EE_MYSQL_HOST:"
1716
ee_lib_echo_escape "port\t\t\t\t \033[37m$ee_mysql_port"
1817
ee_lib_echo_escape "wait_timeout\t\t\t \033[37m$ee_mysql_wait_timeout"
1918
ee_lib_echo_escape "interactive_timeout\t\t \033[37m$ee_mysql_interactive_timeout"

src/lib/ee_lib_variables.sh

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,15 @@ else
3939
fi
4040

4141
# Find out MySQL hostname
42-
if [ -z $($EE_CONFIG_GET mysql.host) ]; then
42+
if [ -z $(git config --file $HOME/.my.cnf client.host) ]; then
4343
readonly EE_MYSQL_HOST=localhost
4444
else
45-
readonly EE_MYSQL_HOST=$($EE_CONFIG_GET mysql.host)
45+
readonly EE_MYSQL_HOST=$(git config --file $HOME/.my.cnf client.host)
4646
fi
4747

48-
# Find out MySQL login
49-
if [ -f ~/.my.cnf ];then
50-
readonly EE_MYSQL_USER=$(cat ~/.my.cnf | grep user | cut -d'=' -f2)
51-
readonly EE_MYSQL_PASS=$(cat ~/.my.cnf | grep pass | cut -d'=' -f2 | sed -e 's/^"//' -e 's/"$//')
52-
elif [ -f /root/.my.cnf ];then
53-
readonly EE_MYSQL_USER=$(cat /root/.my.cnf | grep user | cut -d'=' -f2)
54-
readonly EE_MYSQL_PASS=$(cat /root/.my.cnf | grep pass | cut -d'=' -f2 | sed -e 's/^"//' -e 's/"$//')
48+
# Find out MySQL client-host to setup grants
49+
if [ -z $($EE_CONFIG_GET mysql.client-host) ]; then
50+
readonly EE_MYSQL_CLIENT_HOST=localhost
51+
else
52+
readonly EE_MYSQL_CLIENT_HOST=$($EE_CONFIG_GET mysql.client-host)
5553
fi

src/modules/site/create/ee_mod_setup_database.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ function ee_mod_setup_database()
5656
|| ee_lib_error "Unable to create $EE_DB_NAME database, exit status = " $?
5757

5858
# Create MySQL User
59-
mysql -e "create user '$EE_DB_USER'@'$EE_MYSQL_HOST' identified by '$EE_DB_PASS'" \
59+
mysql -e "create user '$EE_DB_USER'@'$EE_MYSQL_CLIENT_HOST' identified by '$EE_DB_PASS'" \
6060
|| ee_lib_error "Unable to create $EE_DB_USER database user, exit status = " $?
6161

6262
# Grant permission
63-
mysql -e "grant all privileges on \`$EE_DB_NAME\`.* to '$EE_DB_USER'@'$EE_MYSQL_HOST'" \
63+
mysql -e "grant all privileges on \`$EE_DB_NAME\`.* to '$EE_DB_USER'@'$EE_MYSQL_CLIENT_HOST'" \
6464
|| ee_lib_error "Unable to grant privileges for $EE_DB_USER database user, exit status = " $?
6565
mysql -e "flush privileges"
6666
}

0 commit comments

Comments
 (0)