can not start mysql service in centos 7 - mysql

i tried to start the mysql service but it's not work.
while i use this command
service start mysql
this error happens!
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.
but when i tried to use systemctl it's still not work
[root#master-1 ~]# systemctl start mysql
Failed to start mysql.service: Unit not found.
[root#master-1 ~]# systemctl start mysqld
Failed to start mysqld.service: Unit not found.
[root#master-1 ~]#
this is the result for systemctl status mysqld mysql
● mysqld.service
Loaded: not-found (Reason: No such file or directory)
Active: failed (Result: exit-code) since Mon 2021-07-12 10:01:13 WIB; 1 weeks 1 days ago
Main PID: 872 (code=exited, status=1/FAILURE)
Status: "Data Dictionary upgrade from MySQL 5.7 in progress"
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
● mysql.service
Loaded: not-found (Reason: No such file or directory)
Active: failed (Result: exit-code) since Fri 2021-07-16 17:13:43 WIB; 3 days ago
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
i still don't know what happen

Hello systemctl works in Ubuntu Os, Not in CentOS.
please use [/etc/init.d/mysqld restart, /etc/init.d/mysqld start, /etc/init.d/mysqld stop] instead of systemctl start mysql

Related

Broken mysqld package preventing any other installation in ubuntu

I am having this issue for quite a long period of time, it started when I wanted to change password for mysql which I forgot. I have followed a lot of documents to purge mysql from my system completely so that I can have a new password for a freshly installed mysql. But every time I install it I face the same problem and it asks me the same old password.
Currently I have purged mysql from my system but even though whenever I try to install anything, let's say openssh, I get the below logs after downloading the package.
sudo apt-get install openssh-server
.
.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up mysql-server-8.0 (8.0.23-0ubuntu0.20.04.1) ...
Renaming removed key_buffer and myisam-recover options (if present)
mysqld will log errors to /var/log/mysql/error.log
mysqld is running as pid 9069
Job for mysql.service failed because a timeout was exceeded.
See "systemctl status mysql.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mysql, action "start" failed.
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/mysql.service.d
└─override.conf
Active: activating (auto-restart) (Result: timeout) since Sat 2021-07-03 00:35:37 IST; 5ms ago
Process: 9257 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Process: 9278 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid --skip-grant-tables --skip-networking (code=exited, status=0/SUCCESS)
Main PID: 9278 (code=exited, status=0/SUCCESS)
Status: "Server shutdown complete"
Error: 2 (No such file or directory)
Jul 03 00:35:37 gp-HP-Pavilion-Notebook systemd[1]: mysql.service: Scheduled restart job, restart counter is at 1.
Jul 03 00:35:37 gp-HP-Pavilion-Notebook systemd[1]: Stopped MySQL Community Server.
Jul 03 00:35:37 gp-HP-Pavilion-Notebook systemd[1]: Starting MySQL Community Server...
Jul 03 00:35:41 gp-HP-Pavilion-Notebook systemd[1]: mysql.service: Got notification message from PID 10009, but reception only permitted for main PID 10007
dpkg: error processing package mysql-server-8.0 (--configure):
installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-8.0; however:
Package mysql-server-8.0 is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
mysql-server-8.0
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
Is there any way to prevent this from happening every time when I install anything ?
It would be great if anyone could help in resolving this issue, because it is also blocking the proper installation of various other package.
The log says: See "systemctl status mysql.service" and "journalctl -xe" for details.
systemctl status mysql.service will show the status of the mysql.service.
systemctl stop mysql.service will stop the mysql.service.
systemctl start mysql.service will start the mysql.service.
systemctl enable mysql.service will start the mysql.service at boot.
systemctl disable mysql.service will stop the starting of the mysql.service at boot. (I think you need this one)
more info: man systemctl, and systemctl --help

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

Ok so all of a sudden sql is not working properly on my server. When i run sudo service mysql start it says:
Job for mysql.service failed because a fatal signal was delivered to the control process.
See "systemctl status mysql.service" and "journalctl -xe" for details.
When i run systemctl status mysql.service it shows:
mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start) since Wed 2021-04-14 03:08:17 UTC; 4s ago
Process: 12884 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 12892 (mysqld)
Status: "Server startup in progress"
Tasks: 2 (limit: 1136)
Memory: 2.7M
CGroup: /system.slice/mysql.service
└─12892 [mysqld]
When i run journalctl -xe is shows:
Apr 14 03:04:43 otzivio-ubuntu-s-1vcpu-1gb-intel-fra1-01 sudo[11492]: pam_unix(sudo:auth):
authentication failure; logname=ashok uid=1000 euid=0 tty=/dev/pts/0 ruser=ashok rhost= user=ashok
Apr 14 03:04:47 otzivio-ubuntu-s-1vcpu-1gb-intel-fra1-01 sudo[11492]: pam_unix(sudo:auth):
conversation failed
Apr 14 03:04:47 otzivio-ubuntu-s-1vcpu-1gb-intel-fra1-01 sudo[11492]: pam_unix(sudo:auth): auth could
not identify password for [ashok]
Apr 14 03:05:20 otzivio-ubuntu-s-1vcpu-1gb-intel-fra1-01 sudo[11748]: pam_unix(sudo:auth):
authentication failure; logname=ashok uid=1000 euid=0 tty=/dev/pts/0 ruser=ashok rhost= user=ashok
Any help is appreciated
First run " sudo apt-get install -f" for resolve dependences, if it doesn't works, review your config files, permission, etc. Try to see if thare is any update that happened.
In the last case, when nothing works. Try to reinstall by "sudo apt-get autoremove mysql-server && apt-get install mysql-server" but make sure you have all backups os config files and sql...
I don't know if it will really help, but in my job we receve some updates in the server from night to the day that pull all down kkk. After some bad experiences i create the backup of the backp of the backup daily...

MYSQL don't start

Previously I performed the migration of my database from one directory to another within the server itself (/var/lib/mysql to /mnt/mysql) for lack of space.
When starting the server again, after having changed the /etc/my.cnf with the correct directory it returns me this error:
$ systemctl start mysqld
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
And when I run the systemctl status command on the mysqld service it returns me:
$ systemctl status mysqld.service
mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Ter 2019-07-16 09:34:44 -03; 44s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 31923 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS (code=exited, status=1/FAILURE)
Process: 31899 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 31923 (code=exited, status=1/FAILURE)
Status: "SERVER_BOOTING"
Error: 13 (Permission Denied)
Jul 16 09:34:43 srvepl.cettro.local systemd[1]: Starting MySQL Server...
Jul 16 09:34:44 srvepl.cettro.local systemd[1]: mysqld.service: main process exited, code=exited, status=1/FAILURE
Jul 16 09:34:44 srvepl.cettro.local systemd[1]: Failed to start MySQL Server.
Jul 16 09:34:44 srvepl.cettro.local systemd[1]: Unit mysqld.service entered failed state.
Jul 16 09:34:44 srvepl.cettro.local systemd[1]: mysqld.service failed.
If it is permission error, how do I free the server to accept such a directory?
Note: I am using CentOS 7
Thank you!!
If you are using Linux or Unix Server then you should check the permissions of the user to access the service. Here I can see that the user which is logged in can't access the service because of the permission problem.
Try with.
sudo systemctl start mysqld;
Or try sudo su;, enter the creds of the superuser and then try to check the service status.
Or login as superuser and then try to start the service.
Hope this may help you.
After searching i discovered that the error was the 'enforcing' permission of SELINUX.
The answer to fix this problem is:
$ sudo setenforce 0
And the server went up normally.
Are you logged in with root user?
If no, try with sudo.
Otherwise, I think is better to restart your system and try again.
If you aren't expert in linux centos don't manipulate anything.
uninstall mysql and reinstall it.

MySQL can't connect Ubuntu

Can't connect to MySQL service. Below is the status output error I get when trying to start
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
ruan#master.danzlive.com:~$ systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start-post) since Tue 2018-10-30 11:59:35 SAST; 1s ago
Process: 1988 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 1998 (mysqld); Control PID: 1999 (mysql-systemd-s)
Tasks: 16 (limit: 19660)
Memory: 130.2M
CPU: 577ms
CGroup: /system.slice/mysql.service
├─1998 /usr/sbin/mysqld
└─control
├─1999 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─2031 sleep 1
Oct 30 11:59:35 ip-197-101-38-62 systemd[1]: Starting MySQL Community Server...
ruan#master.danzlive.com:~$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I faced similar Issue in Ubuntu 18.04. I found the reason that - On last day I cleared Ubuntu using Stacer Application. This application removed mysql log folder at location
/var/log/
So next day while starting MySQL, got this error.
I created that folder again and given permissions.
mkdir /var/log/mysql
sudo chown mysql:mysql -R /var/log/mysql
Try to add the database-username using the -u parameter directly via commandline.
mysql -u root <database>

Archlinux mysqld won't launch

Cat' launch mysqld on my archlinux x64.
Job for mysqld.service failed. See "systemctl status mysqld.service" and "journalctl -xe" for details.
after systemctl start mysqld
in log
mysqld.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: activating (auto-restart) (Result: timeout) since Mon 2015-04-06 22:07:24 UTC; 9ms ago
Process: 18077 ExecStart=/usr/bin/mysqld --pid-file=/run/mysqld/mysqld.pid (code=exited, status=1/FAILURE)
Main PID: 18077 (code=exited, status=1/FAILURE)
CGroup: /system.slice/mysqld.service
`-control
Apr 06 22:07:24 atlas systemd[1]: Failed to start MariaDB database server.
Apr 06 22:07:24 atlas systemd[1]: Unit mysqld.service entered failed state.
Apr 06 22:07:24 atlas systemd[1]: mysqld.service failed.
What can i do? Thanks!
You will get detailed info in systemd journal: sudo journalctl -f then, on an other terminal, start mysql: sudo systemctl start mysqld to get logs on the first terminal. You will likely get error messages that will help you figure out what goes wrong.
You should type this command before starting the service
mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
ِAnd later you can start the service Regularly
For one session:
systemctl start mysqld
OR being enabled automatically on startup << (NOT RECOMMENDED)
systemctl enable mysqld
Did you follow the install instruction on the ArchLinux Wiki ?
https://wiki.archlinux.org/index.php/MySQL#Installation
As mentionned by Medo Tareq, you need to run the following command :
mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
(Obviously you can adjust the parameters on the command, if you know what you are doing.)
The Wiki page also has other hint and information, notably about the mysql_secure_installation command that "will interactively guide you through a number of recomended security measures at the database level".
Try change the permission of MySQL folder. If you are working locally and try to reinstall MySQL again after runing this command, it will work.
sudo chmod -R 755 /var/lib/mysql/