Description:
I used "-default-character-set=cp1256" option to login the mysql, and excuted sql end with backtick '`', like "select a,b,c from `t1`;". It caused an error.
How to repeat:
(1)I used the fllowing commend to login the mysql:
mysql -uroot -proot -default-character-set=cp1256
execute some SQL end with backtick '`':
mysql> select a,b,c from t1;
+---------+------+------+
| a | b | c |
+---------+------+------+
| 9999999 | 123 | nice |
+---------+------+------+
1 row in set (0.00 sec)
mysql> select `a`,b,c from t1;
+---------+------+------+
| a | b | c |
+---------+------+------+
| 9999999 | 123 | nice |
+---------+------+------+
1 row in set (0.00 sec)
mysql> select `a`,b,c from `t1`;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`t1' at line 1
mysql> select a,b,c from `t1`;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`t1' at line 1
mysql> select a,b,c from `t1` limit 1;
+---------+------+------+
| a | b | c |
+---------+------+------+
| 9999999 | 123 | nice |
+---------+------+------+
1 row in set (0.00 sec)
As you can see, if the SQL is end with backtick '`', like select a,b,c from `t1`, it will cause error.
(2)And I also test other charset. The fllowing is the case:
C:\Users\jiekc>mysql -uroot -proot --default-character-set=cp1256 tt -e "select * from `t1`"
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`t1' at line 1
C:\Users\jiekc>mysql -uroot -proot --default-character-set=utf8mb4 tt -e "select * from `t1`"
mysql: [Warning] Using a password on the command line interface can be insecure.
+---------+------+------+
| a | b | c |
+---------+------+------+
| 9999999 | 123 | nice |
+---------+------+------+
C:\Users\jiekc>mysql -uroot -proot --default-character-set=gbk tt -e "select * from `t1`"
mysql: [Warning] Using a password on the command line interface can be insecure.
+---------+------+------+
| a | b | c |
+---------+------+------+
| 9999999 | 123 | nice |
+---------+------+------+
C:\Users\jiekc>mysql -uroot -proot --default-character-set=cp1257 tt -e "select * from `t1`"
mysql: [Warning] Using a password on the command line interface can be insecure.
+---------+------+------+
| a | b | c |
+---------+------+------+
| 9999999 | 123 | nice |
+---------+------+------+