I tried to test if a line is met in some distance from a point. St_distance just gives me what I want. However, I'm curious about st_intersects + st_buffer:
$ mysql --version
mysql Ver 14.14 Distrib 5.6.24, for Linux (x86_64) using EditLine wrapper
mysql> set #l4=st_geomfromtext('LINESTRING(50 50, 52 45)');
mysql> set #g4=st_geomfromtext('POINT(50 49)');
mysql> select st_distance(#l4, #g4);
--------------
select st_distance(#l4, #g4)
--------------
+-----------------------+
| st_distance(#l4, #g4) |
+-----------------------+
| 0.3713906763541037 |
+-----------------------+
1 row in set (0.00 sec)
I would think the point is very close to the line but obviously MySQL disagrees:
mysql> select st_intersects(st_buffer(#g4, 1), #l4);
--------------
select st_intersects(st_buffer(#g4, 1), #l4)
--------------
+---------------------------------------+
| st_intersects(st_buffer(#g4, 1), #l4) |
+---------------------------------------+
| 0 |
+---------------------------------------+
1 row in set (0.00 sec)
Why? Do I miss something?
P.S.
I have tried the commands above in H2GIS and it says it is indeed true!
ST_Intersects should return true in this case.
This appears to be the bug reported here: https://bugs.mysql.com/bug.php?id=71076, and fixed in MySQL 5.7.6, according to the release notes here: http://forums.mysql.com/read.php?3,629183,629183
"This work also corrected issues that [...], and that
ST_Intersects() sometimes incorrectly calculated the
result for intersections of LineString and Polygon."
Related
The from_base64() does not decode correctly. Please see the problem demo below.
mysql> select to_base64('sometext');
+-----------------------+
| to_base64('sometext') |
+-----------------------+
| c29tZXRleHQ= |
+-----------------------+
1 row in set (0.27 sec)
mysql> select from_base64('c29tZXRleHQ=');
+----------------------------------------------------------+
| from_base64('c29tZXRleHQ=') |
+----------------------------------------------------------+
| 0x736F6D6574657874 |
+----------------------------------------------------------+
1 row in set (0.00 sec)
This was working till i moved to latest ubuntu 19.10.
Server version: 8.0.19 MySQL Community Server - GPL
mysql --version
mysql Ver 8.0.19-0ubuntu0.19.10.3 for Linux on x86_64 ((Ubuntu))
This is because of the following.
--binary-as-hex
When this option is given, mysql displays binary data using hexadecimal notation (0xvalue). This occurs whether the overall output dislay format is tabular, vertical, HTML, or XML.
As of MySQL 8.0.19, when mysql operates in interactive mode, this option is enabled by default. In addition, output from the status (or \s) command includes this line when the option is enabled implicitly or explicitly:
To disable hexadecimal notation, use --skip-binary-as-hex
MySQL client options
My connection string for MySQL is:
"Server=localhost;User ID=root;Password=123;pooling=yes;charset=utf8;DataBase=.;"
My questions are :
What query should I write to get database names that exist?
What query should I write to get server version?
I have error because of my connection string ends with DataBase=.
What should I write instead of the dot?
SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA
SELECT VARIABLE_NAME, VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME = 'VERSION'
Use INFORMATION_SCHEMA as the database.
To get the list of databases, you can use SHOW DATABASES:
SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.01 sec)
To get the version number of your MySQL Server, you can use SELECT VERSION():
SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 5.1.45 |
+-----------+
1 row in set (0.01 sec)
As for the question about the connection string, you'd want to put a database name instead of the dot, such as Database=test.
show Databases;
Will return you all the registered databases.
And
show variables;
will return a bunch of name value pairs, one of which is the version number.
MariaDB cluster Version : mysql Ver 15.1 Distrib 10.0.24-MariaDB,
I have a two node + arbitrator cluster which is live and replicating data across nodes.
Unfortunately we found some inconsistency in some of the tables in Databases.
For instance:
Node1:
MariaDB [(none)]> select count(*) from example_db.reports;
+----------+
| count(*) |
+----------+
| 299 |
+----------+
1 row in set (0.00 sec)
Node2:
MariaDB [(none)]> select count(*) from example_db.reports;
+----------+
| count(*) |
+----------+
| 285 |
+----------+
1 row in set (0.00 sec)
Note: Not find any noticeable errors in mysql error log
What could be the reasons for these kind of inconsistency ?
Is that a bug or a known issues ?
Thank you.
I don't think there are any bugs in this very critical area.
In Galera clusters, you must check for errors after all statements, including COMMIT. (This is different than in ordinary replication.)
All tables are InnoDB, correct?
When calling MySQL SELECT ##VERSION; or SELECT VERSION();, I get for instance '5.7.11-log'. Is there a "well-known" way to check if the version is greater (or smaller) than some major.minor.patch version? If not a well-known way, is there a way without using a temporary table or a user-defined function (there probably is, but for a reason or another currently eludes me)? I would use this to check if there's support for JSON type type that was introduced in version 5.7.8.
Upon researching this more, it appears this is a bit tougher nut for my skills to crack. For instance, I could write something like
SELECT
SUBSTRING_INDEX(##VERSION, '.', 1) AS major,
SUBSTRING_INDEX(SUBSTRING_INDEX(##VERSION,'.', 2), '.', -1) AS minor,
SUBSTRING_INDEX(SUBSTRING_INDEX(##VERSION,'.', -2), '.', -1) AS patch;
but that isn't entirely satisfactory (e.g. see -log) and it doesn't directly check the existence of the feature.
I cross-posted this to DBA overflow How to check if feature (JSON) exists, and/or version.
Use if condition with version
mysql> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 5.7.14 |
+-----------+
1 row in set (0.00 sec)
mysql> select if(VERSION() > '5.7.14' ,1,0);
+-------------------------------+
| if(VERSION() > '5.7.14' ,1,0) |
+-------------------------------+
| 0 |
+-------------------------------+
1 row in set (0.00 sec)
mysql> select if(VERSION() > '5.7.13' ,1,0);
+-------------------------------+
| if(VERSION() > '5.7.13' ,1,0) |
+-------------------------------+
| 1 |
+-------------------------------+
1 row in set (0.00 sec)
I'll cross reference the answer by Rick here. Specifically, there is special comments syntax in MySQL in which MySQL interprets a block of code either as effective MySQL SQL or as just a plain comments section. Here's a link to the documentation: http://dev.mysql.com/doc/refman/5.7/en/comments.html and a few notable examples:
SELECT /*!JSON_TYPE*/('["a", "b", 1]');
and
/*!40103 SET #OLD_TIME_ZONE=##TIME_ZONE */;.
I am using mysql (mysql Ver 14.14 Distrib 5.5.34, for debian-linux-gnu (x86_64) using readline 6.2). and i am create a column named external_password
with description external_password | varchar(200) | null =YES | | default =NULL and inserted data.
When I try preform a select operation through command line i got the following result,
mysql> select external_password from login_user WHERE user_name = 'abc#123';
+---------------------------------------------------------+
| external_password |
+---------------------------------------------------------+
| $S$DEjrvXeeDgACuXAN0XkyM6FEPTFcHLcNqV..3SBHxQBpwR9wN7Fd |
+---------------------------------------------------------+
1 row in set (0.00 sec)
But this not showing the full character. between these substring {LcNqV..3SBHxQB} there are lot of other characters are hidden. how can i get the full text by command line??
please help me
NB: i am using using the ubuntu. Also in a situation i can't use phpmyadmin or any other mysql user interfaces.
use ego. this might display more text compared to the table view.
mysql> select external_password from login_user WHERE user_name = 'abc#123'\G
here are other options you can use http://dev.mysql.com/doc/refman/5.1/en/mysql-commands.html