All pages
Powered by GitBook
1 of 1

Loading...

CREATE SERVER

Define a connection to a remote server. This command registers server details for use with the FEDERATED or SPIDER storage engines.

Syntax

Description

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

This statement creates the definition of a server for use with the , , , or storage engine. The CREATE SERVER statement creates a new row in the table within the mysql database. This statement requires the 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 may be quoted with single quotes. Supported values are:

  • mysql

  • mariadb (from )

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.

Note: 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 table that can later be used with the CREATE TABLE statement when creating a , , or 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.

removes a previously created server definition.

CREATE SERVER is not written to the , irrespective of the being used and therefore will not replicate.

replicates the CREATE SERVER, and statements.

does not replicate the CREATE SERVER, and statements.

For valid identifiers to use as server names, see .

The statement can be used to show the CREATE SERVER statement that created a given server definition.

The statement cannot be used to show the CREATE SERVER statement that created a given server definition.

OR REPLACE

If the optional OR REPLACE clause is used, it acts as a shortcut for:

IF NOT EXISTS

If the IF NOT EXISTS clause is used, MariaDB will return a warning instead of an error if the server already exists. Cannot be used together with OR REPLACE.

Examples

OR REPLACE and IF NOT EXISTS:

See Also

This page is licensed: GPLv2, originally from

CREATE [OR REPLACE] SERVER [IF NOT EXISTS] server_name
    FOREIGN DATA WRAPPER wrapper_name
    OPTIONS (option [, option] ...)

option: <= MariaDB 11.6
  { HOST character-literal
  | DATABASE character-literal
  | USER character-literal
  | PASSWORD character-literal
  | SOCKET character-literal
  | OWNER character-literal
  | PORT numeric-literal }

option: >= MariaDB 11.7
  { HOST character-literal
  | DATABASE character-literal
  | USER character-literal
  | PASSWORD character-literal
  | SOCKET character-literal
  | OWNER character-literal
  | PORT numeric-literal
  | PORT quoted-numerical-literal
  | identifier character-literal}
Connect Storage Engine
  • mysql.servers table

  • SHOW CREATE SERVER

  • Spider
    Connect
    FEDERATED
    FederatedX
    servers
    FEDERATED ADMIN
    Spider
    Connect
    FEDERATED
    FederatedX
    servers
    SUPER
    mysql.servers
    Spider
    Connect
    FederatedX
    FEDERATED
    DROP SERVER
    binary log
    binary log format
    ALTER SERVER
    DROP SERVER
    ALTER SERVER
    DROP SERVER
    Identifier Names
    SHOW CREATE SERVER
    SHOW CREATE SERVER
    Identifier Names
    ALTER SERVER
    DROP SERVER
    Spider Storage Engine
    fill_help_tables.sql
    Galera
    Galera
    DROP SERVER IF EXISTS name;
    CREATE SERVER server_name ...;
    CREATE SERVER s
    FOREIGN DATA WRAPPER mariadb
    OPTIONS (USER 'Remote', HOST '192.168.1.106', DATABASE 'test');
    CREATE SERVER s 
    FOREIGN DATA WRAPPER mariadb 
    OPTIONS (USER 'Remote', HOST '192.168.1.106', DATABASE 'test');
    ERROR 1476 (HY000): The foreign server, s, you are trying to create already exists
    
    CREATE OR REPLACE SERVER s 
    FOREIGN DATA WRAPPER mariadb 
    OPTIONS (USER 'Remote', HOST '192.168.1.106', DATABASE 'test');
    Query OK, 0 rows affected (0.00 sec)
    
    CREATE SERVER IF NOT EXISTS s 
    FOREIGN DATA WRAPPER mariadb 
    OPTIONS (USER 'Remote', HOST '192.168.1.106', DATABASE 'test');
    Query OK, 0 rows affected, 1 warning (0.00 sec)
    
    SHOW WARNINGS;
    +-------+------+----------------------------------------------------------------+
    | Level | Code | Message                                                        |
    +-------+------+----------------------------------------------------------------+
    | Note  | 1476 | The foreign server, s, you are trying to create already exists |
    +-------+------+----------------------------------------------------------------+
    MariaDB 10.3