npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mysql-in-docker

v1.0.7

Published

## Purpose

Downloads

30

Readme

mysql-in-docker

Purpose

Module starts mysql server inside docker container. This is helpful while testing.

Installation

NOTE: Docker required.

npm i mysql-in-docker --save

Usage

IMySqlInDockerOptions options

interface IMySqlInDockerOptions {

  // database name to create [optional]
  database?: string;

  // database user name to create [optional]
  user?: string;

  // database user password to create [optional]
  password?: string;

  // if true, then sequelize v3 will be used for models [optional]
  sequelizeV3?: boolean;

  // use mysql v8, by default v5 is used [optional]
  // NOTE: V8 is configured to use native authentication,
  //        because sequelize has issues with new auth method
  mysqlV8?: boolean;

  // path to folder(s)/file(s) with sequelize models [optional]
  models?: string | string[];

  // path with sql scripts [optional]
  // this path is used when you specify 'my-query.sql' in query instead of
  // sql query, module tries to locate 'my-query.sql' inside this folder
  scriptsDir?: string;

  // if true, all actions will be logged to console, default is false [optional]
  verbose?: boolean;

  // if specified, then it will be used to store mysql database after shutdown
  // note: should be accessible by docker
  storage?: string;
}

Methods

constructor(options?: IMySqlInDockerOptions)

Constructor

start()

Starts docker container with mysql server. If succeeded, then port, host, etc. properties become available.

stop()

Stops running docker container. After completion all port, host, etc. properties become unavailable.

execSql(query: string) => [RowDataPacket]

Returns method to be used to execute SQL queries. Query also can contain name of the file to be executed, e.g: my-query.sql. Returns rows.

model(name) => SequelizeModel | undefined

Return sequelize model by name, if they where loaded from specified path(s).

Properties

host: string | undefined

Returns domain or ip of running MySql server.

port: number | undefined

Returns port MySql server is listening to.

database: string | undefined

Returns name of database.

user: string | undefined

Returns mysql user.

password: string | undefined

Returns mysql password for user.

Example

const MySqlContainer  = require('mysql-in-docker');

async function main() {
  const options = {
    // See IMySqlInDockerOptions
  };

  // instantiate
  const container = new MySqlContainer(options);

  // boot
  await container.start();

  const port = container.port;
  const host = container.host;
  const database = container.database;
  const user = container.user;
  const password = container.password;

  // do some work
  ...

  // shutdown
  await container.stop();
}

or if you want to use storage:

const MySqlContainer  = require('mysql-in-docker');

async function main() {
  const options = {
    // See IMySqlInDockerOptions

    storage: '/my-path'

    // we should explicitly specify database, user and password
    //  to be able to use it after restore
    database: 'test',
    user: 'test',
    password: 'test',
  };

  // instantiate
  const container = new MySqlContainer(options);

  // boot
  await container.start();

  const port = container.port;
  const host = container.host;
  const database = container.database;
  const user = container.user;
  const password = container.password;

  // do some work
  ...

  // shutdown
  await container.stop();

  // Restore after some from the same storage
  await container.start();

  // Work with restored database
  ...

  // shutdown again
  await container.stop();
}

License

MIT. See LICENSE

Author

Siarhei Ladzeika [email protected]