• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Resolved Separated MySQL instances per domain?

Dennis Sweben

New Pleskian
Hi all,

I'm running an Ubuntu server with Plesk Onyx for a while now.
And due a growth of database transactions the tables of other databases are getting slower.

I think this might be solved using a separated MySQL instance per domain?
What would be the best approach to get this up and running?
Any idea's advice or other feedback, please let me know!
 
You can use the following scenario:

- add external database servers in Tools & Settings -> Database Servers
- create Service Plans with different remote database servers in Hosting Parameters tab
- create subscriptions based on different Service Plan with different remote database servers
 
Hi Igor,

thanks for your reply. However I was more looking for a solution to run multiple instances on the same server but a different port.
By your response I assume this issn't supported from Plesk itself?

Would I just manually setup different instances for the heavy domains?
I have more than enough CPU and memory.
 
However I was more looking for a solution to run multiple instances on the same server but a different port.
By your response I assume this issn't supported from Plesk itself?
When you add new database server, you can specify port of this server. Therefore I think that you could try to install several MySQL instances on your server with different ports and add them as separate database servers in Plesk.
 
Hi Igor,

thanks for the amazing fast response!
I think you are right, but it seems that Plesk is unable to setup the new MySQL service on the server.
I was wondering if it was possible due to plesk updates etc. I don't want to break anything
 
Hi Igor,

thanks for the amazing fast response!
I think you are right, but it seems that Plesk is unable to setup the new MySQL service on the server.
I was wondering if it was possible due to plesk updates etc. I don't want to break anything
Yes, you can't perform an installation of multiple MySQL instances by means of Plesk. This may be done manually, but I afraid that consequences may be unpredictable, mainly in the scope of Plesk update procedure. Therefore I'd suggest using remote database servers.
 
Thanks again Igor!
However Plesk does not update MariaDB or Postgresql, so it might be safe to do it.
I will just give it a test.
Have a great day!
 
It would be great if you share results here :)
Hi Igor,

I will no problem :)
Just a slight little question: I can't get into the current mySQL server as I don't know the 'admin' password.
It's not the initial root password from the server.
It's not the new root password from the server.

So I login using the following in shell:
mysql -uadmin -p`cat /etc/psa/.psa.shadow`

I can change the password through safe mode.
What stuff should I keep in mind when I change it?
The actual question would be: Will it break Plesk ? xD
 
Hi Dennis Sweben,

pls. try NOT to mix your threads ( and the corresponding topics ) as it might confuse/irritate other forum users. If you desire to get answers about the "admin" password, pls. use the official Plesk documentation or use the ( powerfull ) => FORUM SEARCH and if you really didn't found any answers to your question, pls. open a NEW thread with a corresponding topic. ;)
 
My apologies UFHH01! You are right, however I still could not find the solution ;-)
I haven't changed the password at all.

I just created 2 new mysql instances on my Ubuntu server, and like Igor mentioned just I added the servers under Tools & Settings -> Database Servers
Created a new database from Domains -> <domain> -> databases on this server.
mysqldump'd the required database over to the new instance

however phpmyadmin was unable to connect, I had to do an aditional GRANT on the database for the created user (created by Plesk) to be able to use it.

It's not the foolproof solution, but it's working like a charm now.
Load is "balanced" on 2 instances now, and my websites stay fast :)
Main reason is that each instance takes its own CPU core

Thanks Igor!
 
Last edited:
Hi, for anybody who is interested, here is my step by step.
In fact, Plesk should find a way to automate this task to release us from this agony ;-)
Plesk Onyx 17.8.11; Ubuntu 16.04.5 LTS; MySQL 5.7.24

Create second MySQL - Database - Instance:
--> cp -prvf /etc/mysql/ /etc/mysql2
--> mkdir -p /var/lib/mysql2
--> chown --reference /var/lib/mysql /var/lib/mysql2
--> chmod --reference /var/lib/mysql /var/lib/mysql2
--> mkdir -p /var/log/mysql2
--> chown --reference /var/log/mysql /var/log/mysql2
--> chmod --reference /var/log/mysql /var/log/mysql2
--> Create error log file:
--> vi /var/log/mysql2/error.log
--> chown mysql /var/log/mysql2/error.log


--> edit mysqld.cnf and my.cnf File:

vi /etc/mysql2/mysql.conf.d/mysqld.cnf

[client]
port = 3337
socket = /var/run/mysqld/mysqld2.sock
[mysqld_safe]
socket = /var/run/mysqld/mysqld2.sock
[mysqld]
pid-file = /var/run/mysqld/mysqld2.pid
socket = /var/run/mysqld/mysqld2.sock
port = 3337
datadir = /var/lib/mysql2
log_error = /var/log/mysql2/error.log
#skip_name_resolve
!includedir /etc/mysql2/conf.d/

vi /etc/mysql2/my.cnf

!includedir /etc/mysql2/conf.d/
!includedir /etc/mysql2/mysql.conf.d/

--> edit /etc/mysql2/debian.cnf file
In section [client]:
--> socket = /var/run/mysqld/mysqld2.sock
In section [mysql_upgrade]:
--> socket = /var/run/mysqld/mysqld2.sock

--> add content to apparmor file:
--> vi /etc/apparmor.d/usr.sbin.mysqld
### Pasted this content --### secondary aka mysql2 ##

/etc/mysql2/*.pem r,
/etc/mysql2/conf.d/ r,
/etc/mysql2/conf.d/* r,
/etc/mysql2/*.cnf r,
/var/lib/mysql2/ r,
/var/lib/mysql2/** rwk,
/var/log/mysql2/ r,
/var/log/mysql2/* rw,
/{,var/}run/mysqld/mysqld2.pid w,
/{,var/}run/mysqld/mysqld2.sock w,

#################### End of configuration for mysql2 ######################

--> restart apparmor: /etc/init.d/apparmor restart

--> mysqld --initialize --user=mysql --datadir=/var/lib/mysql2

--> sed -i 's/key_buffer/key_buffer_size/' /etc/mysql2/my.cnf

--> Start mysql server:
--> mysqld_safe --defaults-file=/etc/mysql2/my.cnf &

--> Check if Server is running on Port 3337
--> netstat -tanp|grep mysql
--> if not, check error.log: vi /var/log/mysql2/error.log

--> Setting root password:
--> find processid: ps -aef | grep mysql2
--> kill <processid>
--> Create file including Set-Password-Statement:
--> vi /var/lib/mysql2/rootpw
--> Statement: ALTER USER 'root'@'localhost' IDENTIFIED BY '<root-password>';
--> chown mysql rootpw
--> Start mysql:
--> mysqld_safe --defaults-file=/etc/mysql2/my.cnf --init-file=/var/lib/mysql2/rootpw &
--> Check Connection to database:
--> mysql --user=root --host=127.0.0.1 --port=3337 --password
--> IMPORTANT: DELETE rootpw File
--> rm /var/lib/mysql2/rootpw
--> Stop mysql:
--> mysqladmin -S /var/run/mysqld/mysqld2.sock shutdown -p

--> Configure as Service:
--> Create service file:
--> vi /etc/systemd/system/mysql2.service
[Unit]
Description=Second mysql database

[Service]
ExecStart=/bin/bash -c "nohup mysqld_safe --defaults-file=/etc/mysql2/my.cnf &"
Type=oneshot
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

--> systemctl daemon-reload
--> systemctl enable mysql2.service

--> service mysql2 start
--> service mysql2 status
--> service mysql2 stop
--> service mysql2 start

--> Configure second mysql Server in Plesk
--> Tools&Settings --> DB Server --> Add DB Server
--> Hostname: 127.0.0.1
--> Port: 3337
--> Type: MySQL
--> Credentials for root user
--> OK
--> phpMyAdmin should point correctly now. Make shure that #skip_name_resolve is commented out in my.cnf
 
Last edited:
Hi, for anybody who is interested, here is my step by step.
In fact, Plesk should find a way to automate this task to release us from this agony ;-)
Plesk Onyx 17.8.11; Ubuntu 16.04.5 LTS; MySQL 5.7.24

Hello,
It would probably be easier to use Docker to run several MySQL server instance on the same host.
 
Back
Top