Bug #71487 when running on a server with hostname using‘_’, mysql gives incorrect result
Submitted: 27 Jan 2014 8:53 Modified: 27 Jan 2014 15:06
Reporter: sevenElle chow Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.6.14 OS:Linux
Assigned to: CPU Architecture:Any
Tags: hostname;

[27 Jan 2014 8:53] sevenElle chow
Description:
Mysql running on a sever with hostname using '_', and I connect to MySQL server on this given host, it seems like sometimes mysql is able to give correct result(using escape character),sometimes not.

example:

[zhl@U31_01 log]$ hostname
U31_01

[zhl@U31_01 etc]$ mysql -h**** -P**** -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use mysql
Database changed
mysql> select user,host from user\G;
*************************** 1. row ***************************
user: root
host: U31\_01
.......................
6 rows in set (0.01 sec)

mysql> select user();
+-------------+
| user()      |
+-------------+
| root@U31_01 |
+-------------+
1 row in set (0.00 sec)

mysql> CREATE TABLE t (qty INT, price INT);
INSERT INTO t VALUES(3, 50);
CREATE VIEW v AS SELECT qty, price, qty*price AS value FROM t;Query OK, 0 rows affected (0.27 sec)

mysql> INSERT INTO t VALUES(3, 50);
Query OK, 1 row affected (0.03 sec)

mysql> CREATE VIEW v AS SELECT qty, price, qty*price AS value FROM t;
Query OK, 0 rows affected (0.03 sec)

mysql> SELECT * FROM v;
ERROR 1449 (HY000): The user specified as a definer ('root'@'U31\_01') does not exist

mysql> drop view v;
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE VIEW v AS SELECT qty, price, qty*price AS value FROM t;
Query OK, 0 rows affected (0.03 sec)

How to repeat:
see above

Suggested fix:
return right result when using a hostname with'_'
[27 Jan 2014 11:40] Hartmut Holzgraefe
How did you manage to set a hostname that contains "_" in the first place?

It is not a valid character for DNS host names for sure, and the "hostname" command refuses to accept it ...
[27 Jan 2014 11:44] Hartmut Holzgraefe
Ok, it is possible to set such a hostname in /etc/hostname directly, but it is still a very bad idea IMHO, e.g. on my Ubuntu laptop X11 doesn't come up if I try to boot it with a name that contains an underscore in /etc/hostname ...
[27 Jan 2014 15:06] Sveta Smirnova
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://dev.mysql.com/doc/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

As Hartmut truly noted hostname you use is not valid. See http://tools.ietf.org/html/rfc1123 and http://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names