MySQL server is not starting - mysql

When I do:
mysql -u root -p and type my password this is what I get:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
So I type this:
systemctl restart mysql
and I got following error:
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
So I did journalctl -xe and got this output:
дек 14 22:57:29 kazak systemd[1]: mysql.service: Failed with result 'exit-code'.
дек 14 22:57:29 kazak systemd[1]: Failed to start MySQL Community Server.
Subject: Unit mysql.service has failed
Defined-By: systemd
Unit mysql.service has failed.
The result is RESULT.
дек 14 22:57:30 kazak systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
дек 14 22:57:30 kazak systemd[1]: mysql.service: Scheduled restart job, restart counter is at 14.
Subject: Automatic restarting of a unit has been scheduled
Defined-By: systemd
So I did this: systemctl status mysql.service And the output is this:
mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start) since Fri 2018-12-14 22:59:11 +06; 5s ago
Process: 14585 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 4037 (code=exited, status=0/SUCCESS); Control PID: 14594 (mysqld)
Tasks: 14 (limit: 4915)
CGroup: /system.slice/mysql.service
├─14594 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid
└─14596 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid`
Does anyone knows how to fix, please?

Related

Getting Error: mysql.service failed because the control process exited with error code. after installing docker

I've installed MySQL-server on my ubuntu 21 system, when i try to start MySQL-Server im getting Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xeu mysql.service" for details.
it was working fine before I installed docker and run a MySQL on it
systemctl status mysql.service
mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset:>
Active: failed (Result: exit-code) since Sat 2022-01-22 18:32:17 IST; 7min>
Process: 19128 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=>
Process: 19136 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Main PID: 19136 (code=exited, status=1/FAILURE)
Status: "Server startup in progress"
Error: 13 (Permission denied)
CPU: 313ms
Jan 22 18:32:17 Lenovo systemd[1]: mysql.service: Scheduled restart job, restar>
Jan 22 18:32:17 Lenovo systemd[1]: Stopped MySQL Community Server.
Jan 22 18:32:17 Lenovo systemd[1]: mysql.service: Start request repeated too qu>
Jan 22 18:32:17 Lenovo systemd[1]: mysql.service: Failed with result 'exit-code>
Jan 22 18:32:17 Lenovo systemd[1]: Failed to start MySQL Community Server.
journalctl -xeu mysql.service
░░ Subject: A stop job for unit mysql.service has finished
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A stop job for unit mysql.service has finished.
░░
░░ The job identifier is 6908 and the job result is done.
Jan 22 18:32:17 Lenovo systemd[1]: mysql.service: Start request repeated too qu>
Jan 22 18:32:17 Lenovo systemd[1]: mysql.service: Failed with result 'exit-code>
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ The unit mysql.service has entered the 'failed' state with result 'exit-code>
Jan 22 18:32:17 Lenovo systemd[1]: Failed to start MySQL Community Server.
░░ Subject: A start job for unit mysql.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A start job for unit mysql.service has finished with a failure.
░░
░░ The job identifier is 6908 and the job result is failed.
Try these commands
sudo mysqld_safe --defaults-file=/etc/my.cf
sudo chown -R mysql:mysql /var/lib/mysql
sometimes for some systems, when you give the below two commands it will show Not a directory if it shows cut the below two commands off and follow the next command.
/etc/init.d/mysqld start
/etc/init.d/mysqld stop
Finally, try this command
sudo systemctl restart systemd-logind
After the systemctl restart the system will hang and log out sometimes. If it logged out, log in again and
Run sudo systemctl start mysql.service it will work fine.
For further commands check the link here and check following commands on that website if above doesn't work for you
I try same and got this:
systemctl status mysql.service
× mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2022-10-17 22:38:59 CEST; 1min 40s ago
Process: 17421 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
CPU: 8ms
Okt 17 22:38:59 install-web systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Okt 17 22:38:59 install-web systemd[1]: Stopped MySQL Community Server.
Okt 17 22:38:59 install-web systemd[1]: mysql.service: Start request repeated too quickly.
Okt 17 22:38:59 install-web systemd[1]: mysql.service: Failed with result 'exit-code'.
Okt 17 22:38:59 install-web systemd[1]: Failed to start MySQL Community Server.
I have reinstalled but that didn't help.
i tried below commands and issue resolved
sudo apt autoremove --purge mysql-server\* mariadb-server\*
sudo rm -rf /var/lib/mysql
sudo rm -rf /etc/mysql/
sudo mkdir -p /etc/mysql/conf.d
sudo apt install mysql-server

MySQL socket disappeared

I was running a Python script that lasted a few hours and executed insert statements. All locally on Debian. When I came back later to check on the script's status, I was no longer able to log into MySQL.
I had had a command line session going, and this was the message:
A similar message appears when I try to log in or run diagnostic functions like mysqldump. It appears that the socket just got up and walked away. The script and database had been running swimmingly several times before this. The only thing that changed was that I tweaked the script to do a heavier load (processing CSV files), so all can figure is that I ran out of memory and something crashed while I was away.
Trying to restart:
root#debian:/home/user# /etc/init.d/mysql stop
[ ok ] Stopping mysql (via systemctl): mysql.service.
root#debian:/home/user# /etc/init.d/mysql start
[....] Starting mysql (via systemctl): mysql.serviceJob for mysql.service failed. See 'systemctl status mysql.service' and 'journalctl -xn' for details.
failed!
systemctl status mysql.service:
root#debian:/home/user# systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled)
Active: activating (start-post) (Result: exit-code) since Fri 2019-02-15 19:26:44 JST; 12s ago
Process: 3324 ExecStart=/usr/sbin/mysqld (code=exited, status=2)
Process: 3317 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 3324 (code=exited, status=2); : 3326 (mysql-systemd-s)
CGroup: /system.slice/mysql.service
└─control
├─3326 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─3373 sleep 1
Feb 15 19:26:44 debian systemd[1]: mysql.service holdoff time over, scheduling restart.
Feb 15 19:26:44 debian systemd[1]: Stopping MySQL Community Server...
Feb 15 19:26:44 debian systemd[1]: Starting MySQL Community Server...
Feb 15 19:26:46 debian systemd[1]: mysql.service: main process exited, code=exited, status=2/INVALIDARGUMENT
journalctl -xn:
Feb 15 19:26:44 debian systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has failed.
--
-- The result is failed.
Feb 15 19:26:44 debian systemd[1]: Unit mysql.service entered failed state.
Feb 15 19:26:44 debian systemd[1]: mysql.service holdoff time over, scheduling restart.
Feb 15 19:26:44 debian systemd[1]: Stopping MySQL Community Server...
-- Subject: Unit mysql.service has begun shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has begun shutting down.
Feb 15 19:26:44 debian systemd[1]: Starting MySQL Community Server...
-- Subject: Unit mysql.service has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has begun starting up.
Feb 15 19:26:46 debian systemd[1]: mysql.service: main process exited, code=exited, status=2/INVALIDARGUMENT

not able to set bind-address=[ip of my server] in mysql

I want to create a master-slave replication on ubuntu servers.
both(master and slave) on different servers.
i made my.cnf(without coments) file on master as:
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
[mysqld]
bind-address=my_server_ip
server-id=1
log_bin=/var/log/mysql/mysql-bin.log
binlog_do_db=indicators
then i restart using sudo service mysql restart and get the following error:
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details
but when i set bind-address=127.0.0.1 it works fine.
below is the reference is used which says bind-address should be the address of master server
https://www.digitalocean.com/community/tutorials/how-to-set-up-master-slave-replication-in-mysql
but it contadicts with below link which says(under comments section) bind-address is the ip of slave
https://dev.mysql.com/doc/refman/5.7/en/replication-howto-masterbaseconfig.html
systemctl status mysql.service as in above error code
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset:
enabled)
Active: activating (start-post) (Result: exit-code) since Sat 2017-11-04
07:12:12 UTC; 11s ago
Process: 25213 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 25205 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre
(code=exited, status=0/SUCCESS)
Main PID: 25213 (code=exited, status=1/FAILURE); : 25214 (mysql-
systemd-s)
Tasks: 2
Memory: 400.0K
CPU: 250ms
CGroup: /system.slice/mysql.service
└─control
├─25214 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─25267 sleep 1
Nov 04 07:12:12 fundexpert-test-r systemd[1]: mysql.service: Service hold-
off time over, scheduling restart.
Nov 04 07:12:12 fundexpert-test-r systemd[1]: Stopped MySQL Community
Server.
Nov 04 07:12:12 fundexpert-test-r systemd[1]: Starting MySQL Community
Server...
Nov 04 07:12:14 fundexpert-test-r systemd[1]: mysql.service: Main process
exited, code=exited, status=1/FAILURE
journalctl -xe says:
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has failed.
--
-- The result is failed.
Nov 04 07:12:42 fundexpert-test-r systemd[1]: mysql.service: Unit entered
failed state.
Nov 04 07:12:42 fundexpert-test-r systemd[1]: mysql.service: Failed with
result 'exit-code'.
Nov 04 07:12:43 fundexpert-test-r systemd[1]: mysql.service: Service hold-
off time over, scheduling restart.
Nov 04 07:12:43 fundexpert-test-r systemd[1]: Stopped MySQL Community
Server.
-- Subject: Unit mysql.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has finished shutting down.
Nov 04 07:12:43 fundexpert-test-r systemd[1]: Starting MySQL Community
Server...
-- Subject: Unit mysql.service has begun start-up
-- Defined-By: systemd
below is the reference is used which says bind-address should be the address of master server
No it doesn't. It says 'replace the standard IP address with the IP address of server'. The word 'master' does not appear.
but it contadicts with below link which says(under comments section) bind-address is the ip of slave
No it doesn't. It says 'you will have to make sure that the slave's address or hostname is matched by the bind-address setting'.
You cannot bind to a non-local IP address.

Can't start mysql server

After rebooting server, I can't start mysql again
I received this message:
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
I tried journalctl -xe and received this
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has failed.
--
-- The result is failed.
Nov 06 21:25:57 myserver systemd[1]: mysql.service: Unit entered failed state.
Nov 06 21:25:57 myserver systemd[1]: mysql.service: Failed with result 'exit-code'.
Nov 06 21:25:57 myserver systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Nov 06 21:25:57 myserver systemd[1]: Stopped MySQL Community Server.
-- Subject: Unit mysql.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has finished shutting down.
Nov 06 21:25:57 myserver systemd[1]: Starting MySQL Community Server...
-- Subject: Unit mysql.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has begun starting up.
Nov 06 21:25:58 myserver systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
here is the result for 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 Sun 2016-11-06 21:29:00 UTC; 21s ago
Process: 4563 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 4560 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 4563 (code=exited, status=1/FAILURE); : 4566 (mysql-systemd-s)
Tasks: 2
Memory: 320.0K
CPU: 400ms
CGroup: /system.slice/mysql.service
└─control
├─4566 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─4625 sleep 1
Nov 06 21:29:00 myserver systemd[1]: Starting MySQL Community Server...
Nov 06 21:29:01 myserver systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Please help ! Thank you!
I found out the solution after checking mysql error.log
The disk was full.

Error when trying to use tmpfs for MySQL in Vagrant

I have a Vagrant machine to run Symfony and it does a lot of interaction with a MySQL database. To try to speed it up a little bit I though about using a tmpfs file system for the data dir.
The data dir is located at /var/lib/mysql, so here's what I tried:
1) stop the mysql service: sudo service mysql stop
2) mount the tmpfs: sudo mount -t tmpfs -o size=512M tmpfs /var/lib/mysql
3) start mysql: sudo service mysql start
And then I get the following error:
Job for mysql.service failed. See "systemctl status mysql.service" and "journalctl -xe" for details.
systemctl status mysql.service output is:
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: start-limit) since Tue 2016-04-05 20:30:52 UTC; 1min 58s ago
Process: 3376 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
Process: 3375 ExecStart=/usr/bin/mysqld_safe (code=exited, status=0/SUCCESS)
Process: 3839 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
Main PID: 3375 (code=exited, status=0/SUCCESS)
Apr 05 20:30:52 libe systemd[1]: mysql.service holdoff time over, scheduling restart.
Apr 05 20:30:52 libe systemd[1]: start request repeated too quickly for mysql.service
Apr 05 20:30:52 libe systemd[1]: Failed to start MySQL Community Server.
Apr 05 20:30:52 libe systemd[1]: Unit mysql.service entered failed state.
Apr 05 20:30:52 libe systemd[1]: mysql.service failed.
Which doesn't give too much information... Any ideas on how to debug this or what I'm doing wrong? Thanks!