mysql server start failed

I am running ubuntu server. When I tried to login to mysql(which was running),I got the following error

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

But mysqld.sock file doesn't exist inside /var/run/mysqld folder. On executing ps aux | grep mysql command,I realized that mysql server was not running.

I then tried to restart mysql server using

service mysql start
service mysql restart
/etc/init.d/mysql start

But,the start process failed in all 3 cases./var/log/mysql/mysql.log and /var/log/mysql/mysql.err files are empty.

But /var/log/error.log shows following information:

140425 12:49:05 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
140425 12:49:05 [Note] Plugin 'FEDERATED' is disabled.
140425 12:49:05 InnoDB: The InnoDB memory heap is disabled
140425 12:49:05 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140425 12:49:05 InnoDB: Compressed tables use zlib 1.2.8
140425 12:49:05 InnoDB: Using Linux native AIO
140425 12:49:05 InnoDB: Initializing buffer pool, size = 3.0G
140425 12:49:05 InnoDB: Completed initialization of buffer pool
InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 26214400 bytes!
140425 12:49:05 [ERROR] Plugin 'InnoDB' init function returned error.
140425 12:49:05 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
140425 12:49:05 [ERROR] /usr/sbin/mysqld: unknown variable 'record_buffer=64M'
140425 12:49:05 [ERROR] Aborting
140425 12:49:05 [Note] /usr/sbin/mysqld: Shutdown complete
6

11 Answers

Open a terminal(Ctrl+Alt+t) and do the following:

sudo service mysql stop
sudo rm /var/lib/mysql/ib_logfile0
sudo rm /var/lib/mysql/ib_logfile1

and comment out the line record_buffer=64M in /etc/mysql/my.cnf [1]

and then restart msyql using:

sudo service mysql restart

(Source)

13

This solved my problem:

mkdir /var/run/mysqld

touch /var/run/mysqld/mysqld.sock

chown -R mysql /var/run/mysqld

/etc/init.d/mysql restart

1

I solved the problem in the following way:

chown -R mysql:mysql /var/lib/mysql
mysql_install_db --user=mysql -ldata=/var/lib/mysql/

In another context, I faced it because the mysql daemon failed to start. So start daemon with command - mysqld start and then try to start the service.

I had the same error message and the same emptyness in the log files. In my config-file (my.cnf) I had specified that I wanted to use myisam tables, by adding this line in the [mysqld]-section:

default-table-type = myisam

After upgrading mysql it seems this causes mysql not to start. I have changed this to:

default-storage-engine = myisam

and now everything works fine.

Increasing the available RAM by adding new Swap space might also help. Steps are here

Make sure that you create /swapfile of the size smaller than the available space shown by

df -h

For example for me output of df- h was:

Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 7.8G 1.2G 6.3G 16% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 492M 12K 492M 1% /dev
tmpfs 100M 336K 99M 1% /run

So I created using 2 G

sudo fallocate -l 2G /swapfile

And then just start the service

sudo /etc/init.d/mysql restart

Hope this helps. All the best.

My solution:

Check if in all /etc/rc1.d ... /etc/rc5.d the mysql script starts with S (Ex S10mysql) and not K AS K10mysql.

Explanation: K prefix loads with stop, kind of kill service; and S prefix starts with start parameter.

execute in terminal:
(command script action runlevel)
---------------------------------------
sudo update-rc.d mysql enable 2
sudo update-rc.d mysql enable 3
sudo update-rc.d mysql enable 4
sudo update-rc.d mysql enable 5

In my case, it was a space issue. Check if you have enough space left.

from /var/log/mysql/error.log I got some hints from two lines:

2018-08-04T05:25:29.519139Z 0 [ERROR] InnoDB: Write to file ./ibtmp1failed at offset 3145728, 1048576 bytes should have been written, only 704512 were writt$
2018-08-04T05:25:29.519145Z 0 [ERROR] InnoDB: Error number 28 means 'No space left on device'

I could see that it is a space issue.

root@xxx:/home/user1# df -h
Filesystem Size Used Avail Use% Mounted on
udev 477M 0 477M 0% /dev
tmpfs 100M 11M 89M 11% /run
/dev/mapper/server1--osticket--vg-root 8.3G 7.9G 0 100% /
tmpfs 497M 0 497M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 497M 0 497M 0% /sys/fs/cgroup
/dev/vda1 472M 467M 0 100% /boot
tmpfs 100M 0 100M 0% /run/user/1000

From here, I could see that there was not enough space left on the virtual server /dev/mapper/server1--osticket--vg-root 8.3G 7.9G 0 100% /. And I thought on either migrating or increasing the virtual drive, but I decided to remove unnecessary files first.

So, had to clean up cache and files that were not needed:

#apt-get clean
#apt-get -f autoremove

Then, do not forget to remove the mysql corrupted log files afterwards. They would be generated again when you restart mysql

#service mysql stop
#cd /var/lib/mysql
#rm ib_logfile*
#service mysql start

Check your mysql server service and it is probably up and running

root@server1-osticket:/var/lib/mysql# service mysql status
● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2018-08-04 23:07:24 WAT; 7min ago Process: 1559 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS) Process: 1549 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS) Main PID: 1558 (mysqld) Tasks: 29 Memory: 280.3M CPU: 589ms CGroup: / └─1558 /usr/sbin/mysqld
Aug 04 23:07:19 server1-osticket systemd[1]: Starting MySQL Community Server...
Aug 04 23:07:24 server1-osticket systemd[1]: Started MySQL Community Server.
root@server1-osticket:/var/lib/mysql#

Case closed. I hope it helps.

Remove the file /var/lib/mysql/.run-mysql_upgrade and it should start

;)

"With great power comes great responsibility"

I had this problem when I set max_allowed_packet = 0.5M in /etc/mysql/my.cnf.

I solved it by changing max_allowed_packet to 1M.

The following command resolve my issue and mysql could start after it.(it might to useful in some cases)

chown -R mysql: /var/lib/mysql

I had this same error, and last 2 times I had to delete and reinstall mysql server as I didn't have much data there.

But, the error used to happen consistently for me, when I used stacer to clean my cache files.

It actually deletes the var/log/mysql/error.log path. Along with the mysql directory.

To fix that, I created the directory manually,

sudo mkdir /var/log/mysql
sudo touch /var/log/mysql/error.log
sudo chown -R mysql: /var/log/mysql

And then restart using:

sudo systemctl start mysql
  • The error previously it was showing on sudo systemctl status mysql

Error: 2 (No such file or directory)

  • After I have created the directory but notsudo chown -R mysql: /var/log/mysql

Error: 13 (Permission denied)

You Might Also Like