Common exceptions and database programming solutions

Performance Test 1.mysqlslap unknown variable 'default-character-set = utf8'

mysqlslap may be used to simulate the load of the server, and outputs timing information. When testing, you can specify the number of concurrent connections, you can specify the SQL statement. If you do not specify the SQL statement, mysqlslap will automatically generate a query schema SELECT statement. But it may be an error

mysqlslap: unknown variable 'default-character-set=utf8'

Modify the configuration file my.ini under the MySQL installation directory, the [client] comment out the following line:

 #default-character-set=utf8

Can be solved, performance testing can continue.

2.mysql命令gruop by报错this is incompatible with sql_mode=only_full_group_by

For GROUP BY aggregate operations, if a column in the SELECT, does not appear in a GROUP BY, then the SQL is not legitimate, because the column is not in the GROUP BY clause, that is to say check out the columns must appear in the group behind by otherwise it will be given, or this field appears in the function inside the polymerization.
Solution a (temporary change):
SQL command line:

set @@GLOBAL.sql_mode='';
set sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

Default turned off ONLY_FULL_GROUP_BY, but restart the MySQL service can not take effect.
Solution two (permanent change):
change my.ini configuration, added at [mysqld] and [MySQL]

sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

Can be permanently changed, restart the MySQL service can also run normally.
Refer https://www.cnblogs.com/jiafeimao-dabai/p/9901108.html .

Published 51 original articles · won praise 184 · views 30000 +

Guess you like

Origin blog.csdn.net/CUFEECR/article/details/103572156