Skip to main content

MySQL Setup

Connect your MySQL database to 42Cells for AI-powered analysis.

Prerequisites

  • MySQL 5.7 or higher (MySQL 8.0+ recommended)
  • Network access from 42Cells to your database
  • A database user with read permissions

Connection Details

FieldDescriptionExample
HostDatabase server addressdb.example.com or 192.168.1.100
PortMySQL port3306 (default)
DatabaseDatabase nameanalytics
UsernameDatabase userreadonly_user
PasswordUser password••••••••

Step-by-Step Setup

For security, create a dedicated read-only user for 42Cells:

-- Create the user (MySQL 8.0+)
CREATE USER 'datacells_reader'@'%' IDENTIFIED BY 'your_secure_password';

-- Grant read access to a specific database
GRANT SELECT ON your_database.* TO 'datacells_reader'@'%';

-- Apply changes
FLUSH PRIVILEGES;

For MySQL 5.7:

-- Create user with password
CREATE USER 'datacells_reader'@'%' IDENTIFIED BY 'your_secure_password';

-- Grant read access
GRANT SELECT ON your_database.* TO 'datacells_reader'@'%';

-- Apply changes
FLUSH PRIVILEGES;

2. Configure Network Access

Ensure your MySQL server accepts remote connections:

For cloud-hosted databases (AWS RDS, PlanetScale, etc.):

  • Add 42Cells IP addresses to your security group or authorized networks
  • Contact support for our current IP ranges

For self-hosted databases:

  • Edit my.cnf (or my.ini on Windows):
    [mysqld]
    bind-address = 0.0.0.0
  • Ensure your firewall allows inbound connections on port 3306

For secure connections, enable SSL:

-- Check SSL status
SHOW VARIABLES LIKE '%ssl%';

In 42Cells connection settings, enable SSL if your server supports it.

4. Test the Connection

  1. Go to Connections in 42Cells
  2. Click New ConnectionMySQL
  3. Enter your connection details
  4. Click Test Connection
  5. If successful, click Save

Common Issues

Connection Refused

  • Verify MySQL is running: sudo systemctl status mysql
  • Check bind-address in my.cnf (should be 0.0.0.0 for remote access)
  • Ensure the port is correct (default: 3306)

Access Denied

  • Verify username and password
  • Check the user host pattern matches (use '%' for any host)
  • View existing users:
    SELECT user, host FROM mysql.user;

Host Not Allowed

The user might be restricted to specific hosts:

-- Update user to allow connections from any host
RENAME USER 'datacells_reader'@'localhost' TO 'datacells_reader'@'%';
FLUSH PRIVILEGES;

Authentication Plugin Issues (MySQL 8.0)

MySQL 8.0 uses caching_sha2_password by default. If you have connection issues:

-- Switch to mysql_native_password
ALTER USER 'datacells_reader'@'%'
IDENTIFIED WITH mysql_native_password BY 'your_secure_password';
FLUSH PRIVILEGES;

Permission Denied

Ensure the user has SELECT privileges:

-- Check current privileges
SHOW GRANTS FOR 'datacells_reader'@'%';

Performance Tips

  • Use connection pooling for frequent queries
  • Consider read replicas for heavy analytics workloads
  • Index columns used in WHERE clauses and JOINs
  • For large tables, ensure statistics are up to date: ANALYZE TABLE table_name;