Documentation Home
MySQL 9.0 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 40.0Mb
PDF (A4) - 40.1Mb
Man Pages (TGZ) - 259.0Kb
Man Pages (Zip) - 366.2Kb
Info (Gzip) - 4.0Mb
Info (Zip) - 4.0Mb


MySQL 9.0 Reference Manual  / ...  / SQL Statements  / Data Definition Statements  /  CREATE SERVER Statement

15.1.18 CREATE SERVER Statement

CREATE SERVERserver_name    FOREIGN DATA WRAPPERwrapper_name    OPTIONS (option [,option] ...)option: {    HOSTcharacter-literal  | DATABASEcharacter-literal  | USERcharacter-literal  | PASSWORDcharacter-literal  | SOCKETcharacter-literal  | OWNERcharacter-literal  | PORTnumeric-literal}

This statement creates the definition of a server for use with theFEDERATED storage engine. TheCREATE SERVER statement creates a new row in theservers table in themysql database. This statement requires theSUPER privilege.

Theserver_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.

Thewrapper_name is an identifier and may be quoted with single quotation marks.

For eachoption 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.

Note

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

TheCREATE SERVER statement creates an entry in themysql.servers table that can later be used with theCREATE TABLE statement when creating aFEDERATED table. The options that you specify are used to populate the columns in themysql.servers table. The table columns areServer_name,Host,Db,Username,Password,Port andSocket.

For example:

CREATE SERVER sFOREIGN DATA WRAPPER mysqlOPTIONS (USER 'Remote', HOST '198.51.100.106', 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 aFEDERATED table:

CREATE TABLE t (s1 INT) ENGINE=FEDERATED CONNECTION='s';

For more information, seeSection 18.8, “The FEDERATED Storage Engine”.

CREATE SERVER causes an implicit commit. SeeSection 15.3.3, “Statements That Cause an Implicit Commit”.

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