I plan to use mysql with only instance database so I can stop one database for maintenance without stopping every thing.
When one reads through the my.cnf config file, it is not clear if we must use at the same time a single database mysql plus any instances mysqld2 (for app1), mysqld3 (for app2), and so on.
Or may I get rid of the mysqld process and start only mysqld2, mysqld3, …
I have try that but could not start any instance. Of course I have configured a systemd service file.
Or may I use mysqld1 as mysql database pointing to mysql as first mandatory database and then add more instance when necessary.
here code for mysqld@.service
[Unit]
Description=MySQL Multi Server for instance %i
After=syslog.target
After=network.target
[Service]
User=mysql
Group=mysql
Type=forking
ExecStart=/usr/bin/mysqld_multi --defaults-file=/etc/mysql/cfg_%i.cnf --log=/var/log/mysql/mysql_multi.log --verbose start %i
ExecStop=/usr/bin/mysqld_multi --log=/var/log/mysql/mysql_multi.log stop %i
#Restart=always
#RestartSec=5
PrivateTmp=true
[Install]
WantedBy=multi-user.target
my config file in /etc/my.cnf
[client]
port = 3306
socket = /bdd/bd_1/sock/mysql_cli.sock
[mysqld_multi]
mysqld = /usr/bin/mysqld_safe
mysqladmin = /usr/bin/mysqladmin
log = /var/log/mysqld_multi.log
[mysqld2]
port = 63332
datadir = /bdd/bd_2/app2
pid-file = /bdd/bd_2/app2/mysqld.pid
socket = /bdd/bd_2/app2/mysql.sock
user = mysql
[mysqld3]
port = 63333
datadir = /bdd/bd_3/app3
pid-file = /bdd/bd_2/app3/mysqld.pid
socket = /bdd/bd_2/app3/mysql.sock
user = mysql
!includedir /etc/my.cnf.d
Must I run mysql_secure_installation for each instance mysqld2, mysqld3, …
Every things are configured in /etc/my.cnf
[LEFT]Accordingly, nothing particular is configured in /etc/systemd/system/mysqld@.service file.
My database files, socket files, pid files are located in /bdd/bd_1/project1, /bdd/bd_2/project2…
The owner of all files is set to mysql.
The log files are located in /var/log/mysql/project1, /var/log/mysql/project2…
The owner of all files is set to mysql.
In the config file /etc/my.cnf, rename [mysqld] to [mysqld0] so you get rid of the single database.
Don’t forget to open port for mysql on the firewall