File tree Expand file tree Collapse file tree 2 files changed +24
-6
lines changed Expand file tree Collapse file tree 2 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
44
55## Unreleased
66
7+ Fix #715 : Update ` db_initialized? ` to be based on database connection instead of file existence
8+
79## 11.1.9 - * 2024-12-09*
810
911## 11.1.8 - * 2024-11-18*
@@ -661,7 +663,7 @@ Adding Ubuntu 13.04 to Platforminfo
661663- ** [ COOK-2966] - Address foodcritic failures'
662664- ** [ COOK-4182] - Template parse failure in /etc/init/mysql.conf (data_dir)'
663665- ** [ COOK-4198] - Added missing tunable'
664- - ** [ COOK-4206
] - create
[email protected] , as well as root@localhost'
666+ - ** [ COOK-4206
] - create
` [email protected] ` , as well as
` root@localhost ` '
665667
666668## [ 4.0.20] - 2014-01-18
667669
Original file line number Diff line number Diff line change @@ -257,11 +257,21 @@ def db_init
257257 end
258258
259259 def db_initialized?
260- if v80plus
261- ::File . exist? "#{ data_dir } /mysql.ibd"
262- else
263- ::File . exist? "#{ data_dir } /mysql/user.frm"
264- end
260+ cmd = shell_out ( "test \" #{ db_initialized_check_cmd } \" -gt 0" , user : 'root' )
261+ cmd . exitstatus == 0
262+ end
263+
264+ def db_initialized_check_cmd
265+ # If MySQL is running, mysqladmin ping will return 0 even with invalid credentials
266+ # if MySQL is not running, mysqladmin will return 1 even with valid credentials
267+ cmd = mysqladmin_bin
268+ cmd << ' --user=UNKNOWN_MYSQL_USER'
269+ cmd << ' ping > /dev/null 2>&1 &&'
270+ cmd << " #{ mysql_client_bin } #{ defaults_file } "
271+ cmd << ' --skip-column-names --batch'
272+ cmd << " --execute=\" SELECT count(*) FROM mysql.db WHERE db LIKE 'test%'\" "
273+ return "scl enable #{ scl_name } \" #{ cmd } \" " if scl_package?
274+ cmd
265275 end
266276
267277 def mysql_install_db_bin
@@ -279,6 +289,12 @@ def mysql_install_db_cmd
279289 cmd
280290 end
281291
292+ def mysql_client_bin
293+ return "#{ prefix_dir } /bin/mysql" if platform_family? ( 'smartos' )
294+ return 'mysql' if scl_package?
295+ "#{ prefix_dir } /usr/bin/mysql"
296+ end
297+
282298 def mysqladmin_bin
283299 return "#{ prefix_dir } /bin/mysqladmin" if platform_family? ( 'smartos' )
284300 return 'mysqladmin' if scl_package?
You can’t perform that action at this time.
0 commit comments