Bug #60995 "show variables like 'datadir';" return empty.
Submitted: 28 Apr 2011 17:59 Modified: 28 Feb 2013 16:22
Reporter: jie zhang Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Options Severity:S2 (Serious)
Version:5.5.11 x32 OS:Microsoft Windows (windows 7 x64, XP SP3 32-bit)
Assigned to: CPU Architecture:Any

[28 Apr 2011 17:59] jie zhang
Description:
"show variables like 'datadir';"  return empty.

How to repeat:
Always.
[28 Apr 2011 18:02] Valeriy Kravchuk
Please, copy/paste the exact statement and results, like this:

macbook-pro:5.1 openxs$ bin/mysql -uroot test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.1.57-debug Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show variables like 'datadir';
+---------------+----------------------------+
| Variable_name | Value                      |
+---------------+----------------------------+
| datadir       | /Users/openxs/dbs/5.1/var/ |
+---------------+----------------------------+
1 row in set (0.00 sec)
[28 Apr 2011 18:06] jie zhang
L:\mysql-5.5.11-win32\bin>mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.5.11-log MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show variables like 'datadir';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| datadir       |       |
+---------------+-------+
1 row in set (0.00 sec)

mysql>
[28 Apr 2011 19:04] Valeriy Kravchuk
Please, send the content of my.ini file used.
[28 Apr 2011 19:12] MySQL Verification Team
i found this earlier...

I:\mysql\5.5\5.5.11\mysql-5.5.11-winx64\bin>mysqld-debug --no-defaults --console --skip-gr --skip-na

mysql> show variables like 'datadir';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| datadir       |       |
+---------------+-------+
1 row in set (1.49 sec)

the datadir in use is actually:
I:\mysql\5.5\5.5.11\mysql-5.5.11-winx64\data
[28 Apr 2011 19:25] jie zhang
my.ini  is original of  my-huge.ini.
[29 Apr 2011 7:40] Valeriy Kravchuk
Verified just as described in the last comment by Shane:

C:\Program Files\MySQL\MySQL Server 5.5\bin>mysql -uroot -P3306
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.11 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show variables like 'datadir';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| datadir       |       |
+---------------+-------+
1 row in set (0.00 sec)
[10 Aug 2011 13:30] Santo Leto
You hit this bug if you don't set a specific datadir in your configuration file. If you set it, it is shown by show variables like 'datadir';

So if you download the archive pck, unzip it and start the server with

mysqld.exe --defaults-file=your_ini.ini

when your configuration file your_ini.ini does not contain the option datadir (like in the default ini files) show variables like 'datadir'; returns an empty value.
[28 Feb 2013 16:22] Paul Dubois
Noted in 5.5.31, 5.6.11, 5.7.1 changelogs.

If the server was started without a --datadir option, SHOW VARIABLES
could show an empty value for the datadir system variable.