[42000][1055] Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.ai.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

solve:

1、首先启动mysql服务

启动MySQL服务

sudo /usr/local/mysql/support-files/mysql.server start

停止MySQL服务

sudo /usr/local/mysql/support-files/mysql.server stop

重启MySQL服务

sudo /usr/local/mysql/support-files/mysql.server restart

2、进入命令行:mysql -u root -p

3、mysql在新版中去掉了默认配置文件my.cnf如果需要可以手动创建

1)在 /etc 新建 my.cnf 文件

sudo vim my.cnf
1
2)将如下配置内容写入到文件中

  1. # Example MySQL config file for medium systems.
  2. #
  3. # This is for a system with little memory (32M - 64M) where MySQL plays
  4. # an important part, or systems up to 128M where MySQL is used together with
  5. # other programs (such as a web server)
  6. #
  7. # MySQL programs look for option files in a set of
  8. # locations which depend on the deployment platform.
  9. # You can copy this option file to one of those
  10. # locations. For information about these locations, see:
  11. # http://dev.mysql.com/doc/mysql/en/option-files.html
  12. #
  13. # In this file, you can use all long options that a program supports.
  14. # If you want to know which options a program supports, run the program
  15. # with the "--help" option.
  16. # The following options will be passed to all MySQL clients
  17. [client]
  18. default-character-set=utf8
  19. #password = your_password
  20. port = 3306
  21. socket = /tmp/mysql.sock
  22. # Here follows entries for some specific programs
  23. # The MySQL server
  24. [mysqld]
  25. character-set-server=utf8
  26. port = 3306
  27. socket = /tmp/mysql.sock
  28. skip-external-locking
  29. key_buffer_size = 16M
  30. max_allowed_packet = 1M
  31. table_open_cache = 64
  32. sort_buffer_size = 512K
  33. net_buffer_length = 8K
  34. read_buffer_size = 256K
  35. read_rnd_buffer_size = 512K
  36. myisam_sort_buffer_size = 8M
  37. character-set-server=utf8
  38. init_connect='SET NAMES utf8'
  39. # Don't listen on a TCP/IP port at all. This can be a security enhancement,
  40. # if all processes that need to connect to mysqld run on the same host.
  41. # All interaction with mysqld must be made via Unix sockets or named pipes.
  42. # Note that using this option without enabling named pipes on Windows
  43. # (via the "enable-named-pipe" option) will render mysqld useless!
  44. #
  45. #skip-networking
  46.  
  47. # Replication Master Server (default)
  48. # binary logging is required for replication
  49. log-bin=mysql-bin
  50.  
  51. # binary logging format - mixed recommended
  52. binlog_format=mixed
  53.  
  54. # required unique id between 1 and 2^32 - 1
  55. # defaults to 1 if master-host is not set
  56. # but will not function as a master if omitted
  57. server-id = 1
  58.  
  59. # Replication Slave (comment out master section to use this)
  60. #
  61. # To configure this host as a replication slave, you can choose between
  62. # two methods :
  63. #
  64. # 1) Use the CHANGE MASTER TO command (fully described in our manual) -
  65. # the syntax is:
  66. #
  67. # CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
  68. # MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
  69. #
  70. # where you replace <host>, <user>, <password> by quoted strings and
  71. # <port> by the master's port number (3306 by default).
  72. #
  73. # Example:
  74. #
  75. # CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
  76. # MASTER_USER='joe', MASTER_PASSWORD='secret';
  77. #
  78. # OR
  79. #
  80. # 2) Set the variables below. However, in case you choose this method, then
  81. # start replication for the first time (even unsuccessfully, for example
  82. # if you mistyped the password in master-password and the slave fails to
  83. # connect), the slave will create a master.info file, and any later
  84. # change in this file to the variables' values below will be ignored and
  85. # overridden by the content of the master.info file, unless you shutdown
  86. # the slave server, delete master.info and restart the slaver server.
  87. # For that reason, you may want to leave the lines below untouched
  88. # (commented) and instead use CHANGE MASTER TO (see above)
  89. #
  90. # required unique id between 2 and 2^32 - 1
  91. # (and different from the master)
  92. # defaults to 2 if master-host is set
  93. # but will not function as a slave if omitted
  94. #server-id = 2
  95. #
  96. # The replication master for this slave - required
  97. #master-host = <hostname>
  98. #
  99. # The username the slave will use for authentication when connecting
  100. # to the master - required
  101. #master-user = <username>
  102. #
  103. # The password the slave will authenticate with when connecting to
  104. # the master - required
  105. #master-password = <password>
  106. #
  107. # The port the master is listening on.
  108. # optional - defaults to 3306
  109. #master-port = <port>
  110. #
  111. # binary logging - not required for slaves, but recommended
  112. #log-bin=mysql-bin
  113.  
  114. # Uncomment the following if you are using InnoDB tables
  115. #innodb_data_home_dir = /usr/local/mysql/data
  116. #innodb_data_file_path = ibdata1:10M:autoextend
  117. #innodb_log_group_home_dir = /usr/local/mysql/data
  118. # You can set .._buffer_pool_size up to 50 - 80 %
  119. # of RAM but beware of setting memory usage too high
  120. #innodb_buffer_pool_size = 16M
  121. #innodb_additional_mem_pool_size = 2M
  122. # Set .._log_file_size to 25 % of buffer pool size
  123. #innodb_log_file_size = 5M
  124. #innodb_log_buffer_size = 8M
  125. #innodb_flush_log_at_trx_commit = 1
  126. #innodb_lock_wait_timeout = 50
  127.  
  128. [mysqldump]
  129. quick
  130. max_allowed_packet = 16M
  131.  
  132. [mysql]
  133. no-auto-rehash
  134. # Remove the next comment character if you are not familiar with SQL
  135. #safe-updates
  136. default-character-set=utf8
  137.  
  138. [myisamchk]
  139. key_buffer_size = 20M
  140. sort_buffer_size = 20M
  141. read_buffer = 2M
  142. write_buffer = 2M
  143.  
  144. [mysqlhotcopy]
  145. interactive-timeout

特别注意,可以加入:

sql_mode='NO_AUTO_VALUE_ON_ZERO,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,PIPES_AS_CONCAT,ANSI_QUOTES'

修改权限 chmod 664 my.cnf  以及用户权限

修改设置

  1. select @@sql_mode
  1. SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
  2.  

【Solution】MySQL 5.8 this is incompatible with sql_mode=only_full_group_by的更多相关文章

  1. mysql报错this is incompatible with sql_mode=only_full_group_by

    1.报错信息 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: In aggregated query without GROUP ...

  2. mysql报错处理:incompatible with sql_mode=only_full_group_by

    问题: 服务报错:incompatible with sql_mode=only_full_group_by,如下图所示: 分析: NLY_FULL_GROUP_BY是MySQL提供的一个sql_mo ...

  3. mysql 查询出现 "this is incompatible with sql_mode=only_full_group_by"错误解决方案,以及个人rpm方式重装所遇到的问题备份

    一.错误说明        这个错误发生在mysql 5.7 版本及以上版本会出现的问题:        mysql .7版本默认的sql配置是:sql_mode="ONLY_FULL_GR ...

  4. 【推荐】MySQL Cluster报错及解决方法(不断更新中)

    排查问题技巧: MySQL Cluster 自带了一个错误代码的查看的小程序.通过这个小东西我们可以方便的定位问题的原因. 这个程序就是 perror 在MYSQL安装目录的bin下面. 如报错:ER ...

  5. 【转】mysql数据库中实现内连接、左连接、右连接

    [转]mysql数据库中实现内连接.左连接.右连接 内连接:把两个表中数据对应的数据查出来 外连接:以某个表为基础把对应数据查出来 首先创建数据库中的表,数据库代码如下: /* Navicat MyS ...

  6. 【Conclusion】MySQL使用

    MySQL使用 因为数据库实验用到了MySQL,这里对现在已经涉及到的MySQL部分操作做一个简单的小结. 1.安装MySQL 上MySQL的官网下载对应自己OS平台的MySQL安装文件,有在线安装和 ...

  7. 【转】mysql索引使用技巧及注意事项

    一.索引的作用 一般的应用系统,读写比例在10:1左右,而且插入操作和一般的更新操作很少出现性能问题,遇到最多的,也是最容易出问题的,还是一些复杂的查询操作,所以查询语句的优化显然是重中之重. 在数据 ...

  8. 【转】MySQL— pymysql and SQLAlchemy

    [转]MySQL— pymysql and SQLAlchemy 目录 一.pymysql 二.SQLAlchemy 一.pymysql pymsql是Python中操作MySQL的模块,其使用方法和 ...

  9. 【转】MySQL— 索引

    [转]MySQL— 索引 目录 一.索引 二.索引类型 三.索引种类 四.操作索引 五.创建索引的时机 六.命中索引 七.其它注意事项 八.LIMIT分页 九.执行计划 十.慢查询日志 一.索引 My ...

随机推荐

  1. selenium+python-unittest多线程生成报告

    前言 selenium多线程跑用例,这个前面一篇已经解决了,如何生成一个测试报告这个是难点,刚好在github上有个大神分享了BeautifulReport,完美的结合起来,就能生成报告了. 环境必备 ...

  2. mysql查看每个数据库所占磁盘大小

    #查看每个数据库所占磁盘大小 SELECT TABLE_SCHEMA AS "库名", , ) AS "表所占空间(MB)", , ) AS "索引所 ...

  3. Servlet(四):request和response对象

    Request对象:问题: 浏览器发起请求到服务器,会遵循HTTP协议将请求数据发送给服务器. 那么服务器接受到请求的数据改怎么存储呢?不但要存,而且要保证完成性. 解决: 使用对象进行存储,服务器每 ...

  4. 2018山东省赛sequence

    2018山东省赛sequence因为必须要删除一个数,所以可以计算每个数删除的代价,从而选取代价最小的进行删除如果一个数大于它前面的所有数的最小值而小于次小值,删除最小值的代价就要+1:如果一个数本身 ...

  5. leetcode刷题第二天<两数相加>

    题目描述 给出两个 非空 的链表用来表示两个非负的整数.其中,它们各自的位数是按照 逆序 的方式存储的,并且它们的每个节点只能存储 一位 数字. 如果,我们将这两个数相加起来,则会返回一个新的链表来表 ...

  6. Ubuntu14.04和16.04官方默认更新源sources.list和第三方源推荐(干货!)

    不多说,直接上干货! 写在前面:笔者由于还在学校学习,学校没有开发给Linux用的上网客户端,所以只能用在windows系统中通过安装虚拟机运行linux比较方便,但没有外网,只有学校的教育网,所以我 ...

  7. JavaScript异步加载的三种方式——async和defer、动态创建script

    一.script标签的位置 传统的做法是:所有script元素都放在head元素中,必须等到全部js代码都被下载.解析.执行完毕后,才能开始呈现网页的内容(浏览器在遇到<body>标签时才 ...

  8. 在VS2010上安装MVC4(webApi)

    我们安装的VS2010上是没有MVC4或者WebApi的,要想加入这些功能只能自己在网上下载安装. 要安装MVC4,首先得安装VS10sp(Service Package)1,然后再安装MVC4.安装 ...

  9. Python-Django学习

    1,安装Django与python版本的对应1.8 2.7,3.2--3.51.9,1.10 2.7,3.4,3.51.11 2.7,3.4,3.5,3.62.0 2.1 第一种安装:pip inst ...

  10. 潭州课堂25班:Ph201805201 tornado 项目 第九课 深入应用 WebSockets(课堂笔记)

    tornado 相关说明 在 handler 中创建一个  chat.py 文件,用来处理聊天室 在 templates 模板文件夹下创建 room.html 文件,是个聊天室 做好服务器的准备