mysql-5.7

Mysql 5.7 native json support - control keys order in json_insert function

泄露秘密 提交于 2019-12-19 06:43:42
问题 I am facing issues with json key ordering while inserting using json_insert function. I have the sorted records as below "AIR", "AIR Express" "CFR", "Cost and Freight" "FH", "Free house" "UN", "United Nations" "UPS", "United Parcel Service" After converting the above records into json using json_insert function, I am seeing the results as below {"FH":"Free house", "UN": "United Nations", "AIR": "AIR Express", "CFR": "Cost and Freight", "UPS": "United Parcel Service"} but I want the json to

Mysql 5.7 native json support - control keys order in json_insert function

落花浮王杯 提交于 2019-12-19 06:43:19
问题 I am facing issues with json key ordering while inserting using json_insert function. I have the sorted records as below "AIR", "AIR Express" "CFR", "Cost and Freight" "FH", "Free house" "UN", "United Nations" "UPS", "United Parcel Service" After converting the above records into json using json_insert function, I am seeing the results as below {"FH":"Free house", "UN": "United Nations", "AIR": "AIR Express", "CFR": "Cost and Freight", "UPS": "United Parcel Service"} but I want the json to

How to solve mysql warning: “InnoDB: page_cleaner: 1000ms intended loop took XXX ms. The settings might not be optimal ”?

耗尽温柔 提交于 2019-12-17 10:19:29
问题 I ran a mysql import mysql dummyctrad < dumpfile.sql on server and its taking too long to complete. The dump file is about 5G. The server is a Centos 6, memory=16G and 8core processors, mysql v 5.7 x64- Are these normal messages/status "waiting for table flush" and the message InnoDB: page_cleaner: 1000ms intended loop took 4013ms. The settings might not be optimal mysql log contents 2016-12-13T10:51:39.909382Z 0 [Note] InnoDB: page_cleaner: 1000ms intended loop took 4013ms. The settings

MySQL - Conditional MIN MAX to return distinct record

∥☆過路亽.° 提交于 2019-12-14 03:05:57
问题 I have a database dump from the geonames website for Great Britain. It consists of approx 60000 records. example data is as follows: id | name | admin1 | admin2 | admin3 | feature_class | feature_code ------------------------------------------------------------------------------------------- 2652355 | Cornwall | ENG | C6 | | A | ADM2 11609029 | Cornwall | ENG | | | L | RGN 6269131 | England | ENG | | | A | ADM1 The first record with feature code ADM2 means it is administrative level 2 The

MYSQL & innoDB alter dynamically AUTO_INCREMENT of a table

时光总嘲笑我的痴心妄想 提交于 2019-12-13 13:04:07
问题 I have a problem, for example in my system I have the next table: CREATE TABLE `sales` ( `id` int(11) NOT NULL AUTO_INCREMENT, `amount` FLOAT NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB; -- is more complex table With content: +-----+-------+ | id | amount| +-----+-------+ |2023 | 100 | |2024 | 223 | |2025 | 203 | |... | |2505 | 324 | +-----+-------+ I don't know the current id(There are sales every day). I'm trying to normalize the table. UPDATE sales SET id=id - 2022; Result: +-----+-------

MySql 5.7 Function UUID() default collation - Illegal mix of collations

谁都会走 提交于 2019-12-13 00:41:36
问题 Problem: MySQL's uuid() default collation does not compare to configured connnection collation. I have a database + tables + fields created with charset: utf-8 and collation utf8_polish_ci. The my.cnf is as follows: init_connect='SET NAMES utf8 COLLATE utf8_polish_ci' character-set-server=utf8 collation-server=utf8_polish_ci character sets: mysql> show variables like "char%"; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+------

How to get unique / distinct elements inside JSON array in MySQL 5.7

扶醉桌前 提交于 2019-12-12 14:52:38
问题 I have mysql 5.7 with a denormalized table that has some JSON columns. I need to extract unique / distinct values per row for an array column. For e.g: ["a", "b", "b", "a", "c"] expected output should be ["a", "b", "c"]; SET @json = '["a", "b", "b", "a", "c"]'; I need to get unique values in this list. ["a", "b", "c"]; 回答1: There is no direct method to get distinct values out of a JSON array in MySQL. One method could be to utilize a Sequence/Number Generator table concept. This sequence

Can't set root MySQL password to null

余生长醉 提交于 2019-12-12 04:37:37
问题 When installing mysql, I didn't put anything in the root password fields, but when I ran mysql -u root I still got Access denied for user 'root'@'localhost' . I started mysql up in safe mode without the grant tables, sudo mysql_safe --skip-grant-tables & , then jumped in with mysql -u root without a problem. Then I did use mysql; update user set authentication_string=null where user='root'; and I got: Query OK, 0 rows affected (0.00 sec) Rows matched: 1 Changed: 0 Warnings: 0 Anyone have any

MySQL 5.7.19 Invalid GIS data provided to function st_geometryfromtext

☆樱花仙子☆ 提交于 2019-12-11 15:14:34
问题 So I am new at ST_ functions in MySql and I think that I am missing something. I am trying to save a POLYGON in MySql, the problem is that when using the function ST_GEOMFROMTEXT and giving the coordinates of the POLYGON taken from Google Maps Javascript API it returns the error: Invalid GIS data provided to function st_geometryfromtext . I've read a lot in Internet but everywhere it mostly says that it's a version problem, the thing here is the I have the most recent one right now (5.7.19)

How to create new MySQL database user with MySQLi prepared statements?

余生颓废 提交于 2019-12-11 12:40:31
问题 I'm trying to add new database user by these statements: $insert = $db->prepare("CREATE USER ? IDENTIFIED BY ?"); $insert->bind_param('ss', $_POST['username'], $_POST['pass']); $insert->execute(); Database gives me error: You have an error in your SQL syntax; (...) near '? IDENTIFIED BY ?' at line 1 When I try to add new user without ? wildcards, everything is fine: CREATE USER john IDENTIFIED BY 'johnpassword' //this works , but even using CONCAT("'", ?, "'") for submitting data doesn't help