Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
722 views
in Technique[技术] by (71.8m points)

Disable ONLY_FULL_GROUP_BY mysql 8 Ubuntu 20.04 LTS

I want to change the default sql_mode to this:

sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

So I set it up inside etc/mysql/mysql.conf.d/mysqld.cnf:

[mysqld]
sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUT>
sort_buffer_size=10M
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
datadir         = /var/lib/mysql
log-error       = /var/log/mysql/error.log

But when I restart MySQL, I get the following error:

 mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Wed 2021-01-27 16:32:39 EET; 9s ago
       Docs: man:mysqld(8)
             http://dev.mysql.com/doc/refman/en/using-systemd.html
    Process: 55142 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=exited, sta>
    Process: 55181 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
   Main PID: 55181 (code=exited, status=1/FAILURE)
     Status: "Server startup in progress"
      Error: 2 (No such file or directory)

I have gone through all of the tutorials on this topic, but it seems that something has changed since those.

I need a permanent solution, because right now, the following setting disappears on every reboot.

mysql > SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));

How can I solve this?

question from:https://stackoverflow.com/questions/65921384/disable-only-full-group-by-mysql-8-ubuntu-20-04-lts

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As stated in this answer, the NO_AUTO_CREATE_USER mode was removed in MySQL 8 (assuming that is the version you're using in Ubuntu 20) and will result in an error if included in your config.

Removing it should fix your error. So the line to be added in your cnf file should be:

[mysqld]
sql_mode=IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...