From 5665884209ae9364d262d5ae6596a289faf18531 Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 4 Dec 2013 23:12:22 +0100 Subject: EL6.4 doesn't know about bdb --- files/config/my.cnf.CentOS | 2 -- 1 file changed, 2 deletions(-) (limited to 'files') diff --git a/files/config/my.cnf.CentOS b/files/config/my.cnf.CentOS index 1be434a..3e152b6 100644 --- a/files/config/my.cnf.CentOS +++ b/files/config/my.cnf.CentOS @@ -9,8 +9,6 @@ old_passwords=0 bind-address=127.0.0.1 -skip-bdb - # Query cache is used to cache SELECT results and later return them # without actual executing the same query once again. Having the query # cache enabled may result in significant speed improvements, if your -- cgit v1.2.3 From bad8721b44b01e9656257a19ae334d46231d2c3d Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 4 Dec 2013 23:19:09 +0100 Subject: also chown the data dir --- files/scripts/CentOS/setmysqlpass.sh | 5 ++++- files/scripts/Debian/setmysqlpass.sh | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'files') diff --git a/files/scripts/CentOS/setmysqlpass.sh b/files/scripts/CentOS/setmysqlpass.sh index 01d8fbf..870494c 100644 --- a/files/scripts/CentOS/setmysqlpass.sh +++ b/files/scripts/CentOS/setmysqlpass.sh @@ -13,8 +13,11 @@ UPDATE mysql.user SET Password=PASSWORD('$rootpw') WHERE User='root' AND Host='l FLUSH PRIVILEGES; EOF killall mysqld +sleep 15 # chown to be on the safe side -chown mysql.mysql /var/lib/mysql/mysql-bin.* +ls -al /var/lib/mysql/mysql-bin.* &> /dev/null +[ $? == 0 ] && chown mysql.mysql /var/lib/mysql/mysql-bin.* +chown -R mysql.mysql /var/lib/mysql/data/ /sbin/service mysqld start diff --git a/files/scripts/Debian/setmysqlpass.sh b/files/scripts/Debian/setmysqlpass.sh index f7d5357..1ef4aaa 100644 --- a/files/scripts/Debian/setmysqlpass.sh +++ b/files/scripts/Debian/setmysqlpass.sh @@ -17,6 +17,7 @@ sleep 15 # chown to be on the safe side ls -al /var/lib/mysql/mysql-bin.* &> /dev/null [ $? == 0 ] && chown mysql.mysql /var/lib/mysql/mysql-bin.* +chown -R mysql.mysql /var/lib/mysql/data/ /etc/init.d/mysql start -- cgit v1.2.3 From 808a83374cc96e93971c80fc08c503981f8e9bc5 Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 4 Dec 2013 23:24:59 +0100 Subject: rename deprecated option --- files/config/my.cnf.CentOS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'files') diff --git a/files/config/my.cnf.CentOS b/files/config/my.cnf.CentOS index 3e152b6..7265fdd 100644 --- a/files/config/my.cnf.CentOS +++ b/files/config/my.cnf.CentOS @@ -25,7 +25,7 @@ query_cache_size = 64M # indexes well, if log_long_format is enabled. It is normally good idea # to have this turned on if you frequently add new queries to the # system. -log_slow_queries +slow_query_log # How many threads we should keep in a cache for reuse. When a client # disconnects, the client's threads are put in the cache if there aren't @@ -34,7 +34,7 @@ log_slow_queries # connections. (Normally this doesn't give a notable performance # improvement if you have a good thread implementation.) thread_cache_size = 4 - + # InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and # row data. The bigger you set this the less disk I/O is needed to # access data in tables. On a dedicated database server you may set this -- cgit v1.2.3 From eb03b7f647f7f17d86a9314150a31edf3f9880a4 Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 4 Dec 2013 23:40:38 +0100 Subject: update to latest EL release --- files/config/my.cnf.CentOS | 3 +++ 1 file changed, 3 insertions(+) (limited to 'files') diff --git a/files/config/my.cnf.CentOS b/files/config/my.cnf.CentOS index 7265fdd..1b6ee1a 100644 --- a/files/config/my.cnf.CentOS +++ b/files/config/my.cnf.CentOS @@ -9,6 +9,9 @@ old_passwords=0 bind-address=127.0.0.1 +# Disabling symbolic-links is recommended to prevent assorted security risks +symbolic-links=0 + # Query cache is used to cache SELECT results and later return them # without actual executing the same query once again. Having the query # cache enabled may result in significant speed improvements, if your -- cgit v1.2.3 From 1caaa07190f05cf2e5a535de271f249321f9f8d2 Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 5 Dec 2013 10:47:25 +0100 Subject: some reasonable defaults --- files/config/my.cnf.CentOS | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'files') diff --git a/files/config/my.cnf.CentOS b/files/config/my.cnf.CentOS index 1b6ee1a..58090f7 100644 --- a/files/config/my.cnf.CentOS +++ b/files/config/my.cnf.CentOS @@ -7,7 +7,11 @@ socket=/var/lib/mysql/mysql.sock # clients (those using the mysqlclient10 compatibility package). old_passwords=0 +character-set-server = utf8 +skip-name-resolve + bind-address=127.0.0.1 +max_allowed_packet = 10M # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 @@ -46,12 +50,27 @@ thread_cache_size = 4 # cause paging in the operating system. Note that on 32bit systems you # might be limited to 2-3.5G of user level memory per process, so do not # set it too high. +innodb_data_home_dir = /var/lib/mysql/data +innodb_data_file_path = ibdata1:10M:autoextend +innodb_log_group_home_dir = /var/lib/mysql/ innodb_buffer_pool_size = 50MB innodb_file_per_table query_cache_limit=5M +[mysql] +no-auto-rehash +# Remove the next comment character if you are not familiar with SQL +#safe-updates +default-character-set=utf8 + +[mysqlimport] +default-character-set=utf8 + +[mysqlshow] +default-character-set=utf8 + [mysql.server] user=mysql basedir=/usr @@ -59,3 +78,9 @@ basedir=/usr [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid + +[mysqldump] +quick +max_allowed_packet = 16M +default-character-set=utf8 + -- cgit v1.2.3 From c38546e15fe62e964c63b03222cc3c2824ee5c36 Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 5 Dec 2013 20:14:04 +0100 Subject: introduce the /etc/mysql/conf.d/ directory for CentOS --- files/config/my.cnf.CentOS | 1 + 1 file changed, 1 insertion(+) (limited to 'files') diff --git a/files/config/my.cnf.CentOS b/files/config/my.cnf.CentOS index 58090f7..1abf15c 100644 --- a/files/config/my.cnf.CentOS +++ b/files/config/my.cnf.CentOS @@ -84,3 +84,4 @@ quick max_allowed_packet = 16M default-character-set=utf8 +!includedir /etc/mysql/conf.d/ -- cgit v1.2.3 From 7bde4efe1e680d21dfa8ecd15e5e9a3c5eb41df2 Mon Sep 17 00:00:00 2001 From: mh Date: Sun, 12 Jan 2014 14:19:26 +0100 Subject: improve optimize script --- files/scripts/optimize_tables.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'files') diff --git a/files/scripts/optimize_tables.rb b/files/scripts/optimize_tables.rb index 46e223e..e1a71ef 100644 --- a/files/scripts/optimize_tables.rb +++ b/files/scripts/optimize_tables.rb @@ -3,10 +3,12 @@ # set home as we runit as weekly cron, where HOME is / ENV['HOME'] = '/root' tables = %x{mysql -Bse "SELECT TABLE_SCHEMA,TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema','mysql') AND Data_free > 0 AND ENGINE IN ('MyISAM','InnoDB','ARCHIVE')"} -tables.each { |table| - tableitems = table.chomp.split(/\t/) - system "mysql #{tableitems[0]} -Bse \"OPTIMIZE TABLE \\`#{tableitems[0]}\\`.\\`#{tableitems[1]}\\`\" | grep -q OK" - if $?.to_i > 0 then - puts "error while optimizing #{tableitems[0]}.#{tableitems[1]}" - end -} +tables.each do |table| + tableitems = table.chomp.split(/\t/) + output = %x{mysql #{tableitems[0]} -Bse "OPTIMIZE TABLE \\`#{tableitems[0]}\\`.\\`#{tableitems[1]}\\`" 2>&1} + unless output =~ /status\t+OK/ + puts "Error while optimizing #{tableitems[0]}.#{tableitems[1]}:" + puts output + puts + end +end -- cgit v1.2.3 From cae3a3cbe85d1dffcd7a7a964669d2b758561dc0 Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 5 Feb 2014 22:34:17 +0100 Subject: fix #6638 - remove the unless check & improve script To workaround a limitation of the exec provider within puppet, we do the unless check no within the script itself and ensure that we use the password there. https://labs.riseup.net/code/issues/6638 --- files/scripts/CentOS/setmysqlpass.sh | 2 ++ files/scripts/Debian/setmysqlpass.sh | 2 ++ 2 files changed, 4 insertions(+) (limited to 'files') diff --git a/files/scripts/CentOS/setmysqlpass.sh b/files/scripts/CentOS/setmysqlpass.sh index 870494c..8b468e1 100644 --- a/files/scripts/CentOS/setmysqlpass.sh +++ b/files/scripts/CentOS/setmysqlpass.sh @@ -4,6 +4,8 @@ test -f /root/.my.cnf || exit 1 rootpw=$(grep password /root/.my.cnf | sed -e 's/^[^=]*= *\(.*\) */\1/') +/usr/bin/mysqladmin -uroot --password="${rootpw}" status > /dev/null && echo "Nothing to do as the password already works" && exit 0 + /sbin/service mysqld stop /usr/libexec/mysqld --skip-grant-tables --user=root --datadir=/var/lib/mysql/data --log-bin=/var/lib/mysql/mysql-bin & diff --git a/files/scripts/Debian/setmysqlpass.sh b/files/scripts/Debian/setmysqlpass.sh index 1ef4aaa..ec2c971 100644 --- a/files/scripts/Debian/setmysqlpass.sh +++ b/files/scripts/Debian/setmysqlpass.sh @@ -4,6 +4,8 @@ test -f /root/.my.cnf || exit 1 rootpw=$(grep password /root/.my.cnf | sed -e 's/^[^=]*= *\(.*\) */\1/') +/usr/bin/mysqladmin -uroot --password="${rootpw}" status > /dev/null && echo "Nothing to do as the password already works" && exit 0 + /etc/init.d/mysql stop /usr/sbin/mysqld --skip-grant-tables --user=root --datadir=/var/lib/mysql --log-bin=/var/lib/mysql/mysql-bin & -- cgit v1.2.3 From 02c8f3342ec9de4a822e68f3f494f7c108bff574 Mon Sep 17 00:00:00 2001 From: mh Date: Sat, 10 Jan 2015 02:18:15 +0100 Subject: introduce new mariadb based config for EL7 --- files/config/my.cnf.CentOS | 45 ++++++----------------- files/config/my.cnf.CentOS.5 | 87 ++++++++++++++++++++++++++++++++++++++++++++ files/config/my.cnf.CentOS.6 | 87 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 186 insertions(+), 33 deletions(-) create mode 100644 files/config/my.cnf.CentOS.5 create mode 100644 files/config/my.cnf.CentOS.6 (limited to 'files') diff --git a/files/config/my.cnf.CentOS b/files/config/my.cnf.CentOS index 1abf15c..c15d2b8 100644 --- a/files/config/my.cnf.CentOS +++ b/files/config/my.cnf.CentOS @@ -3,19 +3,16 @@ datadir=/var/lib/mysql/data log-bin=/var/lib/mysql/mysql-bin expire_logs_days=5 socket=/var/lib/mysql/mysql.sock -# Default to using old password format for compatibility with mysql 3.x -# clients (those using the mysqlclient10 compatibility package). -old_passwords=0 - -character-set-server = utf8 -skip-name-resolve +# Disabling symbolic-links is recommended to prevent assorted security risks +symbolic-links=0 +# Settings user and group are ignored when systemd is used. +# If you need to run mysqld under a different user or group, +# customize your systemd unit file for mariadb according to the +# instructions in http://fedoraproject.org/wiki/Systemd bind-address=127.0.0.1 max_allowed_packet = 10M -# Disabling symbolic-links is recommended to prevent assorted security risks -symbolic-links=0 - # Query cache is used to cache SELECT results and later return them # without actual executing the same query once again. Having the query # cache enabled may result in significant speed improvements, if your @@ -59,29 +56,11 @@ innodb_file_per_table query_cache_limit=5M -[mysql] -no-auto-rehash -# Remove the next comment character if you are not familiar with SQL -#safe-updates -default-character-set=utf8 - -[mysqlimport] -default-character-set=utf8 - -[mysqlshow] -default-character-set=utf8 - -[mysql.server] -user=mysql -basedir=/usr - [mysqld_safe] -log-error=/var/log/mysqld.log -pid-file=/var/run/mysqld/mysqld.pid - -[mysqldump] -quick -max_allowed_packet = 16M -default-character-set=utf8 +log-error=/var/log/mariadb/mariadb.log +pid-file=/var/run/mariadb/mariadb.pid -!includedir /etc/mysql/conf.d/ +# +# include all files from the config directory +# +!includedir /etc/my.cnf.d diff --git a/files/config/my.cnf.CentOS.5 b/files/config/my.cnf.CentOS.5 new file mode 100644 index 0000000..1abf15c --- /dev/null +++ b/files/config/my.cnf.CentOS.5 @@ -0,0 +1,87 @@ +[mysqld] +datadir=/var/lib/mysql/data +log-bin=/var/lib/mysql/mysql-bin +expire_logs_days=5 +socket=/var/lib/mysql/mysql.sock +# Default to using old password format for compatibility with mysql 3.x +# clients (those using the mysqlclient10 compatibility package). +old_passwords=0 + +character-set-server = utf8 +skip-name-resolve + +bind-address=127.0.0.1 +max_allowed_packet = 10M + +# Disabling symbolic-links is recommended to prevent assorted security risks +symbolic-links=0 + +# Query cache is used to cache SELECT results and later return them +# without actual executing the same query once again. Having the query +# cache enabled may result in significant speed improvements, if your +# have a lot of identical queries and rarely changing tables. See the +# "Qcache_lowmem_prunes" status variable to check if the current value +# is high enough for your load. +# Note: In case your tables change very often or if your queries are +# textually different every time, the query cache may result in a +# slowdown instead of a performance improvement. +query_cache_size = 64M + +# Log slow queries. Slow queries are queries which take more than the +# amount of time defined in "long_query_time" or which do not use +# indexes well, if log_long_format is enabled. It is normally good idea +# to have this turned on if you frequently add new queries to the +# system. +slow_query_log + +# How many threads we should keep in a cache for reuse. When a client +# disconnects, the client's threads are put in the cache if there aren't +# more than thread_cache_size threads from before. This greatly reduces +# the amount of thread creations needed if you have a lot of new +# connections. (Normally this doesn't give a notable performance +# improvement if you have a good thread implementation.) +thread_cache_size = 4 + +# InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and +# row data. The bigger you set this the less disk I/O is needed to +# access data in tables. On a dedicated database server you may set this +# parameter up to 80% of the machine physical memory size. Do not set it +# too large, though, because competition of the physical memory may +# cause paging in the operating system. Note that on 32bit systems you +# might be limited to 2-3.5G of user level memory per process, so do not +# set it too high. +innodb_data_home_dir = /var/lib/mysql/data +innodb_data_file_path = ibdata1:10M:autoextend +innodb_log_group_home_dir = /var/lib/mysql/ +innodb_buffer_pool_size = 50MB + +innodb_file_per_table + +query_cache_limit=5M + +[mysql] +no-auto-rehash +# Remove the next comment character if you are not familiar with SQL +#safe-updates +default-character-set=utf8 + +[mysqlimport] +default-character-set=utf8 + +[mysqlshow] +default-character-set=utf8 + +[mysql.server] +user=mysql +basedir=/usr + +[mysqld_safe] +log-error=/var/log/mysqld.log +pid-file=/var/run/mysqld/mysqld.pid + +[mysqldump] +quick +max_allowed_packet = 16M +default-character-set=utf8 + +!includedir /etc/mysql/conf.d/ diff --git a/files/config/my.cnf.CentOS.6 b/files/config/my.cnf.CentOS.6 new file mode 100644 index 0000000..1abf15c --- /dev/null +++ b/files/config/my.cnf.CentOS.6 @@ -0,0 +1,87 @@ +[mysqld] +datadir=/var/lib/mysql/data +log-bin=/var/lib/mysql/mysql-bin +expire_logs_days=5 +socket=/var/lib/mysql/mysql.sock +# Default to using old password format for compatibility with mysql 3.x +# clients (those using the mysqlclient10 compatibility package). +old_passwords=0 + +character-set-server = utf8 +skip-name-resolve + +bind-address=127.0.0.1 +max_allowed_packet = 10M + +# Disabling symbolic-links is recommended to prevent assorted security risks +symbolic-links=0 + +# Query cache is used to cache SELECT results and later return them +# without actual executing the same query once again. Having the query +# cache enabled may result in significant speed improvements, if your +# have a lot of identical queries and rarely changing tables. See the +# "Qcache_lowmem_prunes" status variable to check if the current value +# is high enough for your load. +# Note: In case your tables change very often or if your queries are +# textually different every time, the query cache may result in a +# slowdown instead of a performance improvement. +query_cache_size = 64M + +# Log slow queries. Slow queries are queries which take more than the +# amount of time defined in "long_query_time" or which do not use +# indexes well, if log_long_format is enabled. It is normally good idea +# to have this turned on if you frequently add new queries to the +# system. +slow_query_log + +# How many threads we should keep in a cache for reuse. When a client +# disconnects, the client's threads are put in the cache if there aren't +# more than thread_cache_size threads from before. This greatly reduces +# the amount of thread creations needed if you have a lot of new +# connections. (Normally this doesn't give a notable performance +# improvement if you have a good thread implementation.) +thread_cache_size = 4 + +# InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and +# row data. The bigger you set this the less disk I/O is needed to +# access data in tables. On a dedicated database server you may set this +# parameter up to 80% of the machine physical memory size. Do not set it +# too large, though, because competition of the physical memory may +# cause paging in the operating system. Note that on 32bit systems you +# might be limited to 2-3.5G of user level memory per process, so do not +# set it too high. +innodb_data_home_dir = /var/lib/mysql/data +innodb_data_file_path = ibdata1:10M:autoextend +innodb_log_group_home_dir = /var/lib/mysql/ +innodb_buffer_pool_size = 50MB + +innodb_file_per_table + +query_cache_limit=5M + +[mysql] +no-auto-rehash +# Remove the next comment character if you are not familiar with SQL +#safe-updates +default-character-set=utf8 + +[mysqlimport] +default-character-set=utf8 + +[mysqlshow] +default-character-set=utf8 + +[mysql.server] +user=mysql +basedir=/usr + +[mysqld_safe] +log-error=/var/log/mysqld.log +pid-file=/var/run/mysqld/mysqld.pid + +[mysqldump] +quick +max_allowed_packet = 16M +default-character-set=utf8 + +!includedir /etc/mysql/conf.d/ -- cgit v1.2.3 From fd71b9473fcb4c4e9f839bd9e579e899d424b71f Mon Sep 17 00:00:00 2001 From: mh Date: Mon, 12 Jan 2015 23:29:41 +0100 Subject: split on new line, which fixes an issue if no table is found --- files/scripts/optimize_tables.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'files') diff --git a/files/scripts/optimize_tables.rb b/files/scripts/optimize_tables.rb index e1a71ef..1b76704 100644 --- a/files/scripts/optimize_tables.rb +++ b/files/scripts/optimize_tables.rb @@ -3,7 +3,7 @@ # set home as we runit as weekly cron, where HOME is / ENV['HOME'] = '/root' tables = %x{mysql -Bse "SELECT TABLE_SCHEMA,TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema','mysql') AND Data_free > 0 AND ENGINE IN ('MyISAM','InnoDB','ARCHIVE')"} -tables.each do |table| +tables.split("\n").each do |table| tableitems = table.chomp.split(/\t/) output = %x{mysql #{tableitems[0]} -Bse "OPTIMIZE TABLE \\`#{tableitems[0]}\\`.\\`#{tableitems[1]}\\`" 2>&1} unless output =~ /status\t+OK/ -- cgit v1.2.3 From e1649647f326abeb256a73e4cb1060840f846f24 Mon Sep 17 00:00:00 2001 From: mh Date: Sat, 24 Jan 2015 18:05:08 +0100 Subject: fix issues for EL7 + simplify account security * EL7 uses mariadb & systemd -> adjust setpasswd script to that * move the security ensurance to the setpassword script, as it's easier to ensure that there --- files/scripts/CentOS/setmysqlpass.sh | 10 +++++----- files/scripts/CentOS/setmysqlpass.sh.5 | 26 ++++++++++++++++++++++++++ files/scripts/CentOS/setmysqlpass.sh.6 | 26 ++++++++++++++++++++++++++ files/scripts/Debian/setmysqlpass.sh | 1 + 4 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 files/scripts/CentOS/setmysqlpass.sh.5 create mode 100644 files/scripts/CentOS/setmysqlpass.sh.6 (limited to 'files') diff --git a/files/scripts/CentOS/setmysqlpass.sh b/files/scripts/CentOS/setmysqlpass.sh index 8b468e1..b84aa7a 100644 --- a/files/scripts/CentOS/setmysqlpass.sh +++ b/files/scripts/CentOS/setmysqlpass.sh @@ -6,20 +6,20 @@ rootpw=$(grep password /root/.my.cnf | sed -e 's/^[^=]*= *\(.*\) */\1/') /usr/bin/mysqladmin -uroot --password="${rootpw}" status > /dev/null && echo "Nothing to do as the password already works" && exit 0 -/sbin/service mysqld stop +/usr/bin/systemctl stop mariadb -/usr/libexec/mysqld --skip-grant-tables --user=root --datadir=/var/lib/mysql/data --log-bin=/var/lib/mysql/mysql-bin & +/usr/libexec/mysqld --skip-grant-tables --user=root --datadir=/var/lib/mysql/data --log-bin=/var/lib/mysql/mysql-bin --pid-file=/var/run/mariadb/mariadb.pid & sleep 5 mysql -u root mysql < /dev/null [ $? == 0 ] && chown mysql.mysql /var/lib/mysql/mysql-bin.* chown -R mysql.mysql /var/lib/mysql/data/ -/sbin/service mysqld start - +/usr/bin/systemctl start mariadb diff --git a/files/scripts/CentOS/setmysqlpass.sh.5 b/files/scripts/CentOS/setmysqlpass.sh.5 new file mode 100644 index 0000000..abd0931 --- /dev/null +++ b/files/scripts/CentOS/setmysqlpass.sh.5 @@ -0,0 +1,26 @@ +#!/bin/sh + +test -f /root/.my.cnf || exit 1 + +rootpw=$(grep password /root/.my.cnf | sed -e 's/^[^=]*= *\(.*\) */\1/') + +/usr/bin/mysqladmin -uroot --password="${rootpw}" status > /dev/null && echo "Nothing to do as the password already works" && exit 0 + +/sbin/service mysqld stop + +/usr/libexec/mysqld --skip-grant-tables --user=root --datadir=/var/lib/mysql/data --log-bin=/var/lib/mysql/mysql-bin & +sleep 5 +mysql -u root mysql < /dev/null +[ $? == 0 ] && chown mysql.mysql /var/lib/mysql/mysql-bin.* +chown -R mysql.mysql /var/lib/mysql/data/ + +/sbin/service mysqld start + diff --git a/files/scripts/CentOS/setmysqlpass.sh.6 b/files/scripts/CentOS/setmysqlpass.sh.6 new file mode 100644 index 0000000..abd0931 --- /dev/null +++ b/files/scripts/CentOS/setmysqlpass.sh.6 @@ -0,0 +1,26 @@ +#!/bin/sh + +test -f /root/.my.cnf || exit 1 + +rootpw=$(grep password /root/.my.cnf | sed -e 's/^[^=]*= *\(.*\) */\1/') + +/usr/bin/mysqladmin -uroot --password="${rootpw}" status > /dev/null && echo "Nothing to do as the password already works" && exit 0 + +/sbin/service mysqld stop + +/usr/libexec/mysqld --skip-grant-tables --user=root --datadir=/var/lib/mysql/data --log-bin=/var/lib/mysql/mysql-bin & +sleep 5 +mysql -u root mysql < /dev/null +[ $? == 0 ] && chown mysql.mysql /var/lib/mysql/mysql-bin.* +chown -R mysql.mysql /var/lib/mysql/data/ + +/sbin/service mysqld start + diff --git a/files/scripts/Debian/setmysqlpass.sh b/files/scripts/Debian/setmysqlpass.sh index ec2c971..3a3e336 100644 --- a/files/scripts/Debian/setmysqlpass.sh +++ b/files/scripts/Debian/setmysqlpass.sh @@ -12,6 +12,7 @@ rootpw=$(grep password /root/.my.cnf | sed -e 's/^[^=]*= *\(.*\) */\1/') sleep 5 mysql -u root mysql <