{"id":42534,"library":"connect-mysql-store","title":"connect-mysql-store","description":"A simple and minimal MySQL session store for Express session middleware. Current stable version is 0.2.0. Release cadence is low; no recent updates. Key differentiators: minimal configuration, relies on MySQL connection string, and requires a predefined table schema. Suitable for small Express apps needing MySQL-backed sessions without complex ORM integration.","status":"active","version":"0.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/xuefengwang/connect-mysql","tags":["javascript","Express","MySQL","Session","Store"],"install":[{"cmd":"npm install connect-mysql-store","lang":"bash","label":"npm"},{"cmd":"yarn add connect-mysql-store","lang":"bash","label":"yarn"},{"cmd":"pnpm add connect-mysql-store","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required peer dependency; this store implements express-session's Store interface.","package":"express-session","optional":false},{"reason":"Used for MySQL database connectivity. The package uses mysql2 internally for promise-based queries.","package":"mysql2","optional":false}],"imports":[{"note":"This package does not provide a default ESM export; use CommonJS require.","wrong":"import MySQLStore from 'connect-mysql-store';","symbol":"default","correct":"const MySQLStore = require('connect-mysql-store');"},{"note":"The module exports a single constructor function directly, not as a named export.","wrong":"const { MySQLStore } = require('connect-mysql-store');","symbol":"MySQLStore","correct":"const MySQLStore = require('connect-mysql-store');"},{"note":"session must be imported separately from express-session, not from this package.","wrong":"const MySQLStore = require('connect-mysql-store'); const session = MySQLStore.session;","symbol":"session","correct":"const session = require('express-session');"}],"quickstart":{"code":"const express = require('express');\nconst session = require('express-session');\nconst MySQLStore = require('connect-mysql-store');\n\nconst app = express();\n\napp.use(session({\n  secret: 'your-secret-key',\n  resave: true,\n  saveUninitialized: false,\n  store: new MySQLStore({\n    url: 'mysql://user:password@localhost/database',\n    table: 'sessions'\n  })\n}));\n\napp.get('/', (req, res) => {\n  if (!req.session.views) req.session.views = 0;\n  req.session.views++;\n  res.send(`Views: ${req.session.views}`);\n});\n\napp.listen(3000);","lang":"javascript","description":"Sets up an Express app with MySQL-backed sessions using connect-mysql-store. Demonstrates store initialization with connection URL and session usage."},"warnings":[{"fix":"Run the CREATE TABLE SQL provided in the README to create the sessions table.","message":"Requires a predefined MySQL table with specific columns (sid, session, updated). The table must be created manually before use.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Provide a valid MySQL connection string via the `url` option.","message":"The `url` option is required; if omitted, the store will throw an error on instantiation.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Migrate to a maintained package like 'express-mysql-session'.","message":"This package is no longer actively maintained. Consider using more up-to-date alternatives like 'express-mysql-session'.","severity":"deprecated","affected_versions":">=0.2.0"},{"fix":"Alter the table to increase VARCHAR length or use TEXT type for session column.","message":"The `session` column length is limited to 2048 characters; large sessions may be truncated silently.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'0.2.0':20 'app':47 'back':51 'cadenc':22 'complex':54 'configur':31 'connect':2,35 'connect-mysql-stor':1 'current':16 'differenti':29 'express':13,46,58 'integr':56 'javascript':57 'key':28 'low':24 'middlewar':15 'minim':8,30 'mysql':3,9,34,50,59 'mysql-back':49 'need':48 'orm':55 'predefin':40 'recent':26 'releas':21 'reli':32 'requir':38 'schema':42 'session':10,14,52,60 'simpl':6 'small':45 'stabl':17 'store':4,11,61 'string':36 'suitabl':43 'tabl':41 'updat':27 'version':18 'without':53","created_at":"2026-06-05T16:55:26.234444+00:00","updated_at":"2026-06-05T16:55:26.234444+00:00","problems":[{"fix":"Ensure the store is initialized and passed in the session options object before applying app.use(session(...)).","cause":"The store must be passed to session() synchronously; re-assigning req.session.store after middleware start is not allowed.","error":"Error: Can't set session store after session middleware is used"},{"fix":"Use correct CommonJS require: const MySQLStore = require('connect-mysql-store');","cause":"CommonJS require incorrectly used as named import or ESM import not transpiled.","error":"MySQLStore is not a constructor"},{"fix":"Check the url option format: mysql://username:password@host/database","cause":"Invalid MySQL credentials in the connection url.","error":"ER_ACCESS_DENIED_ERROR: Access denied for user ..."}],"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/xuefengwang/connect-mysql#readme","github":"https://github.com/xuefengwang/connect-mysql","docs":null,"changelog":null,"pypi":null,"npm":"connect-mysql-store","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}}