Quantcast
Channel: Planet MySQL
Viewing all 18803 articles
Browse latest View live

MySQL Connector/NET 8.0.17 has been released

$
0
0

Dear MySQL users,

MySQL Connector/NET 8.0.17 is the fifth version to support Entity Framework Core 2.1 and the sixth general availability release of MySQL Connector/NET to add support for the new X DevAPI, which enables application developers to write code that combines the
strengths of the relational and document models using a modern, NoSQL-like syntax that does not assume previous experience writing traditional SQL.

To learn more about how to write applications using the X DevAPI, see http://dev.mysql.com/doc/x-devapi-userguide/en/index.html. For more information about how the X DevAPI is implemented in Connector/NET, see http://dev.mysql.com/doc/dev/connector-net. NuGet packages provide functionality at a project level. To get the
full set of features available in Connector/NET such as availability in the GAC, integration with Visual Studio’s Entity Framework Designer and integration with MySQL for Visual Studio, installation through the MySQL Installer or the stand-alone MSI is required.

Please note that the X DevAPI requires at least MySQL Server version 8.0 or higher with the X Plugin enabled. For general documentation about how to get started using MySQL as a document store, see http://dev.mysql.com/doc/refman/8.0/en/document-store.html.

To download MySQL Connector/NET 8.0.17, see http://dev.mysql.com/downloads/connector/net/

Installation instructions can be found at https://dev.mysql.com/doc/connector-net/en/connector-net-installation.html


Changes in MySQL Connector/NET 8.0.17 (2019-07-22, General
Availability)


     * Functionality Added or Changed

     * Bugs Fixed

Functionality Added or Changed


     * Connector/NET supports SSL PEM certificate versions 1, 2,
       and 3 to enable use with the full range of applications
       that generate certificates. (Bug #29756058)

     * Support was added for .NET Core 2.2, which is a
       cross-platform version of .NET for building applications
       that run on Linux, macOS and Windows (see Connector/NET
       Versions
(https://dev.mysql.com/doc/connector-net/en/connector-net-versions.html)).

     * Document Store: The Where() method is deprecated
       (Obsolete attribute applied) and will return a warning
       when called in the following method constructs:
       Find().Where(), Modify().Where(), and Remove().Where().

     * New README.md and CONTRIBUTING.md files now accompany
       MySQL Connector/NET code for compatibility with Git.
       Distribution packages (NuGet, MSI, ZIP) continue to
       include the original README file, but do not include the
       new files.

     * Connector/NET now supports the new utf8mb4_0900_bin
       collation added for the utf8mb4 Unicode character set in
       MySQL 8.0.17. For more information about this collation,
       see Unicode Character Sets
(https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-sets.html).

     * Document Store: Connector/NET now supports the OVERLAPS
       and NOT OVERLAPS operators for expressions on JSON arrays
       or objects:
expr OVERLAPS expr
expr NOT OVERLAPS expr

       Suppose that a collection has these contents:
[{
   “_id”: “1”,
   “list”: [1, 4]
 }, {
   “_id”: “2”,
   “list”: [4, 7]
}]

       This operation:
var res = collection.Find(“[1, 2, 3] OVERLAPS $.list”).Fields(“_id”).E
xecute();
res.FetchAll();

       Should return:
[{ “_id”: “1” }]

       This operation:
var res = collection.Find(“$.list OVERLAPS [4]”).Fields(“_id”).Execute
();
res.FetchAll();

       Should return:
[{ “_id”: “1” }, { “_id”: “2” }]

       An error occurs if an application uses either operator
       and the server does not support it.

     * Document Store: For index specifications passed to the
       Collection.CreateIndex() method, Connector/NET now
       supports indexing array fields. For example, consider a
       collection with this array:
Session session = MySQLX.GetSession(connString);
Schema schema = session.GetSchema(schemaName);
Collection coll = schema.CreateCollection(collectionName);

var docs = new[]
{
  new {  _id = 1, name = “John Smith”, emails = [ “john.smith@mycompan
y.com”, “jsmith@php.net”, “jsmith@mail.com” ] }
};

coll.Add(docs).Execute();

       A single index field description can contain a new member
       name array that takes a Boolean value. If set to true,
       the field is assumed to contain arrays of elements of the
       given type. In addition, the set of possible index field
       data types (used as values of member type in index field
       descriptions) is extended with type CHAR(N), where the
       length N is mandatory. For example, to create the
       emails_idx index with an array field:
coll.CreateIndex(“emails_idx”,
    “{\”fields\”: [{\”field\”: $.emails,
                   \”type\”:\”CHAR(128)\”,
                   \”array\”: true }]}”
);

       To find an element of the array:
collection
   .Find(“:mail IN $.emails”)
   .Bind(“mail”, “jsmith@php.net”)
   .Execute();


     * New support for SSH tunneling enables Connector/NET to
       create secure connections to a remote MySQL server using
       TCP/IP over SSH. With SSH server authorization, an
       application can establish a connection from behind a
       firewall when the MySQL Server port is blocked. The new
       connection-string options (and equivalent class
       properties) for SSH tunneling are supported by both the
       classic MySQL protocol and X Protocol connections.

Bugs Fixed


     * The BouncyCastle assembly was loaded into memory whenever
       a connection attempt was made using any SSL mode type,
       except None. Now the assembly loads only when the SSL
       mode type is VerifyCA or VerifyFull, or when PEM
       certificates are used. (Bug #29611216)

     * Document Store: The MySqlConnection.GetSchema() method
       sometimes returned columns in an unexpected order when
       used with the INFORMATION_SCHEMA.COLUMNS table. This fix
       ensures that returned columns now correspond to the
       ordinal position only. (Bug #29536344)

     * The InvariantCulture property was missing from some data
       types, which created issues during platform migration
       operations. Thanks to Effy Teva for the patch. (Bug
       #29262195, Bug #94045)

     * Connector/NET connections executed SHOW VARIABLES
       unnecessarily. (Bug #28928543, Bug #93202)

     * Connector/NET access to MySQL stopped working after the
       computer hosting the server was started and continued to
       operate uninterrupted for a defined period of time. (Bug
       #26930306, Bug #75604)

On Behalf of Oracle/MySQL Engineering Team
Prashant Tekriwal


MySQL Connector/Node.js 8.0.17 has been released

$
0
0

Dear MySQL users,

MySQL Connector/Node.js is a new Node.js driver for use with the X
DevAPI. This release, v8.0.17, is a maintenance release of the
MySQL Connector/Node.js 8.0 series.

The X DevAPI enables application developers to write code that combines
the strengths of the relational and document models using a modern,
NoSQL-like syntax that does not assume previous experience writing
traditional SQL.

MySQL Connector/Node.js can be downloaded through npm (see
https://www.npmjs.com/package/@mysql/xdevapi for details) or from
https://dev.mysql.com/downloads/connector/nodejs/.

To learn more about how to write applications using the X DevAPI, see
http://dev.mysql.com/doc/x-devapi-userguide/en/.
For more information about how the X DevAPI is implemented in MySQL
Connector/Node.js, and its usage, see
http://dev.mysql.com/doc/dev/connector-nodejs/.

Please note that the X DevAPI requires at least MySQL Server version
8.0 or higher with the X Plugin enabled. For general documentation
about how to get started using MySQL as a document store, see
http://dev.mysql.com/doc/refman/8.0/en/document-store.html.

Changes in MySQL Connector/Node.js 8.0.17 (2019-07-22,
General Availability)

Functionality Added or Changed

* Document fields containing arrays can now be indexed by setting array to true in an index fields definition.

* Added support for the OVERLAPS and NOT OVERLAPS operators; which is equivalent to the SQL JSON_OVERLAPS() function. These binary operators are used with a general “expression operator expression” syntax; and the expressions return a JSON array or object. Example usage: [1, 2, 3] overlaps $.list

* Added support for the utf8mb4_0900_bin collation added in MySQL Server 8.0.17.

* The bundled README.md file was split and reformatted with some content moved into the new README.txt and CONTRIBUTING.md files.

Bugs Fixed

* The SQL CAST function did not work as a valid lookup expression. (Bug #29807792)

* Added backtick support for table column identifiers in valid expressions. (Bug #29789818)

* The DIV binary and NOT unary operators are now allowed; and are case-insensitive. (Bug #29771833, Bug #29771027) * Collection.find() now supports the JavaScript Date type. (Bug #29766014)

* The collection.dropIndex method now silently fails if the index does not exist, as expected, when before it generated a “Can’t DROP” error. (Bug #29765589)

* Column.getCollationName() would potentially return the incorrect name. (Bug #29704185)

On Behalf of MySQL/ORACLE RE Team
Gipson Pulla

Working with SSH Tunneling and SSL PEM Certificates in Connector/NET

$
0
0

Dear MySQL Connector/NET community,

We are proud to announce that version 8.0.17 is introducing support for SSH tunneled connections through the classic MySQL protocol and X Protocol. SSH enables the creation of secure encrypted connections between the local and a remote computer allowing services or components to be accessed, MySQL Server in this case. With SSH tunneling, users can connect to a MySQL Server from behind a firewall when the server port is blocked. The server doesn’t require any additional configuration for this type of connection and continues to work as usual.

Users can also add an extra layer of security by making use of SSL over SSH connections, which brings us to the second announcement. Connector/NET previously included support for SSL connections via PFX certificates, which are exclusive to Windows. However, now the support for SSL PEM certificates is available starting with version 8.0.16. This allows Connector/NET to align with other MySQL products. More importantly, it increases the security of your applications, specially when you are working with .NET Core to expand your deployment to platforms beyond Windows.

Connection Options Overview

Those unfamiliar with Connector/NET and/or the differences between the classic MySQL protocol and the X Protocol, first need to be aware of the different ways to construct a connection/session object with which a connection to a MySQL Server can be established. There are 4 methods available:

  • Connection string: Available in the classic MySQL protocol and X Protocol. For the classic protocol an instance of the MySqlConnection class is created. In the constructor you provide a string containing key-value pairs which represent the connection options. For the X Protocol, call the MySQLX.GetSession method and provide the connection string in the constructor as well.
  • Using a builder object: Available in the classic MySQL protocol and X Protocol. An instance of the MySqlConnectionStringBuilder (classic protocol) or MySqlXConnectionStringBuilder (X Protocol) is created. You assign values to the mentioned object’s properties which resemble the connection options available in the connection string. Once the properties have been set, call the ToString method to get the connection string and simply pass it to the MySqlConnection object or MySQLX.GetSession method.
  • URI-like connection string: Available in the X Protocol only. A URI-like string is provided which starts with the mysqlx identifier. It supports the same connection options available for any other connection method.
  • Using anonymous objects: Available in the X Protocol only. An anonymous object is created having properties that match the name of the properties defined in the MySqlXConnectionStringBuilder class. The object is simply passed to the MySQLX.GetSession static method.

Refer to the Connection Examples section for code snippets on using each method.

Creating SSH Tunneled Connections

SSH Connection Options

New connection options have been introduced to support SSH tunneled connections. The connection options can either be specified in the connection string or by making use of an instance of the MySqlConnectionStringBuilder or MySqlXConnectionStringBuilder class. Find the new connection options and their details below:

Connection Option Description Property Name Connection String Options
SSH Host Name The IP address or name of the SSH server. SshHostName sshHostName, ssh host name, ssh-host-name
SSH Port The port of the SSH server. SshPort sshPort, ssh port, ssh-port
SSH User Name The name of the SSH user to use to make a connection. SshUserName sshUserName, ssh user name, ssh-user-name
SSH Password The SSH password for the selected user. SshPassword sshPassword, ssh password, ssh-password
SSH Key File A path to the SSH key file including the filename and extension. SshKeyFile sshKeyFile, ssh key file, ssh-key-file
SSH Pass Phrase The pass phrase of the SSH key file (if any). SshPassPhrase sshPassPhrase, ssh pass phrase, ssh-pass-phrase

Initiate an SSH Connection

First, the connection protocol being used must be TCP/IP, note that this is the default connection protocol in Connector/NET. Additional to that, the presence of the SSH User Name and either the SSH Password or SSH Key File options will notify Connector/NET of the user’s intent to make use of an SSH connection. Be sure to specify said options.

It is also necessary to specify the IP address or host name of the SSH Server being accessed. If no SSH Port is specified, the connection will default to the commonly known port 22.

An SSH Password or SSH Pass Phrase can also be provided in the event that they are required by the SSH User Name or SSH Key File connection options respectively.

Finally, set the Server connection option to localhost and Port to the port number the MySQL Server is running at in the SSH server.

Fallback for SSH Connections

Connector/NET includes a fallback mechanism when working with SSH connections. If values are provided to connect using both a SSH Key File and a SSH Password, fallback from the key file to the password will take place in the event that the former attempt fails. Note that the fallback is only enabled whenever the error is detected on the server side, this meaning that if the error is on the client side the user will instead get an exception prior to the connection attempts being made. Causes for errors on the client side can be an invalid key file or an incorrect pass phrase. 

Connection Examples

The following code examples will get you started on creating SSH Tunneled connections:

Example 1
// This is the most basic form of an SSH connection. MySQL port defaults to
// 3306 and SSH Port defaults to 22 since the values are not provided.
// Also, only a password is being used to authenticate to SSH server.
// Connection is being made using a MySqlConnectionStringBuilder object.
var builder = new MySqlConnectionStringBuilder();
builder.UserID = "myUser";
builder.Password = "test";
builder.Server = "localhost";
builder.SshHostName = "10.0.0.2";
builder.SshUserName = "mySshUser";
builder.SshPassword = "sshtest";
using (var connection = new MySqlConnection(builder.ConnectionString))
{
  connection.Open();
  connection.Close();
}
Example 2
// Now the MySQL and SSH ports are being provided.
// Again, only a password is being used to authenticate to SSH server.
// Connection is being made using a connection string.
using (var connection = new MySqlConnection("uid=myUser;password=test;server=localhost;port=3307;sshHostName=10.0.0.2;sshUserName=mySshUser;sshPassword=sshtest;sshPort=23"))
{
  connection.Open();
  connection.Close();
}
Example 3
// Here, a SSH key file with a pass phrase is provided. 
// Connection is being made using an anonymous object.
using (var connection = new MySqlConnection("uid=myUser;password=test;server=localhost;port=3307;sshHostName=10.0.0.2;sshUserName=mySshUser;sshKeyFile=C:\\keys\\myOpenSshKeyFile.ppk;sshPassPhrase=sshTest;sshPort=23"))
{
  connection.Open();
  connection.Close();
}
Example 4
// A pass phrase-less SSH key file and SSH password are both being provided.
// Given that the key file and pass phrase are valid a fallback to SSH 
// password will take place if authentication via SSH key file fails at 
// server side.
// place if a
var builder = new MySqlConnectionStringBuilder();
builder.UserID = "myUser";
builder.Password = "test";
builder.Server = "localhost";
builder.Port = 3307;
builder.SshHostName = "10.0.0.2";
builder.SshUserName = "mySshUser";
builder.SshKeyFile = @"C:\keys\noPassPhraseOpenSshKeyFile.ppk";
builder.SshPassword = "sshtest";
using (var connection = new MySqlConnection(builder.ConnectionString))
{
  connection.Open();
  connection.Close();
}
Example 5
// An X Protocol SSH connection using a URI-like connection string.
using (var session = MySQLX.GetSession("mysqlx://myUser:test@localhost:33060?sshHostName=10.0.0.2;sshUserName=mySshUser;sshPassword=sshTest"))
{
    session.Close();
}
Example 6
// An X Protocol SSH connection using an anonymous object along with
// setting an SSL Mode.
var sessionOptions = {
    UserID = "myUser",
    Password = "test",
    Server = "127.0.0.1",
    Port = 3307,
    SshHostName = "10.0.0.2",
    SshUserName = "mySshUser",
    SshKeyFile = @"C:\keys\myOpenSshKeyFile.ppk",
    SshPassPhrase = "sshtest",
    SslMode = MySqlSslMode.Required
  };
using (var session = MySQLX.GetSession(sessionOptions))
{
    session.Close();
}

Refer to the official documentation of Connector/NET for additional details on using SSH tunneling for your applications.

Creating SSL Connections with PEM Certificates

Connector/NET supports multiple levels of SSL encryption through the SSL Mode connection option. The list of allowed SSL encryption values are:

  • None: Do not use SSL.
  • Preferred: Use SSL, if server supports it.
  • Required: Always use SSL. Deny connection if server does not support SSL. Do not perform server certificate validation.
  • VerifyCA: Always use SSL. Validate server SSL certificate, but different host name mismatch.
  • VerifyFull: Always use SSL and perform full certificate validation.

The None, Preferred and Required SSL Modes don’t require the user to provide any certificates. Setting SSL Mode to VerifyCA requires that the SSL CA option is set. Setting SSL Mode to VerifyFull requires that SSL CA, SSL Cert and SSL Key are all set. Both VerifyCA and VerifyFull provide added security by performing various validations on the SSL certificates.

SSL Connection Options

Similar to how SSH tunneling introduced new connection options, a couple of connection options were added to support SSL PEM based connections. In past versions, the SSL CA and CertificateFile options could both be used to specify the path to a PFX certificate. Starting with version 8.0.16, the existing SSL CA option was extended to be used with SSL PEM connections as well. The full list of options relevant for SSL PEM connections can be found below:

Connection Option Description Property Name Connection String Options
SSL CA Specifies the path to a certificate file in PEM format (.pem) that contains a list of trusted SSL certificate authorities (CA). SslCa sslCa ,  ssl-Ca
SSL Cert The name of the SSL certificate file in PEM format to use for establishing an encrypted connection. SslCert sslCert ,  ssl-Cert
SSL Key The name of the SSL key file in PEM format to use for establishing an encrypted connection. SslKey sslKey , ssl-Key
SSL Mode Specifies the level of security required for SSL connections. sslMode ,  ssl Mode ,  ssl-Mode

As previously mentioned, the SSL CA option is also supported in PFX based SSL connections. The extension of the file referenced in this connection option tells Connector/NET how to process the certificate and in the case of PEM based connections, it will notify Connector/NET to check the SSL Cert and SSL Key options.

Connection Examples

The following code examples will get you started on creating SSL PEM based connections:

Example 1
// Here only the SSL Ca option is required since the SSL Mode is set to VerifyCA.
// The connection is being made using a MySqlConnectionStringBuilder object.
var builder = new MySqlConnectionStringBuilder();
builder.UserID = "myUser";
builder.Password = "test";
builder.Server = "localhost";
builder.SslCa = "ca.pem";
builder.SslMode = MySqlSslMode.VerifyCA; 
using (var connection = new MySqlConnection(builder.ConnectionString))
{
  connection.Open();
  connection.Close();
}
Example 2
// All SSL options are required since the SSL Mode is set to VerifyFull.
// The connection is being made using a connection string.
using (var connection = new MySqlConnection("uid=myUser;password=test;server=localhost;port=3307;sslMode=VerifyFull;sslCa=ca.pem;sslCert=client-cert.pem;sslKey=client.key.pem"))
{
  connection.Open();
  connection.Close();
}

SSL PEM connections are also available for the X Protocol. SSL connection options are named similarly in the MySqlXConnectionStringBuilder class, anonymous object and URI-like connection string methods. Feel free to use the one that best adapts to your  needs. 

Additional Information and Useful Links

We really hope that you’ve enjoyed the time invested in getting to know these new features and that they prove useful and a step in the right direction to deliver more robust and secure MySQL based applications.

Your feedback is always welcome, so be sure to provide any comments or report any issues into our forums and dedicated bug page.

Finally, we leave you with the following links which will serve as reference to additional information about the topics discussed in this blog post and with Connector/NET in general. Thank you. 

MySQL Workbench 8.0.17 has been released

.NET Core on Connector/NET updates.

$
0
0

Hello MySQL Connector/NET community,

Consistent with our ongoing effort to power MySQL products with the top technologies, we are pleased to announce the latest updates regarding MySQL Connector/NET and .NET Core.

And while we move forward, we also want to shape the product to maximize supportability. To achieve these two goals, we will deprecate the support for .NET Core 1.X to align with Microsoft’s end-of-life schedule (EOL May 14, 2019). But it’s not all about bad news, we also want to talk to you about the inclusion of .NET Core 2.2 support in the Connector/NET8.0.17 release. As you might know, .NET Core 2.2 is the latest GA release of .NET Core to provide a cross-platform framework that lets you build applications for Windows, Linux and macOS.

Our product, MySQL Connector/NET, is built against .NET Standard 2.0 that allows you to use it as a library in any of the .NET implementations compatible with that version of .NET Standard. For more details related to frameworks compatibility, you can go to the official .NET Standard versions web page. Given this, you can build a .NET Core 2.2 application using MySQL Connector/NET 8.0.17 and take advantage of all the new features and improvements this framework has to offer you.

To use Connector/NET in your .NET Core 2.2 project, simply make a reference to the library. There are two ways of achieving this:

  • First, by using NuGet to download a compatible version automatically.
  • Secondly, by downloading the MySQL Connector/NET source code and building it to ensure the corresponding DLLs are created. Then you can make use of the .NET Standard 2.0 version in your project.

Remember to include the element TargetFramework in your project file and to set the version of .NET Core desired, as shown in the example below:

<TargetFramework>netcoreapp2.2</TargetFramework>

If you are new to this framework, Microsoft offers a very useful guide to get you started with .NET Core (see Microsoft .NET Core guide).

We hope you find this information useful so you could start using MySQL Connector/NET with the most recent technologies. Your feedback is always welcome and all your comments inspire us to keep improving so that we offer you a product with top quality.

Finally, here are some links that could be useful for you:

We hope to hear from you!

MySQL Connector/ODBC 8.0.17 has been released

$
0
0

Dear MySQL users,

MySQL Connector/ODBC 8.0.17 is a new version in the MySQL Connector/ODBC 8.0 series,the ODBC driver for the MySQL Server.

The available downloads include both a Unicode driver and an ANSI driver based on the same modern codebase. Please select the driver type you need based on the type of your application – Unicode or ANSI. Server-side prepared statements are enabled by default. It is suitable for use with the latest MySQL server version 8.0.

This release of the MySQL ODBC driver is conforming to the ODBC 3.8 specification. It contains implementations of key 3.8 features, including self-identification as a ODBC 3.8 driver, streaming of out for binary types only), and support of the SQL_ATTR_RESET_CONNECTION connection attribute (for the Unicode driver only).

The release is now available in source and binary form for a number of platforms from our download pages at

https://dev.mysql.com/downloads/connector/odbc/

For information on installing, please see the documentation at

https://dev.mysql.com/doc/connector-odbc/en/connector-odbc-installation.html

Enjoy and thanks for the support!

Changes in MySQL Connector/ODBC 8.0.17  (2019-07-22, General Availability)

Functionality Added or Changed

     * README.md and CONTRIBUTING.md files were created for the convenience of git users. These files are not distributed with binaries, whereas README.txt remains distributed.

Bugs Fixed

     * The myodbc-installer command line utility did not display all DSN options. (Bug #29753227)

     * On Windows, building and installing from source could yield a binary that would not execute due to a case-sensitivity issue in the CMake logic. (Bug #29210040)

On Behalf of Oracle/MySQL Release Engineering Team,

Hery Ramilison 

Fix Problems Proactively with SQL Diagnostic Manager for MySQL (formerly Monyog)

$
0
0

In the conclusion of our blog series, Benefits of SQL Diagnostic Manager for MySQL (formerly Monyog), we explore features of SQL Diagnostic Manager for MySQL that allow database administrators to proactively monitor and manage MySQL and MariaDB servers. If you missed it, feel free to read last week’s post on monitoring MySQL and MariaDB servers.

Fix Problems Proactively with Hundreds of Monitors

SQL Diagnostic Manager for MySQL includes hundreds of monitors that are designed to examine the configuration and security of MySQL and MariaDB servers automatically, identify problems and tuning opportunities, and provides database administrators with specific corrective actions.

Use Advisor Rules

The Advisor Rules feature is a set of best practices that enables database administrators to monitor MySQL and MariaDB servers with confidence and to proactively manage the dynamic nature of all of their database servers over time. The Advisor Rules feature monitors all database servers. It notifies database administrators with specific instructions on how to proactively address the problems found to align with the best practices.

Automate Advisor Rules To Increase Productivity

SQL Diagnostic Manager for MySQL makes database administrators more productive by enabling them to automate each of the Advisor Rules for unattended, around the clock operations. The automation minimizes human errors, improves overall productivity, and lowers the total cost associated with managing MySQL and MariaDB servers.

Receive Proactive Alerts

For all the monitors, Advisor Rule violations trigger notification events. SQL Diagnostic Manager for MySQL sends these notifications via simple mail transfer protocol (SMTP), simple network management protocol (SNMP), the collaboration platform Slack, the incident response platform PagerDuty, and the messaging logging standard syslog. It also provides expert advice on the reported problem.

The ‘Delayed alert notifications’ feature ensures that SQL Diagnostic Manager for MySQL does not send alerts for insignificant events. Define that a problem must have existed for some sample intervals continuously in a row before sending an alert. A global setting for each MySQL and MariaDB server is available from the graphical user interface (GUI).

Read more in the full solution brief.

Find and fix MySQL performance problems on-premises and in the cloud with SQL Diagnostic Manager for MySQL.

The post Fix Problems Proactively with SQL Diagnostic Manager for MySQL (formerly Monyog) appeared first on Monyog Blog.

Automatic provisioning in Group Replication

$
0
0

With the release of version 8.0.17 of MySQL, we bring to you the brand new Clone plugin. Allowing you to get physical snapshots of data stored in InnoDB, this new plugin is an ideal addition to your Group Replication setup.

When joining a new server into a running replication group, a manual offline provisioning procedure was required in most cases as a tool to execute this step in the context of distributed recovery was missing.…


Clone: Create MySQL instance replica

$
0
0

Cloning MySQL instance data reliably and efficiently is required in many scenarios. This includes MySQL HA solutions where one needs to provision an instance before joining it to a Group Replication cluster or adding it as Slave in classic the replication model.

A Breakthrough in Usability – Automatic Node Provisioning

$
0
0

As announced in the previous blog post, MySQL InnoDB Cluster just got a very much requested feature which makes a complete, out-of-the-box, easy-to-use and versatile HA solution – Automatic Node Provisioning.

InnoDB cluster users can now rely on it for every single step of cluster deployment and management.…

MySQL Shell Plugins – Introduction

$
0
0

The MySQL Shell 8.0.17 introduces a novel way of extending its base functionality through plugins, which are JavaScript or Python scripts that allow the user to:

  • Register reports that can be used in monitoring tasks through the \show and \watch Shell Commands.

MySQL 8.0 InnoDB Architecture

Upcoming Mydbops Database Meetup -4 (03-08-2019)

$
0
0

Mydbops continues with its commitment to the open source community comprising of Database Administrators. After the successful conduct of three meet-ups in the past, we are now stepping ahead on to the 4th edition of Mydbops Database meet-up.

First time, we are going to the new venue, thanks to the kind people of Zenefits Technologies India Pvt.Ltd., It is a real pleasure to be hosted by the like-minded organisation in the city of Bangalore, scheduled on Saturday, 3rd of August, 2019 at Zenefits Office.

In the past three editions, the focus was on the latest and hands-on topics by the selected speakers from the DBA World. This focus gets sharper this time as well. The topics for the 4 th Mydbops Database Meetup are:

InnoDB scalability improvements in MySQL 8.0 Mr. Karthik P R, Founder / CEO of Mydbops, a MIT Masters Graduate.

Using ZFS filesystem, with MySQLMr.Bajrang Panigrahi, Sr. DBA at Zenefits Technologies (I) Pvt, Ltd.,a B.Tech graduate from BPUT

What is new is Galera 4 ?Mr. Aakash M, Rookie DBA at Mydbops, B.E. Graduate from KCET

MongoDB Sharded Cluster – How to design your Topology – Mr. Vinodh Krishnaswamy, Support Engineer at Percona and B.E. Graduate from KCT.

The topics are chosen with care, in order to capture the hands-on experience on the evolving subjects in order to sharing the knowledge to the gathering. Kindly register in the below link in order to attend the meet up.The meetup begins at 9:00 AM on the designated day with the following schedule:

Time Activity
09:00 AM Registration Commences
09:15 AM Key Note Presentation by Mr.Sagar Birla
09:30 AM Talk on Topic by Mr. Karthik P. R.
10:10 AM Talk on Topic by Mr. Bajrang Panigrahi
10:50 AM High Tea cum Networking
11:00 AM Talk on Topic by Mr. Aakash
11:40 AM Talk on Topic by Mr. Vinodh Krishnaswamy
12:30 PM Networking and Dispersement


Connect here to register for free – https://bit.ly/2OesFUC

Mydbops Database Meetup – 4

Saturday, Aug 3, 2019, 9:00 AM

ZENEFITS TECHNOLOGIES INDIA PVT LTD
2981, 12th Main Rd Bengaluru, Ka

21 Members Attending

=======================( No registration Fee )=========================== Event Agenda and Speaker info 09:00 AM – Registration 09:15 AM – Keynote Presentation by Sagar Birla ( Zenefits ) How Zenefits, have tweaked AWS SWF service to be used as a queuing mechanism. And what were the challenges (and solutions) that Zenefits faced during deployment o…

Check out this Meetup →


YOUR PRESENCE ENCOURAGES OUR SINCERE EFFORTS. PLEASE JOIN US TO GAIN FROM US.

SQL ORDER BY RANDOM

$
0
0

Introduction In this article, we are going to see how we can sort an SQL query result set using an ORDER BY clause that takes a RANDOM function provided by a database-specific function. This is a very handy trick, especially when you want to shuffle a given result set. Note that sorting a large result set using a RANDOM function might turn out to be very slow, so make sure you do that on small result sets. If you have to shuffle a large result set and limit it afterward, then it’s... Read More

The post SQL ORDER BY RANDOM appeared first on Vlad Mihalcea.

Where's the MySQL Team in August & September 2019

$
0
0

As follow up to the previous blog announcement about the conferences and events MySQL Team is attending, we would like to inform you about where you can find us during August & September 2019. Please find the list below.

  • August 2019:
    • Mid-Atlantic Developer Conference, Baltimore, US, August 1-2, 2019
      • MySQL Community team is a Bronze sponsor of this Developer conference. Our MySQL Community Manager, David Stokes will be giving 2 sessions as follows:
        • "MySQL & GIS" scheduled for Aug 1 @11:30-12:30pm
        • "MySQL without the SQL — Oh My!" Aug 2 @10:15-11:15am
      • Please do not forget to attend the MySQL sessions as well as stop by at our MySQL both in the expo area!
    • OpenSource Conference Kyoto, Japan, August 2-3, 2019
      • As tradition MySQL is a Gold sponsor of this OS show in Japan. This time you can find us at the MySQL booth in the expo area as well as you can find a MySQL talk in the schedule as follows:
        • "MySQL Development Trends-Introducing the Latest Information on Oracle/MySQL Cloud Service" given by Yuki Yamazaki. The talk is scheduled for Aug 3, @15:15-16:00.
    • Kansas Linux Fest (KLF), Wichita, Kansas City, US, August 9-11, 2019
      • MySQL Community team became a Silver sponsor of this Linux event. You can find our MySQL Community Manager, David Stokes there talking about MySQL during his two accepted sessions. The schedule is not yet done, so please watch the conference's website for further updates on timing and place:
        • "MySQL Without the SQL - Oh My!"
        • "The Proper Care and Feeding of a MySQL Database for Busy Linux Administrators". 
    • FrOSCon 2019, Snkt. Augustin, Germany, August 10-11, 2019
      • As tradition MySQL is part of this OS show in Germany. You can visit our MySQL experts at the MySQL booth in the expo area as well as you can attend a MySQL session given by Carsten Thalheimer, the MySQL Master Principal Sales Consultant. The session is:
        • "MySQL Best Practices - In 8 Schritten zur optimierten Datenbank!", scheduled for Sun, Aug 11 @14:00-15:00.
    • COSCUP, Taipei, Taiwan, August 17-18, 2019
      • MySQL is, same as last year, Gold sponsor of COSCUP Conference. You can find our team at the MySQL booth in the expo area as well as find multiple MySQL related talks in the schedule, see some of them below. The full schedule can be found here (Day 1) & here (Day 2).
        • "MySQL InnoDB Custer" given by Ivan Ma, the MySQL Principal Solution Engineer. Ivan's talk is scheduled for Aug 17 @10:45-11:25am.
        • "MySQL Performance - the Dos and Don'ts" given by Yoshiaki Yamasaki, the MySQL Senior Solution Engineer. His talk is scheduled for Aug 17 @13:25-14:05.
        • "MySQL 8.0有那些值得注意的新發展" given by Ryusuke Kajiyama, the MySQL Sales Consulting Senior Manager. His talk is scheduled for Aug 17 @14:55-15:35.
        • ... other MySQL related talks are scheduled for Day 2 (Aug 18) from 10:00-16:00 in IB302 room.
    • FOSS4G, Tokai, Japan, August 23-24, 2019
      • MySQL is a partner of OSGeo.JP group which is organizing FOSS4G events. The previous FOSS4G event we also attended took place in Hokkaido last month. MySQL got an opportunity to run MySQL seminar at this show. At this moment we do not know more details, please check organizers' website for further updates.
    • OpenSource Developer Conference, Tokyo, Japan, August 24, 2019
      • Same as last year we are glad to inform you that MySQL is Gold sponsor of this one day show. This year you could be again able to find our team at the MySQL booth in the expo area as well as attend the MySQL session as follows:
        • "Not only MySQL Server, there is also MySQL Shell" given by Ikoma Tomoko. The talk is scheduled for 15:15-16:00.
      • We are looking forward talking to you in Tokyo!
  • September 2019:
    • SwanseaCon, Swansea, UK, September 9, 2019
      • We are happy to announce that MySQL is again back in the UK for the lovely SwanseaCon event! This year our new colleague will staff the MySQL booth as well as run the MySQL talk. We are looking forward seeing you there! Please do not miss the talk as follows:
        • "NoSQL + SQL = MySQL" given by Stuart Davey, the MySQL Principal Sales Consultant. His talk is scheduled for 11:15-12:00
    • FOSS4G Niigata, Japan, September 13-14, 2019
      • MySQL is a partner of OSGeo.JP group which is organizing FOSS4G events. MySQL got an opportunity to run MySQL seminar at this show. At this moment we do not know more details, please check organizers' website for further updates.
    • OpenSource Conference, Hiroshima, Japan, September 15, 2019
      • As usual MySQL is a Gold sponsor of this OS show, this time in Hiroshima. Do not miss to stop by at our MySQL booth in the expo area as well as come to listen the MySQL talk as follows: 
        • "Finally released! MySQL 8.0 Latest information" given by Yuka Yamazaki from Oracle/MySQL Community. The talk is scheduled for 16:10-16:55.
    • Oracle Open World / MySQL Reception, San Francisco, US, September 16-19, 2019
      • Same as last year MySQL will be part of OOW in San Francisco. Right now we are planning to hold a MySQL Reception on the Sep 17, 2019 as the evening with all MySQLers coming to OOW. More details will be published once the place is fully booked. Just please mark your calendars for the date and more details will come soon!
    • WebExpo, Prague, CZ, September 20-22, 2019
      • This is the fifth time MySQL is partner of WebExpo, the biggest technology conference in the Czech republic! This year, same as last year you will be able to find two teams at Oracle booth in the expo area, NetSuite (Bronto) team & MySQL. Do not forget to stop by!
      • You can also attend the MySQL talk given by Vittorio Cioe, the Senior MySQL Sales Consultant as follows:
        • "Modern Data Security with MySQL 8.0", scheduled for Sat, Sep 21 @14:00-14:40pm.
    • db tech showcase, Tokyo, Japan, September 25-27, 2019
      • We are happy to announce that MySQL is again part of this DB show in Tokyo. We became Silver sponsor with a MySQL booth and speaking opportunity. MySQL got 2 speaking slots as well as 2 MySQL case study sessions and one session for MySQL User Group. Please watch organizers' website for further updates.
    • PerconaLive, Amsterdam, Holland, September 30-October 2, 2019
      • MySQL team is going to become Silver partner of PerconaLive Amsterdam this September. The schedule and planning is not yet done, but we assume to have multiple MySQL talks as well as MySQL booth in the expo area. Do not miss to come to talk to us! We are looking forward talking to you!​​

Impact of innodb_file_per_table Option On Crash Recovery Time

$
0
0

MySQL Logo Starting at version MySQL5.6+ by default innodb_file_per_table is enabled and all data is stored in separate tablespaces.

It provides some advantages. I will highlight some of them:

  • You can reclaim disk space when truncating or dropping a table stored in a file-per-table tablespace. Truncating or dropping tables stored in the shared system tablespace creates free space internally in the system tablespace data files (ibdata files) which can only be used for new InnoDB data.
  • You can store specific tables on separate storage devices, for I/O optimization, space management, or backup purposes.
  • You can monitor table size at a file system level without accessing MySQL.
  • Backups taken with Percona XtraBackup takes less space (compared with the physical backup of ibdata files)

Problem

There are disadvantages described on MySQL man page but I found another one that is not mentioned: if you have a huge number of tables, the crash recovery process may take a lot of time.

During crash recovery the MySQL daemon scans .ibd files:

2019-07-16 21:00:04 6766 [Note] InnoDB: Starting crash recovery.
2019-07-16 21:00:04 6766 [Note] InnoDB: Reading tablespace information from the .ibd files...
# Started at Jul 16 23:46:52:
Version: '5.6.39-83.1-log' socket: ......

During startup time I checked MySQL behavior and found that MySQL opens files one by one. In my test case it was 1400000+ tables and it took 02:46:48 just to scan ibd files.

To prevent such a long downtime we decided to move all the tables to shared tablespaces.

Solution – moving tables to shared tablespaces

  1. Make sure that you have enough space on disk.
  2. Modify my.cnf and add the files.
  3. Restart MySQL and wait until it creates the data files.
  4. Move your InnoDB tables to shared tablespaces.

You can use this script:

# Get table list that stored in own tablespace (SPACE>0)
mysql -NB information_schema -e "select NAME from INNODB_SYS_TABLES WHERE name not like 'SYS_%' AND name not like 'mysql/%' AND SPACE > 0" | split -l 30000 - tables;
# Generate SQL script
for file in `ls tables*`;
do
perl -e '$curdb=""; while(<STDIN>) {chomp; ($db,$table) = split(/\//); if ($curdb ne $db ) { print "USE $db;\n"; $curdb=$db; } print "ALTER TABLE $table engine=innodb;\n"; }' < $file > $file.SQL;
done
# Apply files $file.SQL ( you can use parallel execution ) :
cat<<EOF>convert.sh
file=\$1
mysql < \${file}
EOF
# Do not forget to fix my.cnf
mysql -e "set global innodb_file_per_table = 0"
chmod +x convert.sh
# run 10 parallel threads
ls tables*.SQL | xargs -n1 -P10 ./convert.sh

What the script does:

  1. Retrieves all tables that are occupying their own tablespace
  2. Generates SQL code in this pattern
    USE DB_X; ALTER TABLE TBL_Y engine=innodb;
  3. Applies the SQL scripts in parallel.

After changing file_per_table to 0 and moving the InnoDB tables:

2019-07-17 22:16:47 976 [Note] InnoDB: Reading tablespace information from the .ibd files...
2019-07-17 22:25:45 976 [Note] mysqld: ready for connections.

Conclusion

Using the default value of innodb_file_per_table (ON) is not always a good choice. In my test case: 4000+ databases, 1400000+ tables. I reduced recovery time from 02:46:48 to 00:08:58 seconds.

That’s 18 times less!

Remember, there is no “golden my.cnf config”, and each case is special. Optimize MySQL configuration according to your needs.


The content in this blog is provided in good faith by members of the open source community. The content is not edited or tested by Percona, and views expressed are the authors’ own. When using the advice from this or any other online resource, please test ideas before applying them to your production systems, and always secure a working back up.

Cartoon source https://imgur.com/

The post Impact of innodb_file_per_table Option On Crash Recovery Time appeared first on Percona Community Blog.

MySQL Router 8.0.17 and the REST API

$
0
0

Since MySQL 8.0.16, the Router as the possibility to launch an internal webserver (see Jan’s blog post).

Even if this webserver could serve static files, it was the first piece of a much more interesting solution that is now available since 8.0.17.

It’s possible now to query the MySQL Router via its REST API and get a lot of useful information.

Setup

Let’s first configure our MySQL Router to take advantages of this new feature. In this example, I will add the following lines to /etc/mysqlrouter/mysqlrouter.conf that I created using the --bootsrapcommand line argument:

[http_server]
port=8080

[rest_api]

[rest_router]
require_realm=somerealm

[rest_routing]
require_realm=somerealm

[rest_metadata_cache]
require_realm=somerealm

[http_auth_realm:somerealm]
backend=somebackend
method=basic
name=Some Realm

[http_auth_backend:somebackend]
backend=file
filename=/etc/mysqlrouter/mysqlrouter.pwd

Now, I will create the required credentials:

# mysqlrouter_passwd set /etc/mysqlrouter/mysqlrouter.pwd fred

I can of course verify it:

# mysqlrouter_passwd verify /etc/mysqlrouter/mysqlrouter.pwd fred
Please enter password:

And finally, I must change the ownership of my new password file:

# chown mysqlrouter /etc/mysqlrouter/mysqlrouter.pwd

It’s time to restart MySQL Router.

Using the REST API

Now that the MySQL Router is running and it has been configure, what can we do with it ?

For example, if we want to know which server will be reached for RW, we can use the following command:

$ curl -s -u fred:fred \
  http://192.168.91.2:8080/api/20190715/routes/myCluster_default_rw/destinations
{"items":[{"address":"mysql2","port":3306}]}

It’s also possible to list all the possible calls that can be performed using /api/20190715/swagger.json:

$ curl -s -u fred:fred http://192.168.91.2:8080/api/20190715/swagger.json | jq '.paths'
{
   "/metadata/{metadataName}/config": {
     "get": {
       "tags": [
         "cluster"
       ],
       "description": "Get config of the metadata cache of a replicaset of a cluster",
       "responses": {
         "200": {
           "description": "config of metadata cache",
           "schema": {
             "$ref": "#/definitions/MetadataConfig"
           }
         },
         "404": {
           "description": "cache not found"
         }
       }
     },
     "parameters": [
       {
         "$ref": "#/parameters/metadataNameParam"
       }
     ]
   },
   "/metadata/{metadataName}/status": {
     "get": {
       "tags": [
         "cluster"
       ],
       "description": "Get status of the metadata cache of a replicaset of a cluster",
       "responses": {
         "200": {
           "description": "status of metadata cache",
           "schema": {
             "$ref": "#/definitions/MetadataStatus"
           }
         },
         "404": {
           "description": "cache not found"
         }
       }
     },
     "parameters": [
       {
         "$ref": "#/parameters/metadataNameParam"
       }
     ]
   },
   "/metadata": {
     "get": {
       "tags": [
         "cluster"
       ],
       "description": "Get list of the metadata cache instances",
       "responses": {
         "200": {
           "description": "list of the metadata cache instances",
           "schema": {
             "$ref": "#/definitions/MetadataList"
           }
         }
       }
     }
   },
   "/routes/{routeName}/config": {
     "get": {
       "tags": [
         "routes"
       ],
       "description": "Get config of a route",
       "responses": {
         "200": {
           "description": "config of a route",
           "schema": {
             "$ref": "#/definitions/RouteConfig"
           }
         },
         "404": {
           "description": "route not found"
         }
       }
     },
     "parameters": [
       {
         "$ref": "#/parameters/routeNameParam"
       }
     ]
   },
   "/routes/{routeName}/status": {
     "get": {
       "tags": [
         "routes"
       ],
       "description": "Get status of a route",
       "responses": {
         "200": {
           "description": "status of a route",
           "schema": {
             "$ref": "#/definitions/RouteStatus"
           }
         },
         "404": {
           "description": "route not found"
         }
       }
     },
     "parameters": [
       {
         "$ref": "#/parameters/routeNameParam"
       }
     ]
   },
   "/routes/{routeName}/health": {
     "get": {
       "tags": [
         "routes"
       ],
       "description": "Get health of a route",
       "responses": {
         "200": {
           "description": "health of a route",
           "schema": {
             "$ref": "#/definitions/RouteHealth"
           }
         },
         "404": {
           "description": "route not found"
         }
       }
     },
     "parameters": [
       {
         "$ref": "#/parameters/routeNameParam"
       }
     ]
   },
   "/routes/{routeName}/destinations": {
     "get": {
       "tags": [
         "routes"
       ],
       "description": "Get destinations of a route",
       "responses": {
         "200": {
           "description": "destinations of a route",
           "schema": {
             "$ref": "#/definitions/RouteDestinationList"
           }
         },
         "404": {
           "description": "route not found"
         }
       }
     },
     "parameters": [
       {
         "$ref": "#/parameters/routeNameParam"
       }
     ]
   },
   "/routes/{routeName}/connections": {
     "get": {
       "tags": [
         "routes"
       ],
       "description": "Get connections of a route",
       "responses": {
         "200": {
           "description": "connections of a route",
           "schema": {
             "$ref": "#/definitions/RouteConnectionsList"
           }
         },
         "404": {
           "description": "route not found"
         }
       }
     },
     "parameters": [
       {
         "$ref": "#/parameters/routeNameParam"
       }
     ]
   },
   "/routes/{routeName}/blockedHosts": {
     "get": {
       "tags": [
         "routes"
       ],
       "description": "Get blocked host list for a route",
       "responses": {
         "200": {
           "description": "blocked host list for a route",
           "schema": {
             "$ref": "#/definitions/RouteBlockedHostList"
           }
         },
         "404": {
           "description": "route not found"
         }
       }
     },
     "parameters": [
       {
         "$ref": "#/parameters/routeNameParam"
       }
     ]
   },
   "/routes": {
     "get": {
       "tags": [
         "routes"
       ],
       "description": "Get list of the routes",
       "responses": {
         "200": {
           "description": "list of the routes",
           "schema": {
             "$ref": "#/definitions/RouteList"
           }
         }
       }
     }
   },
   "/router/status": {
     "get": {
       "tags": [
         "app"
       ],
       "description": "Get status of the application",
       "responses": {
         "200": {
           "description": "status of application",
           "schema": {
             "$ref": "#/definitions/RouterStatus"
           }
         }
       }
     }
   }
 }

The current API (version 20190715), supports the following urls:

  • /metadata/{metadataName}/config
  • /metadata/{metadataName}/status
  • /metadata
  • /routes/{routeName}/config
  • /routes/{routeName}/status
  • /routes/{routeName}/health
  • /routes/{routeName}/destinations
  • /routes/{routeName}/connections
  • /routes/{routeName}/blockedHosts
  • /routes
  • /router/status

Some examples

$ curl -s -u fred:fred http://192.168.91.2:8080/api/20190715/metadata | jq 
{
  "items": [
    {
      "name": "myCluster"
    }
  ]
}
$ curl -s -u fred:fred http://192.168.91.2:8080/api/20190715/metadata/myCluster/status | jq 
{
  "refreshFailed": 0,
  "refreshSucceeded": 3639,
  "timeLastRefreshSucceeded": "2019-07-08T09:17:22.463136Z",
  "lastRefreshHostname": "mysql1",
  "lastRefreshPort": 3306
}
$ curl -s -u fred:fred http://192.168.91.2:8080/api/20190715/metadata/myCluster/config | jq 
{
  "clusterName": "myCluster",
  "timeRefreshInMs": 500,
  "groupReplicationId": "b2025e72-9e5e-11e9-95c9-08002718d305",
  "nodes": [
    {
      "hostname": "mysql1",
      "port": 3306
    },
    {
      "hostname": "mysql2",
      "port": 3306
    }
}

Conclusion

I really invite you to update to the latest version of MySQL Router, don’t forget that even with MySQL InnoDB Cluster 5.7.x you must use the latest MySQL Router 8.0 and MySQL Shell 8.0 and try the new REST API.

Some 'Small' Changes in MySQL 8.0.17

$
0
0
I would like to point out some 'small' things you may not have noticed in the MySQL 8.0.17 Release Notes.  They are small changes compared to things like MVIs, InnoDB cloning, and the like but these are the types of changes that are subtle that may catch you unaware.

1. Host names have grown from 60 to 255 characters.  However your SSL/TLS package may not be able to handle the longer names.

2. If you are an old C/C++ programmer, 'C-style &&, ||, and ! operators that are synonyms for the standard SQL AND, OR, and NOT operators, respectively, are deprecated and support for them will be removed in a future MySQL version'.

3. The ZERO fill attribute is being deprecated as is unsigned FLOAT, DOUBLE, and DECIMAL. You can no longer AUTO_INCREMENT FLOAT and DOUBLE columns.

4. The optimizer will rewrite your WHERE foo to WHERE foo != 0 to ensure complete predicates are being used to plan your query.

Connect to MySQL after hitting ERROR 1040: Too many connections

$
0
0
ERROR 1040

ERROR 1040: Too many connectionsERROR 1040…again

A pretty common topic in Support tickets is the rather infamous error: ERROR 1040: Too many connections. The issue is pretty self-explanatory: your application/users are trying to create more connections than the server allows, or in other words, the current number of connections exceeds the value of the max_connections variable.

This situation on its own is already a problem for your end-users, but when on top of that you are not able to access the server to diagnose and correct the root cause, then you have a really big problem; most times you will need to terminate the instance and restart it to recover.

Root user can’t connect either! Why!?

In a properly set up environment, a user with SUPER privilege will be able to access the instance and diagnose the error 1040 problem that is causing connection starvation, as explained in the manual:

mysqld actually permits max_connections + 1 client connections. The extra connection is reserved for use by accounts that have the SUPER privilege. By granting the privilege to administrators and not to normal users (who should not need it), an administrator who also has the PROCESS privilege can connect to the server and use SHOW PROCESSLIST to diagnose problems even if the maximum number of unprivileged clients are connected.

But we see lots of people who give SUPER privileges to their application or script users, either due to application requirements (dangerous!) or due to lack of knowledge regarding the consequences, but the case is then that the reserved connection is taken by a regular user, and your administrative user (usually root) won’t be able to connect.

How to guarantee access to the instance

Besides resorting to the well known GDB hack devised by Aurimas long ago for Error 1040, there are now better solutions, but you need to enable them first.

With Percona Server 5.5.29 and up, and with MySQL 8.0.14 and up, you can set up an extra port that allows a number of extra connections. These additional interfaces will not be used by your applications; they are only for your database administrators and monitoring/health-check agents (see note on this further below).

Setting up in Percona Server

Starting with Percona Server 5.5.29, you can simply add extra_port to your my.cnf and the next time you restart the port will become available and will listen on the same bind_address as regular connections. If you don’t set the extra_port variable, no additional port will be available by default.

You can also define extra_max_connections which sets the number of connections this port will handle. The default value for this is 1.

For a quick demo, I have saturated connections on the regular users port of an instance where I already have set extra_port and extra_max_connections in the my.cnf:

~ egrep 'port|extra' my.sandbox.cnf
port                  = 45989
extra_port            = 45999
extra_max_connections = 10

# attempt to show some variables
~ mysql --host=127.0.0.1 --port=45989 --user=msandbox --password -e "SHOW GLOBAL VARIABLES WHERE Variable_name IN ('port', 'extra_port')"
ERROR 1040 (HY000): Too many connections

# now again, through the extra_port
~ mysql --host=127.0.0.1 --port=45999 --user=msandbox --password -e "SHOW GLOBAL VARIABLES WHERE Variable_name IN ('port', 'extra_port')"
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| extra_port    | 45999 |
| port          | 45989 |
+---------------+-------+

Note that extra_port has been removed in Percona Server 8.0.14 and newer since MySQL Community has implemented admin_port which duplicates this functionality. So make sure to edit your my.cnf when upgrading to Percona Server 8.0.14 or newer if you already have extra_port defined there!

Setting up in MySQL Community

As mentioned, this requires MySQL 8.0.14 where WorkLog 12138 was implemented.

To enable the Admin Interface you have to define the admin_addres, which must be a single and unique (no wildcards allowed) IPv4, IPv6, IPv4-mapped, or hostname on which the admin interface will listen. If this variable is not defined, then the interface is not enabled at all.

You can also define a port, but it’s not mandatory and it defaults to 33062. So if that port is free then you don’t need to configure it. When defined, both variables should be placed under the [mysqld] section of your my.cnf.

Finally, you can also set create_admin_listener_thread (disabled by default) which will create a separate thread for incoming connection handling, which can be helpful in some situations.

Another difference is that Oracle’s documentation claims that:

There is no limit on the number of administrative connections.

(This is in contrast with our default of 1). I am not sure what this means, but I would be careful making sure you don’t accidentally establish 1,000,000 connections as they might not be limited but would still consume resources!

Using it for monitoring and health-checks

A very useful thing is that not only humans can use the extra interface/port during emergency cases where max_connections has been reached; it can also be used by your monitoring system and your proxy/load balancer/service discovery health-check probes.

Monitoring scripts can still pull data for your graphs to later understand why the connection pile up happened. And your health-check scripts could report the degraded state of the server, possibly with a particular code indicating connections are saturated but the server is responsive (meaning it could clear on its own, so it might be worth allowing a longer timeout to failover).

As a warning: make sure to establish only one single connection at a time for monitoring/health probes, to avoid filling up the extra_max_connections in Percona Server or to avoid creating one million threads in MySQL. In other words, your scripts should not connect again if the previous query/connection to the database is still ongoing.

And here is the same demo as before with MySQL:

~ grep admin_ my.sandbox.cnf
admin_address = 127.0.0.1
admin_port = 34888

# regular port
~ mysql --host=127.0.0.1 --port=35849 --user=msandbox --password -e "SHOW GLOBAL VARIABLES WHERE Variable_name IN ('port', 'admin_address', 'admin_port');"
Enter password:
ERROR 1040 (HY000): Too many connections

# admin interface and port
~ mysql --host=127.0.0.1 --port=34888 --user=msandbox --password -e "SHOW GLOBAL VARIABLES WHERE Variable_name IN ('port', 'admin_address', 'admin_port');"a
Enter password:
+---------------+-----------+
| Variable_name | Value     |
+---------------+-----------+
| admin_address | 127.0.0.1 |
| admin_port    | 34888     |
| port          | 35849     |
+---------------+-----------+

Note that for Percona Server 8.0.14 and newer, the process will be the same as for MySQL Community.

Help! I need to login but I don’t have an extra port!

If this is the reason you are reading this post, then you can either follow the crazy GDB hack (no offense meant, Aurimas! Just seems risky :-D) or terminate the instance. The good part is that (most times) you can terminate the instance in a clean fashion by using SIGTERM (-15) instead of SIGKILL (-9). This will tell the server it should perform a clean shutdown, which will give threads a chance to exit gracefully. To do so simply run these:

1) Get PID

marcos.albe in ~/ pgrep -x mysqld;
650

2) And then send SIGTERM to that PID:

marcos.albe in ~/ kill -15 650;

3) You can now tail the error log to watch the shutdown happening; You should see a sequence like

2019-07-11T13:43:28.421244Z 0 [Note] Giving 0 client threads a chance to die gracefully
2019-07-11T13:43:28.521238Z 0 [Note] Shutting down slave threads
2019-07-11T13:43:28.521272Z 0 [Note] Forcefully disconnecting 0 remaining clients

That signals the beginning of the shutdown sequence. Then you should wait for a line like the one below to appear, to know the shutdown is complete:

2019-07-11T13:43:31.292836Z 0 [Note] /opt/percona_server/5.7.26/bin/mysqld: Shutdown complete

mysqlbinlog: support for protocol compression

$
0
0

We are happy to share with you that the mysqlbinlog tool has been enhanced. Starting on 8.0.17, the user can instruct the mysqlbinlog tool to negotiate, with the server that it connects to, whether to use protocol compression or not.

Since MySQL 5.6, the mysqlbinlog tool can connect to a remote server and act as a slave.…

Viewing all 18803 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>