Showing entries 3121 to 3130 of 44043
« 10 Newer Entries | 10 Older Entries »
JSON in MySQL: Keys which do NOT match a value (the more elegant way)

Given a JSON object:
SET @j := '{"BOOSTER": 1, "RETRO": 2, "GUIDANCE": 0, "SURGEON": 1, "RECOVERY": 0}';

How do you find the keys which do NOT contain a value of 0?

A second approach to finding the non-0 values from a JSON object is to turn the keys and values into separate columns of a table. This is cleaner, but a little wordier.

We’ll get the keys in one table:

SELECT ord, keyname 
FROM JSON_TABLE(JSON_KEYS(@j), '$[*]' COLUMNS (
    ord FOR ORDINALITY,
    keyname VARCHAR(100) PATH '$')
) AS keyTable;
 +------+----------+
 | ord  | keyname  |
 +------+----------+
 |    1 | RETRO    |
 |    2 | BOOSTER  |
 |    3 | SURGEON  |
 |    4 | GUIDANCE |
 |    5 | RECOVERY |
 +------+----------+

And the values in a second table:

SELECT ord, …
[Read more]
Testing Percona XtraDB Cluster 8.0 Using Vagrant

As Alkin and Ramesh have shown us in their Testing Percona XtraDB Cluster 8.0 with DBdeployer post, it is now possible to easily deploy an environment to test the features provided by the brand new release of Percona XtraDB Cluster 8.0.

We have also worked on creating a testing environment available for those that use Vagrant instead. Be it that it’s what you are used to working with, or that you want a proper VM for each instance, in particular, you can use the following commands to easily deploy a three-node cluster.

Requirements

Vagrant runs in Linux, Mac OS, and Windows, you just need to have the packages installed. Visit …

[Read more]
How to Create a Many-to-Many Relationship

Establishing a many-to-many relationship between the tables in a database is usually done for ensuring efficient data processing and data integrity, as well as for database normalization and data analysis tasks. Since relational databases don’t allow implementing a direct many-to-many relationship between two tables, handling that kind of relationship can be an intimidating task. In […]

Known Issue Announcement for Tungsten Products and MySQL 8

On Monday April 27th, MySQL released a much-anticipated patch release 8.0.20. Along with many bug fixes and improvements, a new property was introduced – binlog-transaction-compression. During our own internal testing we have discovered an incompatibility with our Continuent Tungsten products when this property is enabled.

The newly-released binlog-transaction-compression feature is really interesting because it compresses transaction payloads before being written into the binary logs, which in turn reduces the disk space overhead required for storage. I’m sure many users will be keen to implement this, however at this time the use of binlog-transaction-compression=ON will prevent Replication from functioning correctly.

This …

[Read more]
Known Issue Announcement for Tungsten Products and MySQL 8

On Monday April 27th, MySQL released a much anticipated patch release 8.0.20. Along with many bug fixes and improvements, a new property was introduced - binlog-transaction-compression. During our own testing we have discovered an incompatibility with this property. Read on for more information.

Tags:  MySQL MySQL 8 tungsten clustering tungsten replicator known issue

JSON in MySQL: Keys which do NOT match a value

Given a JSON object:
SET @j := '{"BOOSTER": 1, "RETRO": 2, "GUIDANCE": 0, "SURGEON": 1, "RECOVERY": 0}';

How do you find the keys which do NOT contain a value of 0?

One approach is to find the keys which do match 0, and then remove them.

Sounds like JSON_SEARCH and JSON_REMOVE? But there’s a gotcha: JSON_SEARCH works only with strings. Ok, so we REPLACE(@j, ‘0’, ‘”0″‘) – but that doesn’t help, because JSON_REMOVE can’t accept an array of paths like JSON_SEARCH would return; it requires each path as a separate parameter.

Instead, JSON_MERGE_PATCH will suffice. It has the feature that values from the second parameter are preserved only if they are not NULL. So, the approach becomes turning the 0s into NULLs, and then merging that document into an empty one.

SELECT REPLACE(@j, 0, 'null') AS j; -- …
[Read more]
Database change tracking using MySQL EE Audit

Use MySQL Enterprise Audut plugin to track data changes on specific tables. Scripts and documentation on github: https://github.com/wwwted/Database-change-tracking Tracked data (audit logs) can then be inserted into reporting db using parser scripts. Limitations:

  • Changing tracking rules stopps all tracking for existing connections until the reconnect. This is a limitation in MySQL EE Audit filter handling.
  • No filtering for different users, easy to implement if needed in change_tracking.sql SP (START/STOP).
  • Only tracking INSERT/UPDATE/DELETE statements. Easy to modify if needed.

1 Enable tracking on target server …

[Read more]
Setting up an InnoDB Cluster With a Few Lines of Code

In this day and age, large enterprise companies make use of Ansible, Puppet, or Chef to provision MySQL servers, be it replica sets or clusters. This eases the burden of deployment and workflow management.

However, for some smaller companies, the learning curve hampers the immediate adoption of automation software. This is where the MySQL Shell helps, by allowing you to deploy an N-node InnoDB Cluster or ReplicaSet in less than 60 lines of code.

The Requirements

  • Percona Server for MySQL version 8.0.17 or later, preferable version 8.0.19, each node started as standalone servers
  • Percona MySQL Shell 8.0 or equivalent upstream version
  • MySQL root user and password or equivalent user with grant option
  • Hostname configured on each node, can be done with …
[Read more]
Installing Galera Cluster 4 with MySQL 8 on Ubuntu 18.04

Since the beta of Galera Cluster 4 with MySQL 8 has been released, we’ve had people asking questions as to how to install it on Ubuntu 18.04. This blog post will cover just that.

Prerequisites

  • All 3 nodes need to have Ubuntu 18.04 installed
  • Firewall (if setup) needs to accept connections on 3306, 4444, 4567, 4568 (a default setup has the firewall disabled)
  • AppArmor disabled (this is as simple as executing: systemctl stop apparmor and systemctl disable apparmor).

Installation and Configuration

We have good installation documentation as well as a quick how to get this installed in AWS (though this is CentOS centric).

First, you will need to ensure that the …

[Read more]
MySQL Security – Password Verification-Required Policy

MySQL 8.0 has introduced an optional behavior that authorize users to change their password only if they could provide the current password.

The post MySQL Security - Password Verification-Required Policy first appeared on dasini.net - Diary of a MySQL expert.

Showing entries 3121 to 3130 of 44043
« 10 Newer Entries | 10 Older Entries »