File tree 2 files changed +24
-6
lines changed
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.
4
4
5
5
## Unreleased
6
6
7
+ Fix #715 : Update ` db_initialized? ` to be based on database connection instead of file existence
8
+
7
9
## 11.1.9 - * 2024-12-09*
8
10
9
11
## 11.1.8 - * 2024-11-18*
@@ -661,7 +663,7 @@ Adding Ubuntu 13.04 to Platforminfo
661
663
- ** [ COOK-2966] - Address foodcritic failures'
662
664
- ** [ COOK-4182] - Template parse failure in /etc/init/mysql.conf (data_dir)'
663
665
- ** [ 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 ` '
665
667
666
668
## [ 4.0.20] - 2014-01-18
667
669
Original file line number Diff line number Diff line change @@ -257,11 +257,21 @@ def db_init
257
257
end
258
258
259
259
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
265
275
end
266
276
267
277
def mysql_install_db_bin
@@ -279,6 +289,12 @@ def mysql_install_db_cmd
279
289
cmd
280
290
end
281
291
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
+
282
298
def mysqladmin_bin
283
299
return "#{ prefix_dir } /bin/mysqladmin" if platform_family? ( 'smartos' )
284
300
return 'mysqladmin' if scl_package?
You can’t perform that action at this time.
0 commit comments