MySQL - ALTER SERVER Statement



MySQL ALTER SERVER Statement

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

You can change the server information i.e. the options permitted while creating the server, using the ALTER SERVER statement.

Syntax

Following is the syntax of the ALTER SERVER statement −

 ALTER SERVER server_name OPTIONS (option [, option] ...) 

Example

Assume we have created a server named myserver using the CREATE SERVER statement as shown below −

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

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; 

Output

The above query produces the following output −

 *********** 1. row *********** Server_name: myserver Host: localhost Db: federated Username: Remote Password: Port: 0 Socket: Wrapper: mysql Owner: 1 row in set (0.00 sec) 

Following query alters the above created server −

 ALTER SERVER myserver OPTIONS (USER 'test'); 

Verification

If you verify the list of servers again you can observe the changed user name as shown below −

 SELECT * FROM mysql.servers; MySQL ALTER SERVER Statement; 

Following is the output of the above query −

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