MySQL - CREATE SERVER Statement



MySQL CREATE SERVER Statement

If you need to use either of the Spider, FEDERATED or FederatedX storage engines. You need to create a server.

You can create a server using the CREATE SERVER statement. This statement creates a new row in the servers table in the mysql database.

Syntax

Following is the syntax of the CREATE SERVER statement −

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

Example

Following query creates a server named myserver −

CREATE SERVER myserver FOREIGN DATA WRAPPER mysql OPTIONS 
(USER 'Remote', HOST 'localhost', DATABASE 'federated');

Verification

If you list out the servers in mysql using the SELECT statement you can observe the above created server in it −

SELECT * FROM mysql.servers;

The above mysql query will generate the following output −

************** 1. row **************
Server_name: myserver
       Host: localhost
         Db: federated
   Username: Remote
   Password:
       Port: 0
     Socket:
    Wrapper: mysql
      Owner:
Advertisements