Red Hat Bugzilla – Bug 726150
bacula-dir.conf for mysql support should not point to QueryFile with bad SQL commands
Last modified: 2012-07-18 05:29:32 EDT
Description of problem:
bacula-dir.conf from bacula-dir-mysql indicates as a QueryFile the /etc/bacula/query.sql which seems to contains sample SQL commands. This commands are preventing bacula-dir to collect its catalog.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Manually start bacula-dir (cf bug #726147)
2. run bconsole
3. try any command depending on catalog access (ie list, run etc)
Could not open catalog database "bacula".
mysql.c:194 Unable to connect to MySQL server.
MySQL connect failed either server not running or your authorization is incorrect.
bacula-dir should be able to retrieve its catalog
Changing QueryFile to a even non existent file correct this problem.
It seems like your mysql database configuration is not correct. Try to connect to mysql using user bacula and show all tables:
$ mysql -u bacula -p
myslq> use bacula;
mysql> show tables;
Content of query.sql:
# See the file <bacula-source>/examples/sample-query.sql
# for some sample queries.
:The default file is empty, see <bacula-source>/examples/sample-query.sql for samples
SELECT 'See <bacula-source>/examples/sample-query.sql for samples' AS Info;
How the line starting if : and not ending with ; could be a valid sql query? The last line is ok and do nothing. So even if this file was correct (I don't know may be it is), it's useless. Removing the QueryFile in bacula-dir.conf fix the problem, so if Bacula is working fine and storing cataly in MySQL I can say my database is ok. Or I miss something?
But here is the result of the show tables:
mysql> show tables;
| Tables_in_bacula |
| BaseFiles |
| CDImages |
| Client |
| Counters |
| Device |
| File |
| FileSet |
| Filename |
| Job |
| JobHisto |
| JobMedia |
| Location |
| LocationLog |
| Log |
| Media |
| MediaType |
| Path |
| PathHierarchy |
| PathVisibility |
| Pool |
| Status |
| Storage |
| UnsavedFiles |
| Version |
24 rows in set (0.00 sec)
Is it ok?
(In reply to comment #2)
> Content of query.sql:
> :The default file is empty, see <bacula-source>/examples/sample-query.sql for
> SELECT 'See <bacula-source>/examples/sample-query.sql for samples' AS Info;
> How the line starting if : and not ending with ; could be a valid sql query?
This file is parsed by bacula-dir before executing in mysql. ':' and '*' are characters with special meaning, so this is intentional and probably right.
> mysql> show tables;
> | Tables_in_bacula |
> | BaseFiles |
> | Version |
> 24 rows in set (0.00 sec)
> Is it ok?
It seems ok, have you been connected to mysql using bacula user? I still suspect mysql, at least error message in comment #0 speaks clear: "Unable to connect to MySQL server."
You've mentioned you run bacula-dir directly, not with systemd/init script - so you run it under root, but bacula-dir is usually run under bacula user.
Here is how I manually start bacula:
bacula-dir -c /etc/bacula/bacula-dir.conf -v -f -u bacula -g bacula
I don't run it under but as you said under bacula user. But I also try under root same problem. I have no choice to run it directly because systemd/init script is not working.
As I said if I comment the QueryFile line in bacula-dir.conf it's working fine so... my main concern is bug #726147