{"id":44166,"library":"zod-dbs-mysql","title":"zod-dbs-mysql","description":"MySQL provider for zod-dbs, enabling type-safe database schema generation from MySQL or MariaDB databases. Current stable version is 1.0.5 with regular updates. It uses mysql2 for connectivity and introspects via information_schema.columns, supporting both MySQL and MariaDB. Key differentiator: integrates with zod-dbs to generate Zod schemas directly from database schema, providing end-to-end type safety without manual schema definitions.","status":"active","version":"1.0.5","language":"javascript","source_language":"en","source_url":"https://github.com/msunbay/zod-dbs","tags":["javascript","zod","zod-dbs","typescript","database","schema","mysql","mariadb","type-safe"],"install":[{"cmd":"npm install zod-dbs-mysql","lang":"bash","label":"npm"},{"cmd":"yarn add zod-dbs-mysql","lang":"bash","label":"yarn"},{"cmd":"pnpm add zod-dbs-mysql","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for database connectivity (peer dependency)","package":"mysql2","optional":false}],"imports":[{"note":"createProvider is a named export, not default.","wrong":"import createProvider from 'zod-dbs-mysql'","symbol":"createProvider","correct":"import { createProvider } from 'zod-dbs-mysql'"},{"note":"generateZodSchemas comes from 'zod-dbs', not the provider package.","wrong":"import { generateZodSchemas } from 'zod-dbs-mysql'","symbol":"generateZodSchemas","correct":"import { generateZodSchemas } from 'zod-dbs'"},{"note":"CLI is run via zod-dbs; --provider mysql selects the mysql provider.","wrong":"npx zod-dbs-mysql","symbol":"zod-dbs-cli usage with provider","correct":"npx zod-dbs --provider mysql"}],"quickstart":{"code":"// Install dependencies:\n// npm install zod-dbs zod-dbs-mysql mysql2\n\nimport { generateZodSchemas } from 'zod-dbs';\nimport { createProvider } from 'zod-dbs-mysql';\n\nconst provider = createProvider({\n  connectionString: process.env.MYSQL_CONNECTION_STRING ?? 'mysql://root:password@localhost:3306/mydb'\n});\n\nawait generateZodSchemas({\n  provider,\n  config: {\n    output: './src/schemas',\n    generateEnums: true\n  }\n});","lang":"typescript","description":"Generates Zod schemas from a MySQL database using the zod-dbs-mysql provider."},"warnings":[{"fix":"Install mysql2: npm install mysql2","message":"Package has a peer dependency on mysql2 >=2 which must be installed separately. Failure to install mysql2 results in runtime errors.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"For views, consider manual schema definitions or feature request.","message":"The provider only introspects tables and columns. Views, stored procedures, or functions are not supported.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Use --schema-name option in CLI or schemaName in programmatic config.","message":"Schema name may need to be explicitly provided when using multiple databases or when the database name differs from schema name. Not providing schema-name can lead to missing tables.","severity":"gotcha","affected_versions":">=1.0"}],"env_vars":null,"search_vec":"'1.0.5':27 'connect':35 'current':23 'databas':15,22,58,77 'dbs':3,10,51,75 'definit':70 'differenti':46 'direct':56 'enabl':11 'end':62,64 'end-to-end':61 'generat':17,53 'information_schema.columns':39 'integr':47 'introspect':37 'javascript':71 'key':45 'manual':68 'mariadb':21,44,80 'mysql':4,5,19,42,79 'mysql2':33 'provid':6,60 'regular':29 'safe':14,83 'safeti':66 'schema':16,55,59,69,78 'stabl':24 'support':40 'type':13,65,82 'type-saf':12,81 'typescript':76 'updat':30 'use':32 'version':25 'via':38 'without':67 'zod':2,9,50,54,72,74 'zod-db':8,49,73 'zod-dbs-mysql':1","created_at":"2026-06-05T17:03:17.447553+00:00","updated_at":"2026-06-05T17:03:17.447553+00:00","problems":[{"fix":"npm install mysql2","cause":"Peer dependency mysql2 not installed.","error":"Error: Cannot find module 'mysql2'"},{"fix":"Provide correct host via connection-string or --host option.","cause":"MySQL host not reachable (defaults to localhost).","error":"Error: getaddrinfo ENOTFOUND localhost"},{"fix":"Verify username, password, and database permissions.","cause":"Incorrect credentials or insufficient privileges.","error":"Error: ER_DBACCESS_DENIED_ERROR: Access denied for user 'user'@'host' to database 'db'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/msunbay/zod-dbs#readme","github":"https://github.com/msunbay/zod-dbs","docs":null,"changelog":null,"pypi":null,"npm":"zod-dbs-mysql","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}