- 37 Views
- 08/08/2024
How to Fix "InnoDB: mmap(xxxx bytes) failed; errno 12" When Starting MySQL on Linux
The error "InnoDB: mmap(xxxx bytes) failed; errno 12" in MySQL is usually related to the system not having enough memory (RAM or swap) to allocate for the MySQL process. Here are some steps you can take to resolve this issue:
1. Check and Increase Swap Memory Capacity
If the RAM is full, you can increase the swap size to provide additional virtual memory for the system:
- Check the current swap size:
free -h
- Create an additional swap file if needed:
sudo chmod 600 /swapfile # Đặt quyền truy cập an toàn
sudo mkswap /swapfile # Khởi tạo swap file
sudo swapon /swapfile # Kích hoạt swap file
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab # Làm cho thay đổi vĩnh viễn
2. Adjust MySQL Configuration
We may need to reduce some resource configurations in MySQL, particularly parameters related to InnoDB:
- Edit the configuration file my.cnf or my.ini (usually located at /etc/mysql/my.cnf or /etc/my.cnf):
innodb_buffer_pool_size = 128M # Giảm xuống nếu đang cao hơn
innodb_log_buffer_size = 8M # Giảm nếu cần
- Restart MySQL:
3. Check System Resources
- Check RAM usage and processes:
htop # Nếu đã cài đặt htop
- Identify processes that are using a lot of RAM and consider stopping or optimizing them.
4. Upgrade hardware
If the issue is still not resolved after optimizing the software and configuration, you may need to upgrade the server's RAM.
5. Check and repair MySQL tables
- Sometimes, corrupted tables can also cause MySQL startup issues:
Follow these steps sequentially, checking after each step to see if the issue has been resolved. If the problem persists, review the MySQL logs (e.g., /var/log/mysql/error.log
or similar) for additional details that may be helpful.
Thanks for visit my website