Category Archives: MySQL

ERROR: mysqld failed while attempting to check config [How to Solve]

Problem Description:

the reason for the pit I encountered in learning docker is that the MySQL image used in the video is 5.7, and I use more than 8.0 (8.0.16) </ font>

Error code


Cause analysis:

Start from the third step, analyze step by step, and directly look at the solutions

1. Pull image

I pulled more than 8.0, so I encountered this pit

docker pull mysql:8.0.16

2. View mirror

docker images

3. Run container

docker run -p 3306:3306 --name mysql \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=root -d mysql:8.0.16

After running, you can see the container ID, but it is empty when viewed with docker PS

4. View container

docker ps

5. View all containers

docker ps -a

6. View log analysis

docker logs 容器id

7. Cause

The configuration location of MySQL is wrong when running the container. The configuration location of MySQL 5.7 is/etc/MySQL. The configuration location above MySQL 8.0 is/etc/MySQL/conf.d. just modify the configuration location according to the MySQL version


Solution:

1. Delete container

docker rm Container id or NAME

2. Modify the configuration of the run container

The conf configuration is modified as shown in the figure below

/mydata/mysql/conf:/etc/mysql
					||
					||
					||
					\/
/mydata/mysql/conf:/etc/mysql/conf.d

3. Rerun

Summary:

Mysql8.0 and above configuration

docker run -p 3306:3306 --name mysql \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql/conf.d \
-e MYSQL_ROOT_PASSWORD=root -d mysql:8.0.16

Mysql5.7 configuration

docker run -p 3306:3306 --name mysql \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=root -d mysql:5.7

[Solved] MySQL connection error: communications link failure

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:Communications link failure

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

1. Causes

Communication link failure occurs when Java connects to the database. Why can’t you log in

2 solution (my situation is invalid)

Method 1

[1] Login mysql,cmd command
mysql -h host address -u username -p user password (for example mysql -hlocalhost -uroot -p123456)

[2] Check the wait_timeout,cmd command.
show global variables like 'wait_timeout';


[3] If the wait_timeout is too small, modify it. cmd command:
set global wait_timeout=604800;
set global interactive_timeout=604800;

Method 2

Add the following parameter to the connection URL: &autoReconnect=true

3. Troubleshooting of other causes

If the above two methods are not solved, check whether there are problems in the server environment and database port.

After investigation, if the database port passes through nginx reverse proxy, or if the database port performs proxy operations through other servers, it is caused by nginx reverse proxy timeout that the database cannot be connected

You need to modify the configuration file of nginx and use steam agent Mysl

stream {
     upstream mysql {
         zone myapp1 64k;
         server localhost:3306 weight=1 max_fails=3 fail_timeout=30s;
     }
     server {
         listen 10086;
         proxy_connect_timeout 1s;
         proxy_timeout 3s;
         proxy_pass mysql;
    }
}

In other cases, you can also check whether the MySQL port has been proxy

[Solved] there are special symbols in the initial password for installing MySQL in Hadoop, and an error is reported

Today, I installed a MySQL database in the server because there was a ‘)’ in the initial password assigned. I always reported an error when entering the password. I tried many changes on the Internet. It’s useless to wrap anything in quotation marks. Next, let’s talk about my solution:

Step 1:

vi /etc/my.cnf

After opening, add a sentence: skip grant tables

The function is equivalent to that no password is required for login

Step 2:

Restart MySQL

systemctl restart mysqld

Step 3:

Direct Logins

mysql -uroot -p

Step 4:

// goto database
use mysql
// refresh the data
flush privileges;

Step 5:

Change password

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'PASSWORD';

Then, delete the just secret free statement and restart MySQL

Login

mysql -uroot -p[NEW PASSWORD]

[Solved] CentOS installs MySQL and starts MySQL with error 2002 (HY000)

MYSQL Startup error: ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (111)

[root@iZ2zei01n7f2wrecqn5249Z ~]# sudo service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Community Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: inactive (dead)
[root@iZ2zei01n7f2wrecqn5249Z ~]# mysqladmin -u root password '123456'
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
[root@iZ2zei01n7f2wrecqn5249Z ~]# sudo mysqladmin -u root password '123456'
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
[root@iZ2zei01n7f2wrecqn5249Z ~]# mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@iZ2zei01n7f2wrecqn5249Z ~]# lsof -i:3306
-bash: lsof: command not found
[root@iZ2zei01n7f2wrecqn5249Z ~]# mysql -uroot -h 127.0.0.1 -p
Enter password: 
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
[root@iZ2zei01n7f2wrecqn5249Z ~]# mysql -uroot -h 127.0.0.1 -p
Enter password: 
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
[root@iZ2zei01n7f2wrecqn5249Z ~]# netstat -ntlp 
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      950/sshd            
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      969/master          
tcp6       0      0 ::1:25                  :::*                    LISTEN      969/master          
[root@iZ2zei01n7f2wrecqn5249Z ~]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
[root@iZ2zei01n7f2wrecqn5249Z ~]# service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Community Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2021-11-01 19:27:48 CST; 14s ago
  Process: 1724 ExecStartPost=/usr/bin/mysql-systemd-start post (code=exited, status=0/SUCCESS)
  Process: 1664 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 1723 (mysqld_safe)
   CGroup: /system.slice/mysqld.service
           ├─1723 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─1890 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/...

Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysql-systemd-start[1664]: Support MySQL by buying support/licenses at http://shop.mysql.com
Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysql-systemd-start[1664]: Note: new default config file not created.
Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysql-systemd-start[1664]: Please make sure your config file is current
Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysql-systemd-start[1664]: WARNING: Default config file /etc/my.cnf exists on the system
Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysql-systemd-start[1664]: This file will be read by default by the MySQL server
Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysql-systemd-start[1664]: If you do not want to use this, either remove it, or use the
Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysql-systemd-start[1664]: --defaults-file argument to mysqld_safe when starting the server
Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysqld_safe[1723]: 211101 19:27:47 mysqld_safe Logging to '/var/log/mysqld.log'.
Nov 01 19:27:47 iZ2zei01n7f2wrecqn5249Z mysqld_safe[1723]: 211101 19:27:47 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Nov 01 19:27:48 iZ2zei01n7f2wrecqn5249Z systemd[1]: Started MySQL Community Server.

Start it.

service mysqld start

Recheck status

service mysqld status

Just as shown above
set the password

mysqladmin -u root password '123456'

Sign in

mysql -u root -p

General error: 2006 MySQL server has gone away [How to Solve]

Congratulations on your journey;

There are many reasons for this. Let’s not talk about the others. Let’s talk about the problems that occurred today; Eliminate the problem of the database itself (my MySQL does not go down at this time.) it is the problem of the program. This problem is that the process always exists, but it has not operated the database for too long, resulting in the disconnection of the database, but suddenly a piece of data comes. At this time, the process will not re link the database, but use the original link (disconnected at this time), so there is no way to find the database, so this error is reported.

Solution:

$round = mt_rand(1, 10);
if ($round == 6) {
    // Query a sql to avoid unavailability of the process due to connection timeout
    $dividend = Db::query("select id from think_member_group where  `id` = 1");
}

A random number. The core of this method is to let your process check the database every few seconds so that the link will not be disconnected.

MYSQL Use cmd to change root password error: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual tha

MYSQL Use cmd to change root password error: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 ‘(“123456”) where user = “root”‘ at line 1

Prompt for SQL syntax error
Change the password with another command

ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';

Modified successfully

[Solved] Druid connection pooling Error: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

Scene restatement

In the morning, I checked the actual operation log of the previous day of the project and found that an exception was generated in the Druid connection pool and MySQL in the springboot project. The reconnection did not affect the system temporarily
the following is the specific error message:

com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

The last packet successfully received from the server was 178,478,007 milliseconds ago.  The last packet sent successfully to the server was 4 milliseconds ago.
	at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:172)
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
	at com.mysql.cj.jdbc.StatementImpl.executeQuery(StatementImpl.java:1247)
	at com.alibaba.druid.filter.FilterChainImpl.statement_executeQuery(FilterChainImpl.java:2363)
	at com.alibaba.druid.filter.FilterAdapter.statement_executeQuery(FilterAdapter.java:2481)
	at com.alibaba.druid.filter.FilterEventAdapter.statement_executeQuery(FilterEventAdapter.java:302)
	at com.alibaba.druid.filter.FilterChainImpl.statement_executeQuery(FilterChainImpl.java:2360)
	at com.alibaba.druid.wall.WallFilter.statement_executeQuery(WallFilter.java:498)
	at com.alibaba.druid.filter.FilterChainImpl.statement_executeQuery(FilterChainImpl.java:2360)
	at com.alibaba.druid.filter.FilterAdapter.statement_executeQuery(FilterAdapter.java:2481)
	at com.alibaba.druid.filter.FilterEventAdapter.statement_executeQuery(FilterEventAdapter.java:302)
	at com.alibaba.druid.filter.FilterChainImpl.statement_executeQuery(FilterChainImpl.java:2360)
	at com.alibaba.druid.proxy.jdbc.StatementProxyImpl.executeQuery(StatementProxyImpl.java:211)
	at com.alibaba.druid.pool.DruidAbstractDataSource.testConnectionInternal(DruidAbstractDataSource.java:1270)
	at com.alibaba.druid.pool.DruidDataSource.getConnectionDirect(DruidDataSource.java:966)
	at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4544)
	at com.alibaba.druid.filter.logging.LogFilter.dataSource_getConnection(LogFilter.java:827)
	at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4540)
	at com.alibaba.druid.filter.FilterAdapter.dataSource_getConnection(FilterAdapter.java:2723)
	at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4540)
	at com.alibaba.druid.filter.stat.StatFilter.dataSource_getConnection(StatFilter.java:661)
	at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4540)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:931)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:923)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:100)
	at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:158)
	at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:116)
	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
	at org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:82)
	at org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:68)
	at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:338)
	at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:84)
	at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)
	at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:326)
	at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
	at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
	at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
	at sun.reflect.GeneratedMethodAccessor100.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
	at com.sun.proxy.$Proxy83.selectList(Unknown Source)
	at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230)
	at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:139)
	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:76)
	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
	at com.sun.proxy.$Proxy91.getTerminalTotalList(Unknown Source)
	at com.tsing.demo.service.DevicesService.getTerminalTotalList(DevicesService.java:118)
	at com.tsing.demo.controller.DevicesTimeMessageController.getDeviceTotalData(DevicesTimeMessageController.java:166)
	at sun.reflect.GeneratedMethodAccessor129.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:197)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:141)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:894)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1061)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:961)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:626)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:888)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure

Analyze the cause of the error

Combined with their own understanding and the analysis of others on the Internet, the positioning is as follows:

    1. since the project uses MySQL database, the “wait_timeout” of MySQL is set to 8 hours without modifying the configuration file. In other words, when a connection is idle for more than 8 hours, it will be automatically closed and recycled by mysql. We use the Druid connection pool to manage the database connection. When MySQL closes a timeout connection, the client just requests the connection from the connection pool. Because the connection pool does not know that the connection is closed by mysql, it will reassign the invalid connection, so this exception will be reported

Solution

1 from the perspective of reason, the simplest solution is to directly modify the MySQL configuration file my.ini and directly set the “wait_timeout” to a larger value, which can be set to about 24 days. However, this does not eliminate such abnormalities from the root, but delays the number and time of abnormal “explosion”
2 modify the Druid connection pool to reduce the connection cycle in the connection pool and recycle invalid connections as much as possible
make the maximum connection lifetime less than the “wait_timeout” time of MySQL.

# Configure the minimum time, in milliseconds, for a connection to survive in the pool
spring.datasource.minEvictableIdleTimeMillis=30000
spring.datasource.maxEvictableIdleTimeMillis=180000

How to Solve MySQL version 5.7+ Group by group error

MySQL-this is incompatible with sql_mode=only_full_group_By error resolution

1. Principle level
this error occurs in MySQL version 5.7 and above:

   The default sql configuration for mysql 5.7 is: sql_mode="ONLY_FULL_GROUP_BY", which strictly enforces the "SQL92 standard".

   When upgrading from 5.6 to 5.7, most of them choose to adjust sql_mode to make it consistent with 5.6 in order to be as compatible as possible with the program.

2. SQL level

    In sql execution, the cause appears.

    Simply put: the output is called target list, which is the field followed by select, and a place group by column, which is

    group by followed by the field. Because the ONLY_FULL_GROUP_BY setting is turned on, so if a field is not in the target list 

    and group by fields, or the value of the aggregation function, then this sql query is considered illegal by mysql and will report an error.

Translated with www.DeepL.com/Translator (free version)

1. View the statement of SQL_mode is as follows

select @@GLOBAL.sql_mode;

Second, the solution – (recommended solution two)
① solution one: sql statement temporarily modify sql_mode
set @@GLOBAL.sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Question.

          After restarting the mysql database service, ONLY_FULL_GROUP_BY will still appear.

② Solution 2: perfect solution.

To modify the MySQL configuration file, add SQL manually_ Mode is mandatory. Only is not required_ FULL_ GROUP_ By attribute,
VI/etc/my. CNF
Add or modify configuration file:
sql_mode =‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISIN_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION’

Restart the MySQL service and solve it successfully.

	service mysqld restart

MySQL OrderBy Error: Expression #1 of ORDER BY

Add any_value () package to all non-aggregated columns (that is, data directly fetched in the table)

**Note: The columns used in order by should also be wrapped**

The ANY_VALUE() function is useful when the ONLY_FULL_GROUP_BY mode is enabled and GROUP BY is used for query; this function is used to suppress the value rejection caused when the ONLY_FULL_GROUP_BY mode is enabled;
example:

SELECT
	any_value ( a.id ) AS id,
	a.footprint_id AS footprintId,
	any_value ( a.footprint_type ) AS footprintType,
	any_value ( a.user_id ) AS userId 
FROM
	info_footprint a 
WHERE
	a.footprint_type = 3 
	AND a.user_id = 1 
	AND a.del_flag = '0' 
GROUP BY
	footprint_id 
ORDER BY
	any_value(a.id) DESC 
	LIMIT 10;

Dbeaver Import SQL File Error: Error executing process Process failed (exit code = 1). See error log. Process failed (exit code = 1). See error log.

****Dbeaver7. Error in importing SQL file error executing process failed (exit code = 1). See error log. Process failed (exit code = 1). See error log

It may be because the import file contains the datetime type and the default table is 0. In the mysql configuration file (my.ini), check whether it contains sql_mode=ONLY_FULL_GROUP_BY, STRICT_TRANS_TABLES, ERROR_FOR_DIVISION_BY_ZERO, NO_ENGINE_SUBSTITUTION, if not, add it at the end of the document Can.

[Solved] no all patern found! & Error on Generate Activation Code…

No all pattern found! And error on generate activation code

Error 1: no all pattern found!

Solution: Win + R, enter regedit

Computer found\HKEY_CURRENT_User\software\premiersoft,
delete Navicat in premiersoft and start again

Error 2: error on generate activation code

Solution: if the network is not disconnected during the operation, restart after the network is disconnected

[Solved] MySQL: Syntax error or access violation: 1055 Expression #1 of SELECT list is not …

Reason for error.
MySQL 5.7.5 and above implements detection of functional dependencies. If only_full_group_by SQL mode is enabled (which it is by default), then MySQL rejects queries referenced by select lists, conditions, or sequential lists that will refer to unnamed non-aggregated columns in the group, rather than depend on them functionally. (Prior to 5.7.5, MySQL did not detect functional dependencies, and only_full_group_by was not enabled by default. For a description of the pre-5.7.5 behavior, see the MySQL 5.6 Reference Manual.)
You can view the contents of sql_mode by executing the following command.

 

  mysql> SHOW SESSION VARIABLES;

mysql> SHOW GLOBAL VARIABLES;

mysql> select @@sql_mode;

It can be seen that the value of sql_mode for both session and global is

ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

only_full_group_by Description. 
only_full_group_by : use this is to use the same group rules as oracle, select the columns to be in the group, or itself is an aggregated column (SUM, AVG, MAX, MIN) only, in fact, this configuration is currently a personal feeling and distinct similar, so remove the good

Solution:
Execute the following two commands.

mysql> set global sql_mode=’STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION’;

mysql> set session sql_mode=’STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION’;

These two commands, remove the sql_mode of ONLY_FULL_GROUP_BY
However, many users say to directly modify the mysql configuration file by adding sql_mode= to my.ini

[mysqld]
sql_mode=

Huang has also tried it himself. It’s really OK!