Fix Mideye Database Connection Issues (MySQL/MSSQL)
Database connectivity problems prevent Mideye Server from starting or cause runtime failures. This guide covers common database issues and their resolution.
Overview
Section titled “Overview”Mideye Server requires a database to store configuration, user tokens, authentication logs, and operational data. Connection failures during startup prevent the service from running, while runtime failures can cause authentication to fail.
Supported Databases:
- MariaDB (primary/recommended)
- MySQL
- Microsoft SQL Server
Common Error Messages
Section titled “Common Error Messages”| Error Message | Likely Cause |
|---|---|
| ”Communications link failure” | Cannot connect to database server |
| ”Connection refused” | Database not listening on configured port |
| ”Access denied for user” | Invalid database credentials |
| ”Unknown database” | Database doesn’t exist |
| ”Waiting for changelog lock” | Database migration lock stuck |
| ”Connection is not available” | Connection pool exhausted |
Common Issues
Section titled “Common Issues”1. Database Not Running
Section titled “1. Database Not Running”Symptoms:
- “Connection refused” errors
- “Communications link failure” errors
- Mideye Server fails to start
Diagnostic Steps:
Linux:
# Check database service statussystemctl status mariadb # MariaDBsystemctl status mysql # MySQL
# Check if database is listeningss -tlnp | grep 3306 # MariaDB/MySQLss -tlnp | grep 1433 # SQL ServerWindows (PowerShell):
# Check database serviceGet-Service *mysql*Get-Service *mariadb*Get-Service MSSQLSERVER
# Check if database is listeningTest-NetConnection -ComputerName localhost -Port 3306Solution:
-
Start the database service:
Linux:
Terminal window sudo systemctl start mariadbsudo systemctl enable mariadb # Start on bootWindows:
Terminal window Start-Service MSSQLSERVERSet-Service MSSQLSERVER -StartupType Automatic -
Test database connection:
Linux:
Terminal window mysql -h localhost -u root -p mideyeserver -
Restart Mideye Server:
Linux:
Terminal window sudo systemctl restart mideyeserver6Windows:
Terminal window Restart-Service MideyeServer6
2. Invalid Database Credentials
Section titled “2. Invalid Database Credentials”Symptoms:
- “Access denied for user” errors
- Service fails to start immediately (not after timeout)
Diagnostic Steps:
-
Test credentials manually:
Terminal window mysql -h localhost -u root -p mideyeserver -
Check configured credentials:
Terminal window sudo cat /opt/mideyeserver6/config/application-prod.yml | grep -A 5 datasource
Solution:
-
Update password in the application configuration file if it was changed in the database
-
If using special characters in the password, wrap it in single quotes in the configuration file:
password: 'P@ssw0rd!' -
Grant necessary permissions:
GRANT ALL PRIVILEGES ON mideyeserver.* TO 'root'@'localhost';FLUSH PRIVILEGES; -
Restart Mideye Server
3. Database Does Not Exist
Section titled “3. Database Does Not Exist”Symptoms:
- “Unknown database” error
- Service fails to start
- Migration errors
Solution:
-
Create the database:
-- MariaDB/MySQLCREATE DATABASE mideyeserver CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;-- SQL ServerCREATE DATABASE mideyeserver; -
Grant permissions:
GRANT ALL PRIVILEGES ON mideyeserver.* TO 'root'@'localhost';FLUSH PRIVILEGES; -
Restart Mideye Server — database tables will be created automatically
4. Database Migration Lock Stuck
Section titled “4. Database Migration Lock Stuck”Problem: Migration lock is held from a previous failed startup, preventing new migrations.
Symptoms:
- “Waiting for changelog lock” in logs
- Service startup hangs
- Cannot restart service successfully
Diagnostic Steps:
SELECT * FROM DATABASECHANGELOGLOCK;If LOCKED = 1 and no Mideye Server process is running, the lock is stuck.
Solution:
-
Ensure Mideye Server is stopped:
Linux:
Terminal window sudo systemctl stop mideyeserver6Windows:
Terminal window Stop-Service MideyeServer6 -
Release the lock:
UPDATE DATABASECHANGELOGLOCK SET LOCKED=0, LOCKGRANTED=NULL, LOCKEDBY=NULL WHERE ID=1;Only release the lock if you are absolutely certain no migration is running!
-
Start Mideye Server:
Linux:
Terminal window sudo systemctl start mideyeserver6Windows:
Terminal window Start-Service MideyeServer6 -
Monitor logs for successful startup
5. Network Connectivity to Remote Database
Section titled “5. Network Connectivity to Remote Database”Problem: Database is on a remote server and network connectivity is an issue.
Symptoms:
- Works with localhost database, fails with remote
- “Connection timed out” errors
- Intermittent connectivity
Diagnostic Steps:
Linux:
# Test connectivitync -zv databaseserver.domain.com 3306
# Measure latencytime mysql -h databaseserver.domain.com -u root -p -e "SELECT 1"Windows:
Test-NetConnection -ComputerName databaseserver.domain.com -Port 3306Solution:
-
Allow database port through firewalls between Mideye Server and the database server
-
Ensure the database is configured to accept remote connections:
Terminal window # MariaDB/MySQL: check bind-addresssudo grep bind-address /etc/mysql/mariadb.conf.d/*.cnfChange
127.0.0.1to0.0.0.0for remote access. -
Grant remote access for the database user:
GRANT ALL PRIVILEGES ON mideyeserver.* TO 'root'@'mideyeserver-ip' IDENTIFIED BY 'password';FLUSH PRIVILEGES;
6. Connection Pool Exhaustion
Section titled “6. Connection Pool Exhaustion”Problem: All database connections are in use, causing new requests to fail.
Symptoms:
- “Connection is not available” errors
- Service becomes unresponsive under load
- Works initially then fails during peak usage
Solution:
-
Check current database connections:
-- MariaDB/MySQLSHOW STATUS LIKE 'Threads_connected';SHOW VARIABLES LIKE 'max_connections'; -
Increase the database server’s max connections if needed:
SET GLOBAL max_connections = 500; -
Review the connection pool settings in the application configuration file and increase pool size if needed
-
Restart Mideye Server
7. Database Character Encoding Issues
Section titled “7. Database Character Encoding Issues”Problem: Special characters (å, ä, ö, é, etc.) appear corrupted.
Symptoms:
- Usernames with special characters appear as garbage
- “Incorrect string value” errors
Diagnostic Steps:
-- Check database character setSHOW VARIABLES LIKE 'character_set%';SHOW VARIABLES LIKE 'collation%';
SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAMEFROM INFORMATION_SCHEMA.SCHEMATAWHERE SCHEMA_NAME = 'mideyeserver';Solution:
Use UTF8MB4 for the database:
-- New databaseCREATE DATABASE mideyeserver CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Existing databaseALTER DATABASE mideyeserver CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;See also Character Encoding Issues.
Verification and Testing
Section titled “Verification and Testing”After resolving database issues:
- Verify service starts — Check service status
- Check application logs — Look for database-related errors via Log Files
- Test authentication — Verify authentication operations work
- Check authentication logs — Ensure logs are being written to the database via Authentication Logs
Getting Help
Section titled “Getting Help”If database issues persist:
-
Collect diagnostic information:
- Database type and version
- Error messages from logs
- Database service status
- Network connectivity test results
-
Sanitize configuration (remove passwords)
-
Contact Mideye Support with collected information