If you write MySQL queries, at some point you are going to have
to provide query results in a specific order. To impose any
ordering in MySQL (this applies to SQL overall
and is not directed only at MySQL), you have to use the
ORDER BY
clause. Without it, there is no
guaranteed order. The database is free to send back
query results in any order. As I learn PHP, I make it a point to
explore both the MySQL side, along with the PHP side in
regards to similar type tasks and the efficiency of each. So far
in my PHP journey, I have found that arrays
are used
quite extensively. In this post, I’ll cover
array_multisort()
– one of many in-built
PHP functions – used for sorting arrays. In the context of the
example data for this post, the arrays are populated by an
unordered MySQL query. Let’s see one example of how you
can establish a sorting order in a PHP …
In the previous post, we setup a Drupal website with MySQL as backend on a different compute instance in a different subnet.
Today we will increase the High Availability of our Database by transforming this single MySQL instance into a MySQL InnoDB Cluster!
The architecture will be the following:
We will use 2 different Availability Domains (AD), of course we could have used 3, it’s up to you.
We will install MySQL Router on the Application Server as advised, and we will modify our Drupal’s configuration to connect locally on the R/W port of the MySQL Router.
You will see that this is very easy to achieve, the most …
[Read more]Today, we will cover a totally different MySQL Shell plugin: InnoDB.
Currently only 3 methods have been created:
Those related to the Table space fragmentation, have already been covered in this recent article.
Let’s discover the getAlterProgress()
method. This
method allows us to have an overview of the progress of some
alter statements status like:
- stage/innodb/alter table (end)
- stage/innodb/alter table (flush)
- stage/innodb/alter table (insert)
- stage/innodb/alter table (log apply index)
- stage/innodb/alter table (log apply table)
- stage/innodb/alter table (merge sort)
- stage/innodb/alter table (read PK and internal sort)
- stage/innodb/alter tablespace (encryption)
This is an output of the method:
As …
[Read more]To illustrate how easy it’s to see who’s trying to access data they have not been granted for, we will first create a schema with two tables:
mysql> create database mydata; mysql> use mydata mysql> create table table1 (id int auto_increment primary key, name varchar(20), something varchar(20)); mysql> create table table2 (id int auto_increment primary key, name varchar(20), something varchar(20));
Now, let’s create a user :
mysql> create user myuser identified by 'mypassword';
And as it’s always good to talk about SQL ROLES, let’s define 3 roles for our user:
- myrole1: user has access to both tables in their entirety, reads and writes
- myrole2: user has access only to `table2`, reads and writes
- myrole3: user has only access to the column `name`of `table1` and …
Mid September, MySQL Community, MySQL Customers and MySQL Engineers will be in San Francisco to share their experience and present the new features of your favorite database !
The event will be held in Moscone South (just Mirko Ortensi‘s Hands-on Lab will be delivered in Moscone West).
During the week, the MySQL Community Team will host the traditional MySQL Reception. We got so great feedback from last year that we decided to renew the experience in the same awesome location, the Samovar Tea Lounge at Yerba Buena Gardens. Don’t forget that you need to register for this reception but no OOW pass is required. Please register here !
Back to the conference, you can find the full schedule for the session in the …
[Read more]As you may have noticed, MySQL 8.0.16 has been released today !
One of the major long expected feature is the support of
CHECK contraints
.
My colleague, Dave Stokes, already posted an article explaining how this works.
In this post, I wanted to show how we could take advantage of this new feature to validate JSON values.
Let’s take the following example:
So we have a collection of documents representing rates from a user on some episodes. Now, I expect that the value for the rating should be between 0 and …
[Read more]I wish you all the best for this end of 2018 and of course a nice start of 2019’s edition !
For the best possible start of 2019, I already invite you to these different events where I will have to honor to talk about MySQL:
- MySQL Innovation Day in Stockholm (Jan 23rd)
- pre-FOSDEM MySQL Day in Brussels (Feb 1st)
- FOSDEM MySQL, MariaDB & Friends Devroom (Feb 2nd)
- MySQL New York Meetup (Mar 5th)
Take some rest and see you soon again ! …
[Read more]