MariaDB Service Troubleshooting Guide
MariaDB is an open-source relational database management system widely used in various applications. Although MariaDB usually runs stably, you might encounter service failures or performance issues in certain situations. This article provides a detailed guide on troubleshooting MariaDB services in ServBay, including common issues, diagnostic steps, and solutions. ServBay runs on macOS and includes different versions of MariaDB, so some commands require you to specify version-specific configuration files and directories.
Common Issues and Solutions
1. MariaDB Service Cannot Start
Possible Causes
- Configuration file errors
- Port occupied
- Permission issues
Solutions
Check the Configuration File: Ensure the
my.cnf
configuration file syntax is correct, located at:bash/Applications/ServBay/etc/mariadb/11.3/my.cnf
1Validate the configuration file using:
bashmysqld --defaults-file=/Applications/ServBay/etc/mariadb/11.3/my.cnf --validate-config
1Check Port Occupancy: Ensure the port used by MariaDB (default 3306) is not occupied by other processes. Check port occupancy using:
bashlsof -i :3306
1Check Permissions: Ensure the permissions of the MariaDB data directory and configuration files are correct. Check permissions using:
bashls -l /Applications/ServBay/db/mariadb/11.3 ls -l /Applications/ServBay/etc/mariadb/11.3/my.cnf
1
2Start the Service: Attempt to restart the MariaDB service:
bashservbayctl restart mariadb 11.3
1
2. Cannot Connect to MariaDB
Possible Causes
- MariaDB service is not running
- Firewall blocking the connection
- User permission issues
Solutions
Check Service Status: Ensure the MariaDB service is running:
bashservbayctl status mariadb 11.3
1Check Firewall Settings: Ensure the firewall allows MariaDB's port (default 3306):
bashsudo /usr/libexec/ApplicationFirewall/socketfilterfw --add /Applications/ServBay/bin/mysqld sudo /usr/libexec/ApplicationFirewall/socketfilterfw --unblockapp /Applications/ServBay/bin/mysqld
1
2Check User Permissions: Ensure the user has sufficient permissions to connect to the database:
sqlSHOW GRANTS FOR 'your_username'@'localhost';
1Connection Test: Test the connection using:
bashmysql --defaults-file=/Applications/ServBay/etc/mariadb/11.3/my.cnf -u your_username -p -h localhost -P 3306
1
3. Performance Issues
Possible Causes
- Unoptimized queries
- Improper cache configuration
- Missing indexes
Solutions
Optimize Queries: Use
EXPLAIN
to analyze query performance and optimize accordingly:sqlEXPLAIN SELECT * FROM your_table_name WHERE column_name = 'value';
1Adjust Cache: Adjust the cache settings in
my.cnf
, for example:[mysqld] query_cache_size = 64M innodb_buffer_pool_size = 1G
1
2
3Create Indexes: Ensure indexes are created for frequently queried columns:
sqlCREATE INDEX idx_column_name ON your_table_name(column_name);
1
4. Database Crashes
Possible Causes
- Hardware failure
- Software conflicts
- Configuration errors
Solutions
Check Error Logs: View the MariaDB error logs to find the specific cause of the crash. The error log path is:
bash/Applications/ServBay/logs/mariadb/11.3.err
1Repair the Database: Use the
mysqlcheck
tool to repair the database:bashmysqlcheck --defaults-file=/Applications/ServBay/etc/mariadb/11.3/my.cnf -u your_username -p --auto-repair --all-databases
1Restore Data: If database files are damaged, recover data from backups. The backup file path is:
bash/Applications/ServBay/backup/mariadb/11.3
1
5. Backup and Restore Issues
Possible Causes
- Corrupted backup files
- Incorrect restore commands
Solutions
Check Backup Files: Ensure backup files are complete and not corrupted. Check file size and integrity using:
bashls -lh /Applications/ServBay/backup/mariadb/11.3/your_backup.sql
1Correctly Restore the Database: Use the
mysql
tool to restore the database correctly:bashmysql --defaults-file=/Applications/ServBay/etc/mariadb/11.3/my.cnf -u your_username -p your_database < /Applications/ServBay/backup/mariadb/11.3/your_backup.sql
1
Specific Issue: ib_logfile0 was not found
and InnoDB: Missing FILE_CHECKPOINT(47594) at 47594
Possible Causes
- Bug in MariaDB 11.5.1
Error Logs
240618 22:37:46 mysqld_safe Starting mariadbd daemon with databases from /Applications/ServBay/db/mariadb/11.5
2024-06-18 22:37:46 0 [Note] Starting MariaDB 11.5.1-MariaDB-log source revision 65079ece42f383bdeb9b3f913a833a6f0123919d as process 3323
2024-06-18 22:37:46 0 [Warning] Setting lower_case_table_names=2 because file system for /Applications/ServBay/db/mariadb/11.5/ is case insensitive
2024-06-18 22:37:47 0 [Warning] --innodb-file-per-table is deprecated and will be removed in a future release
2024-06-18 22:37:47 0 [Note] InnoDB: Compressed tables use zlib 1.3.1
2024-06-18 22:37:47 0 [Note] InnoDB: Number of transaction pools: 1
2024-06-18 22:37:47 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2024-06-18 22:37:47 0 [Note] InnoDB: Initializing buffer pool, total size = 4.000GiB, chunk size = 64.000MiB
2024-06-18 22:37:47 0 [Note] InnoDB: Completed initialization of buffer pool
2024-06-18 22:37:47 0 [ERROR] InnoDB: File /Applications/ServBay/db/mariadb/11.5/ib_logfile0 was not found
2024-06-18 22:37:47 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2024-06-18 22:37:47 0 [Note] InnoDB: Starting shutdown...
2024-06-18 22:37:47 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2024-06-18 22:37:47 0 [Note] Plugin 'FEEDBACK' is disabled.
2024-06-18 22:37:47 0 [Note] Plugin 'wsrep-provider' is disabled.
2024-06-18 22:37:47 0 [ERROR] Unknown/unsupported storage engine: InnoDB
2024-06-18 22:37:47 0 [ERROR] Aborting
240618 22:37:48 mysqld_safe mysqld from pid file /Applications/ServBay/tmp/mariadb-11.5.pid ended
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
240618 23:22:28 mysqld_safe Starting mariadbd daemon with databases from /Applications/ServBay/db/mariadb/11.5
2024-06-18 23:22:28 0 [Note] Starting MariaDB 11.5.1-MariaDB-log source revision 65079ece42f383bdeb9b3f913a833a6f0123919d as process 6667
2024-06-18 23:22:28 0 [Warning] Setting lower_case_table_names=2 because file system for /Applications/ServBay/db/mariadb/11.5/ is case insensitive
2024-06-18 23:22:29 0 [Warning] --innodb-file-per-table is deprecated and will be removed in a future release
2024-06-18 23:22:29 0 [Note] InnoDB: Compressed tables use zlib 1.3.1
2024-06-18 23:22:29 0 [Note] InnoDB: Number of transaction pools: 1
2024-06-18 23:22:29 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2024-06-18 23:22:29 0 [Note] InnoDB: Initializing buffer pool, total size = 4.000GiB, chunk size = 64.000MiB
2024-06-18 23:22:29 0 [Note] InnoDB: Completed initialization of buffer pool
2024-06-18 23:22:29 0 [ERROR] InnoDB: Missing FILE_CHECKPOINT(47594) at 47594
2024-06-18 23:22:29 0 [ERROR] InnoDB: Log scan aborted at LSN 47594
2024-06-18 23:22:29 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2024-06-18 23:22:29 0 [Note] InnoDB: Starting shutdown...
2024-06-18 23:22:29 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2024-06-18 23:22:29 0 [Note] Plugin 'FEEDBACK' is disabled.
2024-06-18 23:22:29 0 [Note] Plugin 'wsrep-provider' is disabled.
2024-06-18 23:22:29 0 [ERROR] Unknown/unsupported storage engine: InnoDB
2024-06-18 23:22:29 0 [ERROR] Aborting
240618 23:22:29 mysqld_safe mysqld from pid file /Applications/ServBay/tmp/mariadb-11.5.pid ended
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Solutions
Referencing Modifying MariaDB Settings, find my.cnf
, and follow these detailed steps:
Add
innodb_force_recovery = 6
under[mysqld]
inmy.cnf
Edit the
my.cnf
configuration file, find[mysqld]
, and add the following line:iniinnodb_force_recovery = 6
1Start MariaDB
Start MariaDB using the following command:
bashservbayctl start mariadb 11.5
1Backup MariaDB
Use the
mysqldump
command to back up all databases:bashmysqldump -uroot -p --all-databases --opt > /Applications/ServBay/backup/mariadb/11.5/mariadb_backup.sql
1Disable MariaDB Service
In the ServBay management panel, disable the MariaDB 11.5 service
Remove
innodb_force_recovery = 6
frommy.cnf
Edit the
my.cnf
configuration file and delete the following line:iniinnodb_force_recovery = 6
1Rename
11.5
DirectoryRename the MariaDB data directory
11.5
to11.5.bak
:bashmv /Applications/ServBay/db/mariadb/11.5 /Applications/ServBay/db/mariadb/11.5.bak
1Switch to Another Version of MariaDB
Switch back to a non-problematic MariaDB version 11.5.0, or another version such as 11.3 or 11.4.
Restore MariaDB Backup
Restore the database using the
mysql
command:bashmysql -uroot -p < /Applications/ServBay/backup/mariadb/11.5/mariadb_backup.sql
1
Summary
MariaDB is a powerful and flexible database management system, but you may encounter various issues during usage. This article provides an introduction on how to troubleshoot MariaDB services, including diagnosing and resolving common issues. We hope this article is helpful to you. If you have any questions or need further assistance, please feel free to contact us.