mysql-8.0

Indexing JSON column in MySQL 8

为君一笑 提交于 2020-06-16 19:00:22
问题 So I'm experimenting with json column. Mysql 8.0.17 supposed to work with multi value JSON indexes, like this: CREATE INDEX data__nbr_idx ON a1( (CAST(data->'$.nbr' AS UNSIGNED ARRAY)) ) I have column categories with JSON like this ["books", "clothes"]. I need to get all products from "books" category. I can use "json_contains" or new "member of". SELECT * FROM products WHERE JSON_CONTAINS(categories, '\"books\"') SELECT * FROM products WHERE "books" MEMBER OF(categories) And it works. The

Indexing JSON column in MySQL 8

独自空忆成欢 提交于 2020-06-16 19:00:03
问题 So I'm experimenting with json column. Mysql 8.0.17 supposed to work with multi value JSON indexes, like this: CREATE INDEX data__nbr_idx ON a1( (CAST(data->'$.nbr' AS UNSIGNED ARRAY)) ) I have column categories with JSON like this ["books", "clothes"]. I need to get all products from "books" category. I can use "json_contains" or new "member of". SELECT * FROM products WHERE JSON_CONTAINS(categories, '\"books\"') SELECT * FROM products WHERE "books" MEMBER OF(categories) And it works. The

How to set sql_mode in my.cnf in MySQL 8?

穿精又带淫゛_ 提交于 2020-02-06 12:39:22
问题 I'm running MySQL 8.0.11 community version. I need to set sql_mode to exclude ONLY_FULL_GROUP_BY in my.cnf so that it's restart safe. I tried the following variants: sql_mode= STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" sql-mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR

How to set sql_mode in my.cnf in MySQL 8?

吃可爱长大的小学妹 提交于 2020-02-06 12:33:27
问题 I'm running MySQL 8.0.11 community version. I need to set sql_mode to exclude ONLY_FULL_GROUP_BY in my.cnf so that it's restart safe. I tried the following variants: sql_mode= STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" sql-mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR

How to disable column-statistics in MySQL 8 permanently?

柔情痞子 提交于 2020-01-31 21:31:44
问题 Since MySQL 8 the column-statistics flag is enabled by default. So if you try to dump some tables with MySQL Workbench 8.0.12, you get this error message: 14:50:22 Dumping db (table_name) Running: mysqldump.exe --defaults-file="c:\users\username\appdata\local\temp\tmpvu0mxn.cnf" --user=db_user --host=db_host --protocol=tcp --port=1337 --default-character-set=utf8 --skip-triggers "db_name" "table_name" mysqldump: Couldn't execute 'SELECT COLUMN_NAME, JSON_EXTRACT(HISTOGRAM, '$."number-of

MySQL “Show table status”, auto increment is not correct

蹲街弑〆低调 提交于 2020-01-30 03:20:10
问题 I create a new table in Mysql, add some rows, yet the Auto_increment field of show tables still returns NULL. The mysql manual says: this field should return: "The next Auto_increment value" https://dev.mysql.com/doc/refman/8.0/en/show-table-status.html What am I doing wrong? How can I find the next auto_increment value correctly? Steps to reproduce: create table `test` ( `id` int(5) not null auto_increment, `name` varchar(256), PRIMARY KEY(`id`) ); Then I run : show table status where name

using of GROUP BY in mysql 8

坚强是说给别人听的谎言 提交于 2020-01-22 00:19:07
问题 I have upgraded my MySQL server and now I have a problem with group by select * from tickets WHERE `status` = 0 group by `tnumber` ORDER BY `created_at` DESC error is: SELECT list is not in GROUP BY clause and contains nonaggregated column Updated: my table content is: <!DOCTYPE html> <html> <head> <style> table { font-family: arial, sans-serif; border-collapse: collapse; width: 100%; } td, th { border: 1px solid #dddddd; text-align: left; padding: 8px; } tr:nth-child(even) { background-color

MySQL search json value by key in array

拜拜、爱过 提交于 2020-01-20 06:53:10
问题 I have an array of JSON objects and want to have a specific node returned. To simplify my problem, lets say the array could look like this: [ {"Race": "Orc", "strength": 14}, {"Race": "Knight", "strength": 7}, ... ] And I want to know the strength of the knight for example. The function JSON_SEARCH, returns the path '$[1].Race' and with the path operator I could get the strength. Is there a way to combine those two, so I could do something like the following? SELECT someFunc(myCol,'$[*].Race'

MySQL 8 Warning: SQL_NO_CACHE is deprecated

邮差的信 提交于 2020-01-16 14:04:07
问题 When issuing a statement to MySQL8 server: SELECT SQL_NO_CACHE * FROM <table-name>; I get this warning: Warning, 1681, 'SQL_NO_CACHE' is deprecated and will be removed in a future release. I would like to ask if there is any successor of the SQL_NO_CACHE that works or is planned to work with MySQL 8.x? Does SQL_NO_CACHE actually work with MySQL 8.x or it is omitted by the server? 来源: https://stackoverflow.com/questions/58584596/mysql-8-warning-sql-no-cache-is-deprecated

docker-compose : The server requested authentication method unknown to the client

前提是你 提交于 2020-01-10 18:47:08
问题 I have this yml file for configuration of MySQL in docker: # Use root/example as user/password credentials version: '3.1' services: db: image: mysql restart: always environment: MYSQL_ROOT_PASSWORD: 'pass' MYSQL_DATABASE: 'db' MYSQL_USER: 'user' MYSQL_PASSWORD: 'pass' adminer: image: adminer restart: always ports: - 8888:8080 And I start the container using following command from the same directory where yml is located: docker-compose -f stack.yml up Then I got this error: 回答1: This worked