Article ID: 128839, created on May 16, 2016, last review on May 16, 2016

  • Applies to:
  • Plesk Automation 11.5

Question

  1. I have created a new resource type MySQL custom and replaced default MySQL database resource with it in my service template.

  2. The MySQL custom resource has provisioning attribute MySQL custom attribute, the same attribute assigned to the newly added MySQL Service Node with IP address 192.168.0.3.

  3. When new webspace is created the MySQL database service is provisioned to the new server 192.168.0.3, but when trying to create new database on a webspace created with old MySQL resource MySQL database it still trying to create database on the old MySQL Service Node with IP 192.168.0.2.

How to update existing webspace so it starts using new database server?

Resolution

Apply the following command to an existing webspace:

# /usr/local/psa/bin/subscription_settings -u domain.tld -default_server_mysql 192.168.0.3:3306

Where domain.tld is the webspace name and 192.168.0.3 is the new MySQL server.

In order to update default DB server for batch of webspaces from particular service node you can run following commands:

  1. Get list of subscription with Web hosting from old Service Node mysql1.domain.tld:

    # mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa -Ne "SELECT domains.name FROM domains AS domains  INNER JOIN DomainServices AS DomainServices ON domains.id = DomainServices.dom_id  INNER JOIN IpAddressesCollections AS IpAddressesCollections ON IpAddressesCollections.ipCollectionId = DomainServices.ipCollectionId AND \"web\" = DomainServices.type  INNER JOIN IP_Addresses AS IP_Addresses ON IpAddressesCollections.ipAddressId = IP_Addresses.id  WHERE (IP_Addresses.ip_address='192.168.0.2') and (domains.webspace_id = 0);" > /root/webspaces_from_linux2.txt
    

    Here is 192.168.0.2 - IP address of service node. Results will be saved in /root/webspaces_from_linux2.txt file.

  2. Update default MySQL database server using simple script like:

    # for w in `cat /root/webspaces_from_linux2.txt`; do /usr/local/psa/bin/subscription_settings -u $w -default_server_mysql 192.168.0.3:3306; done
    

    Here is 192.168.0.3 - IP address of required (new) DB server.

NOTE: existing MySQL databases will not be transferred to new Database Server.

Search Words

change database ip address

default mysql server not pulling through

default mysql server in plesk

change service node ip address

change default database server

mysql database

Could you help me about mysql server add

mysql

change mysql server

33a70544d00d562bbc5b17762c4ed2b3 caea8340e2d186a540518d08602aa065 e0aff7830fa22f92062ee4db78133079

Email subscription for changes to this article
Save as PDF