# MySQL

Euno's MySQL integration supports auto-discovery of:

* MySQL instances
* MySQL schemas (databases)
* MySQL tables and views
* MySQL columns with data type mapping
* View definitions with SQL code

## Setting up MySQL integration

### Overview

MySQL is a popular open-source relational database management system. In MySQL, data is stored in *tables* and *views.* Each table or view belongs to one MySQL *schema* (also called database), and each *schema* belongs to a MySQL *instance*. A MySQL instance can have multiple schemas, and each schema can contain multiple tables and views.

To discover MySQL resources, Euno connects directly to your MySQL instance and executes queries on the system-defined `INFORMATION_SCHEMA` views. These views provide metadata about all databases, tables, views, and columns in your MySQL instance.

Euno automatically excludes system schemas (`mysql`, `sys`, `performance_schema`, `information_schema`) and allows you to configure which user schemas to discover using regular expression patterns.

### Step 1: Prepare MySQL Instance

#### Ensure MySQL is accessible

1. Verify that your MySQL instance is running and accessible from Euno IP address `35.224.29.172`
2. Note the MySQL hostname/IP address and port (default: 3306)
3. Ensure your MySQL instance allows connections from Euno's network

#### Create a dedicated MySQL user for Euno (Recommended)

For security best practices, create a dedicated MySQL user with minimal required permissions:

```sql
-- Create a dedicated user for Euno
CREATE USER 'euno_reader'@'%' IDENTIFIED BY 'secure_password_here';

-- Grant necessary permissions to read metadata
GRANT SELECT ON *.* TO 'euno_reader'@'%';
GRANT SHOW DATABASES ON *.* TO 'euno_reader'@'%';

-- Apply the changes
FLUSH PRIVILEGES;
```

**Alternative**: You can use an existing MySQL user with read permissions, but ensure it has the following minimum privileges:

* `SELECT` on all databases you want to discover
* `SHOW DATABASES` privilege

### Step 2: Configure Euno's MySQL Integration

| Configuration  | Description                                         |
| -------------- | --------------------------------------------------- |
| MySQL Hostname | The hostname or IP address of your MySQL server     |
| MySQL Port     | The port number MySQL is running on (default: 3306) |
| MySQL Username | Username for connecting to MySQL                    |
| MySQL Password | Password for the MySQL user                         |

### Step 3: Schedule

* Enable the Schedule option.
* Choose:
  1. **Weekly**: Set specific days and times.
  2. **Hourly**: Define the interval in hours (e.g., every 8 hours).

### Step 4: Resource Cleanup

* **Immediate Cleanup**: Remove resources not detected in the most recent successful source integration run.
* **No Cleanup**: Keep all resources indefinitely, even if they are no longer detected.

To keep your data relevant and free of outdated resources, Euno provides automatic **resource cleanup** options. These settings determine when a resource should be removed if it is no longer detected by a source integration. For a detailed explanation on Euno's cleanup strategies, see: [Resource Sponsorship in Euno](https://docs.euno.ai/developer-reference/technical-concepts/resource-sponsorship-and-cleanup-in-euno).

### Step 5: Advanced Settings

Click on the '**Advanced**' section to display these additional configurations.

| Configuration                    | Description                                                                                                                                                                                                                  |
| -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Override MySQL Instance Name     | Custom name for the MySQL instance in Euno (defaults to hostname)                                                                                                                                                            |
| Override MySQL Hostname for URIs | Custom hostname to use in resource URIs (defaults to actual hostname)                                                                                                                                                        |
| Schema Pattern                   | Use a regular expression to allow or exclude specific schemas. ".\*" will include/exclude all schemas. System schemas (mysql, sys, performance\_schema, information\_schema) are always excluded regardless of this setting. |

**Examples of Schema Patterns:**

* `.*` - Include all user schemas
* `production_.*` - Include only schemas starting with "production\_"
* `.*` (allow) and `test_.*` (deny) - Include all schemas except those starting with "test\_"

### Step 6: Save Configuration

Click the **Test & Save** button to complete the setup. Euno will validate the connection and permissions before saving.

## Discovered Resources

The Euno-MySQL integration discovers various resources including MySQL instances, schemas, tables, views, and columns. For detailed information about discovered resources and their properties, see [mysql-integration-discovered-resources](https://docs.euno.ai/sources/data-warehouses/mysql-integration/mysql-integration-discovered-resources).
