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

MySQL 5.7 Reference Manual  /  ...  /  CREATE SERVER Syntax

13.1.13 CREATE SERVER Syntax

CREATE SERVER server_name
    FOREIGN DATA WRAPPER wrapper_name
    OPTIONS (option [, option] ...)

  { HOST character-literal
  | DATABASE character-literal
  | USER character-literal
  | PASSWORD character-literal
  | SOCKET character-literal
  | OWNER character-literal
  | PORT numeric-literal }

This statement creates the definition of a server for use with the FEDERATED storage engine. The CREATE SERVER statement creates a new row in the servers table in the mysql database. This statement requires the SUPER privilege.

The server_name should be a unique reference to the server. Server definitions are global within the scope of the server, it is not possible to qualify the server definition to a specific database. server_name has a maximum length of 64 characters (names longer than 64 characters are silently truncated), and is case insensitive. You may specify the name as a quoted string.

The wrapper_name should be mysql, and may be quoted with single quotation marks. Other values for wrapper_name are not currently supported.

For each option you must specify either a character literal or numeric literal. Character literals are UTF-8, support a maximum length of 64 characters and default to a blank (empty) string. String literals are silently truncated to 64 characters. Numeric literals must be a number between 0 and 9999, default value is 0.


The OWNER option is currently not applied, and has no effect on the ownership or operation of the server connection that is created.

The CREATE SERVER statement creates an entry in the mysql.servers table that can later be used with the CREATE TABLE statement when creating a FEDERATED table. The options that you specify will be used to populate the columns in the mysql.servers table. The table columns are Server_name, Host, Db, Username, Password, Port and Socket.

For example:

OPTIONS (USER 'Remote', HOST '', DATABASE 'test');

Be sure to specify all options necessary to establish a connection to the server. The user name, host name, and database name are mandatory. Other options might be required as well, such as password.

The data stored in the table can be used when creating a connection to a FEDERATED table:


For more information, see Section 15.8, “The FEDERATED Storage Engine”.

CREATE SERVER causes an automatic commit.

In MySQL 5.7, CREATE SERVER is not written to the binary log, regardless of the logging format that is in use.

In MySQL 5.7.1, gtid_next must be set to AUTOMATIC before issuing this statement. This restriction does not apply in MySQL 5.7.2 or later. (Bug #16062608, Bug #16715809, Bug #69045)

Download this Manual
User Comments
  Posted by ALEXANDER SKAKUNOV on January 8, 2013
We use this in our project - it's very nice for deployment since you can create a server this way and then use the federated tables - which are the same as symlinks in Linux so you can avoid copying the same data between projects (for example, Geo tables).
Sign Up Login You must be logged in to post a comment.