Change start-up options for mysqld in whm on CentOS - mysql

I have a WHM/Cpanel server set up on CentOS 7.6.
I need to set up my mysqld process with a start-up option --init-file, to be ran every time the service is restarted.
I assume there is a file somewhere on the server that tells WHM what options to use when starting the service mysqld. But I can't find it.
Thanks
Matt

Figured out that CentOS uses the systemd service initializer.
Answer:
Edit the mysqld.service file in
/usr/lib/systemd/system
Then you have to reload the systemctl daemon. Run command:
systemctl daemon-reload
Then restart mysql from WHM and it will execute the option

Related

mysql server doesn't recognize changes in my.cnf

I have installed mysql server and mysql client with bundle in Centos 7. mysql server's port is displayed as 0. I want to give specific port to it. For this purpose, I have changed /etc/my.cnf with below;
port=4545
After changes, I've restarted the service. But it's start with skip-networking as ON. I have also tried to change skip-networking to OFF but didn't accomplish.
I have also tried mysql_secure_installation after changes but got below error :
Failed! Error: The MySQL server is running with the
--skip-grant-tables option so it cannot execute this statement
How can i solve this?
Thanks for answering
I have solved my question with below;
systemctl stop mysqld
systemctl daemon-reload
systemctl set-environment MYSQLD_OPTS="--skip-networking=OFF"
After this I have started service again.
systemctl start mysqld

MYSQL and MYSQLD not start MySQL 5.7 enterprise version on CentOS7

I just install MySQL 5.7 enterprise version 5.7.1 commercial Client and then Install 5.7.1 commercial server.
I didn't do any thing just restart CentOS 7 VM
when I try to start the service of mysql i got error
1st i Try to start service using
service mysql start
Redirecting to /bin/systemctl start mysql.service
Failed to issue method call: Unit mysql.service failed to load: No such file or directory.
then i try the following command
service mysqld start
Starting mysqld (via systemctl): Job for mysqld.service failed. See 'systemctl status mysqld.service' and 'journalctl -xn' for details. [FAILED].
I unInstall the MySQL and delete the folder where log and data files created and then reinstall MySQL then restart CentOS again same Issue.
Regards,
Saad

Not To Start MySql Automatically at Centos Startup

i have "CentOS 6" VPS and i wanted to start mysql service automatically at Startup of Server when it is restarted. so i used this command in putty
chkconfig --level 345 mysqld on
this command is working and mysql starts on every startup automatically.
BUT how can i now stop this? what if i want to start Mysql manually on every startup, then what command should i use?
also what is the File where i can see the list of programs that are running automatically on every setup.
Thanks
You can turn off auto-start with this command:
chkconfig --level 345 mysqld off
To see what is configured for auto-start, you can run:
chkconfig --list
See more info on chkconfig here:
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s2-services-chkconfig.html

mysql.sock does not exist error in fresh install of MySQL on Arch Linux

I'm trying to use MySQL on Arch Linux. it is already installed but this error comes up when I try to connect:
connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2 "No such file or directory")'
I've looked for /etc/my.cfg but the file does not exist.
Something must have gone wrong during the installation.
How can I "purge" MariaDB and reinstall it?
If you're using archlinux it is a vital idea to understand the package manager (pacman). For the question about /etc/my.cfg you can run
pacman -Ql mariadb
there you will see that the file is actually called:
/etc/mysql/my.cnf
Arch linux will not configure the package for you, that is part of the arch philosophy. It will provide example configurations, and even provide you with a systemd unit file
usr/lib/systemd/system/mysqld.service
but it is your responsibility to ensure that the configuration is correct and actually start the daemon.
systemctl enable mysqld # add the unit file to the boot sequence
systemctl start mysqld # runs ExecStart= in the unit file
systemctl stop mysqld # kills the daemon
systemctl disable mysqld # remove unit from boot sequence
reinstall
Since the word reinstall is in the title of the question and someone might find this question thanks to that: To reinstall mariadb you simply do
pacman -S mariadb
pacman will reinstall a package that is already installed, there is no need to remove the package (for completeness, package removal happens with pacman -R)
as of 7-28-17 I had to do this on a new install. Newbie here might save someone some time. It was a real pain.
OK HERE IS THE DEAL!!!!!
INSTALL APACHE _ NO PROB
INSTALL MYSQL _PROBLEM
pacman -S mysql then before starting service
MUST UNCOMMENT INNODB IN:
nano /etc/mysql/my.cnf
then must initialize datadirectory before starting service:
mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
You need to initialize the MariaDB data directory prior to starting
the service. This can be done with mysql_install_db command, e.g.:
mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
Optional dependencies for mariadb
galera: for MariaDB cluster with Galera WSREP
perl-dbd-mysql: for mysqlhotcopy, mysql_convert_table_format and
mysql_setpermission
CNF file is /etc/mysql/my.cnf in Arch Linux.
One simple way I can reproduce your issue is when MariaDB is shut down. Sorry if it sounds dumb but as you did not mention it: is MariaDB started? sudo systemctl start mysqld.service
You should have a look at MariaDB logs to get some clue: journalctl _SYSTEMD_UNIT=mysqld.service (maybe paste some part if you still don't get what is going on).
This happens the first time you install MySQL and MariaDB. As grochmal pointed out, you have to set up configurations before first use. But, the user teckk sent these three links in the archlinux newbie corner:
https://wiki.archlinux.org/index.php/MariaDB
https://wiki.archlinux.org/index.php/MariaDB#Reset_the_root_password
https://bbs.archlinux.org/viewtopic.php?id=51981
In short, you have to run the command below before starting the service:
sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
Optionally (recommended) you should improve the initial security by calling:
sudo mysql_secure_installation
Now you can start the service:
sudo systemctl start mariadb
Optionally, you could install and use a graphical front-end tool.
Carry on with setting up the configurations as described in the archwiki post on MariaDB Configuration.

How make mysql start automatically ? (linux-cli only)

How can i make mysql start every time the system boot ? I need that in a dedicated server(ubuntu distro) in which i have my blog, but every time the server goes down, on booting mysql is stopped.
Btw i can use only command line.
update-rc.d allows setting init script links on Ubuntu and Debian Linux systems to control what services are run by init when entering various runlevels. It should be able to add mysql to the list of services to run at boot:
sudo update-rc.d mysql defaults
If you later want to disable running mysql on bootup:
sudo update-rc.d mysql remove
You can do it by using sysv-rc-conf, on debian based you can install it with sudo apt-get install sysv-rc-conf
then you can choose what start at boot with a simple X on the name of the deamon, all via command line
Run the following command to see your mysql current status:
/sbin/chkconfig mysqld --list
it will return a line such as below:
mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off
to make mysql start every time the system boots, type the following:
sudo /sbin/chkconfig mysqld on
Result now from '--list' is:
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
No answer helped. Finally chkconfig and update-rc.d did not work with MySQL on my machine.
Solution, I had a file /etc/init/mysql.override which contained
manual
i just deleted that file
$ sudo rm /etc/init/mysql.override
Deleting
/etc/init/mysql.override
did the job in my case (HostEurope VPS with Ubuntu 12.04)
I had the same problem, so I checked how I disabled it in the first place:
https://askubuntu.com/questions/138487/how-to-keep-apache-and-mysql-from-starting-automatically
Check your /etc/init/mysql.conf to make sure you don't have start on commented out (like I did).
# MySQL Service
description "MySQL Server"
author "Mario Limonciello <superm1#ubuntu.com>"
start on runlevel [2345]
stop on starting rc RUNLEVEL=[016]
...
Rebooted the machine and it works.
$ sudo service mysql status
mysql start/running, process 972
Use the chkconfig command as per the manpage http://manpages.ubuntu.com/manpages/maverick/man8/chkconfig.8.html
Another place to look for clues as to what is and isn't starting at boot time...
/etc/init.d/.depend.start (and its buddy at shutdown time, .depend.stop)
Here's a little more info http://www.pyenet.co.nz/2-202-1-customising-system-startup-and-boot-processes/
I had 2 servers - after booting, 1 would have mysql running, the other not so much.
On the box where mysql was starting at boot time:
chkconfig wasn't even installed
there were zero links from any scripts in /etc/rc?.d/* back to /etc/init.d/mysql
BUT... /etc/init.d/.depend.start contained:
TARGETS = halt apache2 umountfs umountnfs.sh sendsigs networking umountroot reboot killprocs unattended-upgrades urandom mysql mdadm dns-clean landscape-client pppd-dns sysstat rsync sudo postfix single grub-common ondemand rc.local
INTERACTIVE = apache2
postfix: mysql
single: killprocs dns-clean pppd-dns
grub-common: apache2 unattended-upgrades postfix mysql mdadm dns-clean landscape-client pppd-dns sysstat rsync sudo
ondemand: apache2 unattended-upgrades postfix mysql mdadm dns-clean landscape-client pppd-dns sysstat rsync sudo
rc.local: apache2 unattended-upgrades postfix mysql mdadm dns-clean landscape-client pppd-dns sysstat rsync sudo
When I simply copied this file over to the problem server, and rebooted, mysql was up & running.
With Debian 9, I installed MySQL today and typed "reboot" and mysqld restarted automatically. Also rebooted from my VPS dashboard, mysqld restarted automatically. In short, if you have Debian 9, there's nothing extra to do, it just works.