MySQL can't start after transfering from old to new server - mysql

I recently transferred mysql data from an old ssh server to a new ssh server using rsync, the transfer was from files in old server /var/lib/mysql/ to /var/lib/mysql/ in new server , the move was good. After that I tried to restart the mysql server using sudo service mysql restart.
I got this error :
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
I did a systemctl status mysql.service after and got this :
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2020-06-23 20:44:07 UTC; 1min 7s ago
Process: 16490 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=1/FAILURE)
Process: 16466 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 11702 (code=exited, status=0/SUCCESS)
So, I did some research and set ownership of the mysql using chown mysql:mysql -R /var/lib/mysql/ but it didn't make any difference.
I need some assistance to solve this issue. Is there perhaps something that I missed to do?
Thanks!

Related

Can't start MySQL without skip-grant-tables: Job for mysql.service failed because the control process exited with error code

When I have
[mysqld]
skip-grant-tables
in /etc/mysql/mysql.conf.d/mysqld.cnf file
service mysql start
works fine.
However when I comment it out:
[mysqld]
#skip-grant-tables
I get a
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
error. Why? How do I fix it?
systemctl status mysql.service
Gives this
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start) since Mon 2022-09-26 12:40:00; 569ms ago
Process: 791228 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 791236 (mysqld)
Status: "Server startup in progress"
Tasks: 21 (limit: 38267)
Memory: 343.6M
CGroup: /system.slice/mysql.service
└─791236 /usr/sbin/mysqld
Sep 26 22:40:00 copper systemd[1]: Starting MySQL Community Server...

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 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>

mysql service can't restart

I tried to start mysql using sudo /etc/init.d/mysql start,
as well as restart using sudo restart mysql and sudo /etc/init.d/mysql restart but nothing happens. When I try these types of commands, apache and php are fine, but I always have a problem with mysql, i don't understand. It works good for some time and then just turns off.
If I reinstall all of its packages, it works, but I don't want to constantly deal with it.
Using systemctl status mysql.service I get:
mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor
preset: enabled)
Active: failed (Result: exit-code) since Thu 2018-07-12 16:06:18 CEST;
7min ago
Process: 9231 ExecStart=/usr/sbin/mysqld --daemonize --pid-
file=/run/mysqld/mysqld.pid (code=exited, status=1/FAILURE)
Process: 9222 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre
(code=exited, status=0/SUCCESS)
Can somebody help me? I'm new with this. I have Ubuntu 18.04.
## Edit /etc/my.cnf, and add the following line under the
[mysqld] heading.
[mysqld]
innodb_buffer_pool_size=64M
Then restart: $ service mysql restart
https://www.digitalocean.com/community/questions/mysql-on-ubuntu-keeps-crashing

MySQL 5.7 Upgrade error on Ubuntu 16.04

I was just uninstalling nginx and then in that apt-get remove command, I see that mysql-server is updating. Then the update hung up. I killed the "apt-get" process (followed some answer somewhere). Then things kept on happening and the mysql was completely screwed up. I followed #jargonjunkie 's answer here: https://askubuntu.com/questions/763534/cannot-reinstall-mysql-server-after-its-purge also but to no avail.
(I have even removed /var/lib/mysql and /etc/mysql).
Here's what happens when I try to start mysql:
root#lamp-512mb-nyc1-01:~/etc/mysql# sudo /etc/init.d/mysql start
[....] Starting mysql (via systemctl): mysql.serviceJob for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
failed!
Here's what "systemctl status mysql.service" shows:
root#lamp-512mb-nyc1-01:~/etc/mysql# systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start-post) (Result: exit-code) since Tue 2017-10-24 13:40:38 UTC; 13s ago
Process: 21324 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 21315 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 21324 (code=exited, status=1/FAILURE); : 21325 (mysql-systemd-s)
Tasks: 2
Memory: 18.2M
CPU: 423ms
CGroup: /system.slice/mysql.service
└─control
├─21325 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─21357 sleep 1
Oct 24 13:40:38 lamp-512mb-nyc1-01 systemd[1]: Starting MySQL Community Server...
Oct 24 13:40:38 lamp-512mb-nyc1-01 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
I have seen several questions related to mysql-server 5.7 upgrade on ubuntu, but couldn't find anything that worked.
Please help. Thanks in advance.
Save your data (/var/lib/mysql) and totally remove MySQL:
apt purge mysql* mariadb*
Remove files files from /var/lib/mysql, /etc/mysql, /lib/systemd/system/mysql.service, /usr/share/mysql
Install MySQL again
Check if it starts
Bring data back (if needed)
Check logs journalctl -xe