mysql server start failed

360,189

Solution 1

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)

Solution 2

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

Solution 3

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.

Solution 4

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.

Solution 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: /system.slice/mysql.service
           └─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.

Share:
360,189

Related videos on Youtube

ananth
Author by

ananth

Updated on September 18, 2022

Comments

  • ananth
    ananth over 1 year

    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
    
  • ananth
    ananth about 10 years
    I ran the commands you mentioned..On running sudo service mysql restart, it gave a message stop: Unknown instance and shell prompt didn't appear(restart is still running from past 50 mins)
  • ananth
    ananth about 10 years
    No..I did sudo service mysql restart.
  • jobin
    jobin about 10 years
    Can you try doing sudo service mysql start?
  • jobin
    jobin about 10 years
    Yes, you can kill the process, it should be harmless.
  • jobin
    jobin about 10 years
    @user1985948: Was the issue resolved?
  • ananth
    ananth about 10 years
    I did sudo service mysql stop. Then I did sudo service mysql start. -The process is still running(bash prompt did not appear) from 15 minutes..I did not get any message as in the previous case.
  • jobin
    jobin about 10 years
    Do the log files have anything?
  • ananth
    ananth about 10 years
    The tail of /var/log/mysql/error.log is -140425 15:52:18 InnoDB: Waiting for the background threads to start 140425 15:52:19 InnoDB: 5.5.37 started; log sequence number 940942258188 140425 15:52:19 [ERROR] /usr/sbin/mysqld: unknown variable 'record_buffer=64M' 140425 15:52:19 [ERROR] Aborting 140425 15:52:19 InnoDB: Starting shutdown... 140425 15:52:20 InnoDB: Shutdown completed; log sequence number 940942258188 140425 15:52:20 [Note] /usr/sbin/mysqld: Shutdown complete
  • jobin
    jobin about 10 years
    @BryceAtNetwork23: It is actually he himself who solved it and later I updated my question for people who come at this post later.
  • Amit Yadav
    Amit Yadav over 6 years
    after applying these steps my database is got deleted. Now what will I do??
  • JohnFF
    JohnFF about 4 years
    I just removed the log files without the memory change and it worked :S :S :S