mysql on amazon linux - MySQL Daemon failed to start

岁酱吖の 提交于 2020-03-22 07:30:06

问题


I tried that restarting EC2 instance and sudo service httpd restart.

But I still get this message:

[ec2-user@ip-* ~]$ sudo service mysqld start
MySQL Daemon failed to start.
Starting mysqld:                                           [FAILED]

Also I get this message:

[ec2-user@ip-* ~]$ mysqld
160127  7:01:48 [Note] mysqld (mysqld 5.5.46) starting as process 2745 ...
160127  7:01:48 [Warning] Can't create test file /var/lib/mysql/ip-*.lower-test
160127  7:01:48 [Warning] Can't create test file /var/lib/mysql/ip-*.lower-test
160127  7:01:48 [Note] Plugin 'FEDERATED' is disabled.
mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
160127  7:01:48 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
160127  7:01:48 InnoDB: The InnoDB memory heap is disabled
160127  7:01:48 InnoDB: Mutexes and rw_locks use GCC atomic builtins
160127  7:01:48 InnoDB: Compressed tables use zlib 1.2.8
160127  7:01:48 InnoDB: Using Linux native AIO
160127  7:01:48 InnoDB: Initializing buffer pool, size = 128.0M
160127  7:01:48 InnoDB: Completed initialization of buffer pool
160127  7:01:48  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.

I don't know what should I do..

Cheers!

EDIT

(+ I'm also using amazon RDS.)

Now, I tried sudo chown -R mysql:mysql /var/lib/mysql too.

But

[ec2-user@ip-* ~]$ mysql_upgrade
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
FATAL ERROR: Upgrade failed

[ec2-user@ip-* ~]$ ls -lh /var/lib/mysql/
합계 29M
-rw-rw---- 1 mysql mysql 5.0M  1월 27 06:52 ib_logfile0
-rw-rw---- 1 mysql mysql 5.0M  1월 27 06:12 ib_logfile1
-rw-rw---- 1 mysql mysql  18M  1월 27 06:52 ibdata1
drwx------ 2 mysql mysql 4.0K  1월 20 07:03 mysql
drwx------ 2 mysql mysql 4.0K  1월 20 07:03 performance_schema
drwx------ 2 mysql mysql 4.0K  1월 20 07:03 test

回答1:


As per today the nano instances with 0.5GiB memory do not allow running mysqld - they do not have enough memory. Running a micro instance with 1GiB memory fixes the problem completely. I think guys at AWS should have made a note about this in the LAMP installation instructions, as this research costed me several hours or even a day before I figured it out.




回答2:


I answer myself to my question to help other people in the same problem.

I resolved this problem from these steps:

  1. Restart your EC2 instance.
  2. Type sudo service httpd restart. (I don't know why I should do these two steps.)
  3. Type sudo chown -R mysql:mysql /var/lib/mysql. - Before typing this command, check your user= option in your /etc/my.cnf. If there is no user= option, your user is "mysql". (Visit https://stackoverflow.com/a/21435052/1570534)
  4. Change the innodb_buffer_pool_size option inside /etc/my.cnf from 128 (can be different) to 500M. If you don't have innodb_buffer_pool_size option in your /etc/my.cnf, add innodb_buffer_pool_size=500M in [mysqld] section.

I hope it helps you!




回答3:


If the issue is in Amazon Linux OS, please check whether you have free swap. I faced the same issue, when I add more swap, mysql service start working. You can see more from here http://www.linuxblackmagic.com/2018/04/mysql-daemon-failed-to-start-in-amazon.html

This will surely work for you. Shivin Vijai




回答4:


I had this problem, similar to @Michael Zelensky, when I tried to make use of an Amazon t3.nano machine. (FWIW t3.micro needed no extra adjustments on my end, but I was trying to see "how low could I go" )

I was able to find a workaround that seems to be working for now. Simply add: table_definition_cache=400 .. to the [mysqld] section in /etc/my.cnf . This apparently lowered some of the memory usage enough to allow me to then perform a service mysqld start and the service came up (along with my Wordpress websites :) )

Thanks to some AWS support specialists and also this website for helping me figure this out: http://www.tocker.ca/2014/03/10/configuring-mysql-to-use-minimal-memory.html




回答5:


I also faced the same issue when setting up an instance on Lightsail with the lowest cost instance (512MB, 1 vCPU, 20 GB SSD).

I was able to solve the issue by adding a swap file in the instance.

Here is the step to create a swap:

  1. Use the dd command to create a swap file on the root file system, where "bs" is the block size and "count" is the number of blocks. In this example the swap file is 1 GB:
$ sudo dd if=/dev/zero of=/swapfile bs=1M count=1000
  1. Update the read and write permissions for the swap file:
$ chmod 600 /swapfile
  1. Set up a Linux swap area:
$ mkswap /swapfile
  1. Make the swap file available for immediate use by adding the swap file to swap space:
$ swapon /swapfile
  1. Verify that the procedure was successful:
$ swapon -s
  1. Enable the swap file at boot time by editing the /etc/fstab file:
$ vi /etc/fstab
$ /swapfile swap swap defaults 0 0


来源:https://stackoverflow.com/questions/35030824/mysql-on-amazon-linux-mysql-daemon-failed-to-start

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!