Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual Excerpts from this Manual

MySQL 5.7 Reference Manual  /  ...  /  Installing and Configuring the InnoDB memcached Plugin Installing and Configuring the InnoDB memcached Plugin

Setting Up Required Tables

To configure the memcached plugin so it can interact with InnoDB tables, run the innodb_memcached_config.sql configuration script to install the necessary tables used behind the scenes:

mysql> source MYSQL_HOME/share/innodb_memcached_config.sql

This is a one-time operation. The tables remain in place if you later disable and re-enable the memcached support. For information about the layout and purpose of these tables, see Section 14.17.7, “Internals of the InnoDB memcached Plugin”.

Installing the Daemon Plugin

To activate the daemon plugin, use the install plugin statement, just as when installing any other MySQL plugin:

mysql> install plugin daemon_memcached soname "";

Once the plugin is installed this way, it is automatically activated each time the MySQL server is booted or restarted.

Disabling the Daemon Plugin

When making major changes to the plugin configuration, you might need to turn off the plugin. To do so, issue the following statement:

mysql> uninstall plugin daemon_memcached;

To re-enable it, issue the preceding install plugin statement again. All the previous configuration settings, internal tables, and data are preserved when the plugin is restarted this way.

For additional information about enabling and disabling plugins, see Section, “Installing and Uninstalling Plugins”.

Specifying memcached Configuration Options

If you have any memcached specific configuration parameters, specify them on the mysqld command line or enter them in the MySQL configuration file, encoded in the argument to the daemon_memcached_option MySQL configuration option. The memcached configuration options take effect when the plugin is installed, which you do each time the MySQL server is started.

For example, to make memcached listen on port 11222 instead of the default port 11211, add -p11222 to the MySQL configuration option daemon_memcached_option:

mysqld .... --daemon_memcached_option="-p11222"

You can add other memcached command line options to the daemon_memcached_option string. The other configuration options are:

  • daemon_memcached_engine_lib_name (default

  • daemon_memcached_engine_lib_path (default NULL, representing the plugin directory).

  • daemon_memcached_r_batch_size, batch commit size for read operations (get). It specifies after how many memcached read operations the system automatically does a commit. By default, this is set to 1 so that every get request can access the very latest committed data in the InnoDB table, whether the data was updated through memcached or by SQL. When its value is greater than 1, the counter for read operations is incremented once for every get call. The flush_all call resets both the read and write counters.

  • daemon_memcached_w_batch_size, batch commit for any write operations (set, replace, append, prepend, incr, decr, and so on) By default, this is set as 1, so that no uncommitted data is lost in case of an outage, and any SQL queries on the underlying table can access the very latest data. When its value is greater than 1, the counter for write operations is incremented once for every add, set, incr, decr, and delete call. The flush_all call resets both the read and write counters.

By default, you do not need to change anything with the first two configuration options. Those options allow you to load any other storage engine for memcached (such as the NDB memcached engine).

Again, please note that you will have these configuration parameters in your MySQL configuration file or MySQL boot command line. They take effect when you load the memcached plugin.


Now you have everything set up. You can directly interact with InnoDB tables through the memcached interface. To verify that the feature is working properly, see Section, “Verifying the InnoDB and memcached Setup”.

Download this Manual
User Comments
  Posted by Alexander Panyutin on April 23, 2015
Please add the manual page about enabling memcached with InnoDB under SELinux.

If you use SELinux ( run "getenforce" if it is answer Enforcing - then - you will ) and in /var/log/mysqld.log you'll see
bind(): Permission denied
failed to listen on TCP/UDP port 11222: Permission denied
Then do the following.

1. If you use non standart port ( not 11211, means other memcached for mySQL on the same server with other memcached ) you need allow this port
sudo semanage port -a -t memcache_port_t -p udp 11222
sudo semanage port -a -t memcache_port_t -p tcp 11222
From now - it is allowed to run/connect memcached on this port

2. Second - SELinux don't allow to run memcached from mysqld service. Do the following.

2.1. Make a -te file with following content ( for example we name it MySQL-InnoDB-Memcached.te )

module audit 1.0;

require {
type memcache_port_t;
type mysqld_t;
class tcp_socket name_bind;

#============= mysqld_t ==============
allow mysqld_t memcache_port_t:tcp_socket name_bind;

require {
type memcache_port_t;
type mysqld_t;
class udp_socket name_bind;

#============= mysqld_t ==============
allow mysqld_t memcache_port_t:udp_socket name_bind;

2.2. Now prepare this for SELinux
2.2.1. Check and build
checkmodule -M -m -o MySQL-InnoDB-Memcached.mod MySQL-InnoDB-Memcached.te
2.2.2. Pack
semodule_package -o MySQL-InnoDB-Memcached.pp -m MySQL-InnoDB-Memcached.mod
2.2.3. Load
semodule -i MySQL-InnoDB-Memcached.pp

3. Now you can restart your mysqld.
service mysqld restart.
Sign Up Login You must be logged in to post a comment.