Area: Ingestion
Sub-Area: Databases
Applies to: OSS + Cloud
Issue
MySQL ingestion shows incomplete metadata (missing tables or views), or a recipe fails validation. You may also want to know how foreign keys, table comments and column comments are ingested, how to set up SSL, or how to use MariaDB or AWS RDS.
You Might Be Asking
- Why are some tables or views missing from MySQL ingestion?
- Do foreign keys create lineage?
- Why are my table descriptions not showing up?
- How do I set SSL options or connect to AWS RDS?
- How do I ingest MariaDB?
- How do I stay under
max_user_connections?
Cause
-
Missing grants. MySQL filters
information_schemarows by the grants of the connecting user. A missing grant does not cause an access-denied error. You see missing tables or views instead. -
Driver arguments in the wrong place. The
optionskey is passed straight to SQLAlchemycreate_engineas keyword arguments. Driver connection arguments such as SSL files must go underoptions.connect_args, not directly underoptions. -
System databases. With
databaseunset, the source lists every database the user can see and keeps those allowed bydatabase_pattern. The built-in exclusion ofinformation_schema,performance_schema,mysqlandsysapplies only to usage statistics, not to metadata ingestion.
Solution
-
Grant the documented privileges. Grant
SELECTandSHOW VIEWon each database you ingest.SELECTcovers metadata and profiling.SHOW VIEWgives you view definitions.GRANT SELECT ON <db>.* TO 'datahub_user'@'%'; GRANT SHOW VIEW ON <db>.* TO 'datahub_user'@'%';Do not grant on
information_schema. Stored procedures are read frominformation_schema.ROUTINES, which MySQL filters by your existing grants.Add these only when you need them:
-
GRANT SELECT ON performance_schema.*only forinclude_usage_statisticswithusage_source: performance_schema. It needs thestatements_digestconsumer. It is not needed for profiling. -
GRANT SELECT ON mysql.general_logonly forusage_source: general_log. It needsgeneral_log=ONandlog_output=TABLE.
See MySQL prerequisites.
-
-
Choose databases. Set
databaseto ingest one database. Leave it unset to ingest every database the user can see. A wildcard is not a valid value fordatabase. Usedatabase_patternto filter, and deny the system databases:source: type: mysql config: host_port: "mysql.company.com:3306" username: "${MYSQL_USER}" password: "${MYSQL_PASSWORD}" database_pattern: allow: ["production", "analytics"] deny: ["mysql", "information_schema", "performance_schema", "sys"]Patterns match from the start of the name. Deny is checked first. Anchor with
^...$for an exact match. -
Set SSL. Put driver arguments under
options.connect_args:source: type: mysql config: host_port: "mysql.company.com:3306" username: "${MYSQL_USER}" password: "${MYSQL_PASSWORD}" options: connect_args: ssl_ca: "/path/to/ca.pem" ssl_cert: "/path/to/client-cert.pem" ssl_key: "/path/to/client-key.pem" -
Connect to AWS RDS without a password. Use
auth_mode: AWS_IAMwithaws_config. Thepasswordfield is ignored in this mode.source: type: mysql config: host_port: "database.region.rds.amazonaws.com:3306" username: "datahub_user" auth_mode: AWS_IAM aws_config: aws_region: "<region>" -
Foreign keys and comments. DataHub always extracts foreign keys. There is no config flag. DataHub stores them as
foreignKeyson the dataset schema metadata, not as lineage. Table comments become the dataset description. Column comments become column descriptions. If descriptions are missing, check the run report for the warningError processing table. The context of the warning is<schema>.<table>. DataHub skips a table when processing of that table fails. -
Control connections and large runs. With profiling on, a database can use up to
pool_size(default 5) plusmax_overflowconnections.max_overflowdefaults toprofiling.max_workers. If you seeUser 'USERNAME' has exceeded the 'max_user_connections' resource, do one of these:- Lower
profiling.max_workers. - Set
options: {pool_size: 2, max_overflow: 5}. - Disable profiling.
Profiling is off by default (
profiling.enabled: false). Stale entity removal is on by default with stateful ingestion. It soft-deletes entities missing from the current run. If a run drops more thanfail_safe_threshold(default 75%) of entities, removal is skipped and the run reportsSkipping stateful ingestion / stale entity removal. See stateful ingestion. - Lower
-
MariaDB. Use the dedicated
mariadbsource (type: mariadb). It takes the same config asmysql. See MariaDB source.