PHPackages                             slam/mysql-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. slam/mysql-php

AbandonedArchivedLibrary[Database &amp; ORM](/categories/database)

slam/mysql-php
==============

PHP version of mysql cli that comes with MySQL

v1.1.0(3y ago)524.9k↓46.7%[1 issues](https://github.com/Slamdunk/mysql-php/issues)[3 PRs](https://github.com/Slamdunk/mysql-php/pulls)MITPHPPHP ~8.1.0 || ~8.2.0

Since Jul 17Pushed 1y agoCompare

[ Source](https://github.com/Slamdunk/mysql-php)[ Packagist](https://packagist.org/packages/slam/mysql-php)[ Fund](https://paypal.me/filippotessarotto)[ GitHub Sponsors](https://github.com/Slamdunk)[ RSS](/packages/slam-mysql-php/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (4)Dependencies (5)Versions (12)Used By (0)

MySQL bin in PHP
================

[](#mysql-bin-in-php)

[![Latest Stable Version](https://camo.githubusercontent.com/faf49bd10c2dff5e4fbfb71671c784e1d348cc8ac4b6144d1b271737d20b8f6d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736c616d2f6d7973716c2d7068702e737667)](https://packagist.org/packages/slam/mysql-php)[![Downloads](https://camo.githubusercontent.com/5fcd835e25ca7c496fec4c68576a5ec329845a71ca8bb5b6382f16a8c6c79cf7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736c616d2f6d7973716c2d7068702e737667)](https://packagist.org/packages/slam/mysql-php)[![Integrate](https://github.com/Slamdunk/mysql-php/workflows/CI/badge.svg?branch=master)](https://github.com/Slamdunk/mysql-php/actions)[![Code Coverage](https://camo.githubusercontent.com/d8f99b2326e3973dc1142deeb7488ab376fce7cd6cc635f0ed247937ba5ec75d/68747470733a2f2f636f6465636f762e696f2f67682f536c616d64756e6b2f6d7973716c2d7068702f636f7665726167652e7376673f6272616e63683d6d6173746572)](https://codecov.io/gh/Slamdunk/mysql-php?branch=master)

PHP light version of mysql cli that comes with MySQL.

Why
---

[](#why)

1. You are inside a PHP only environment, like a PHP Docker image
2. You need to import a large mysql dump
3. You don't have access to the native `mysql` client

Performance
-----------

[](#performance)

Speed is exactly the **same** of the original `mysql` binary thanks to streams usage.

Supported formats
-----------------

[](#supported-formats)

Input typeExampleSupported?`mysqldump` output*as is*✔️Single query on single line`SELECT NOW();`✔️Single query on multiple lines`SELECT`
`NOW();`✔️Multiple queries on separated single or multiple lines`SELECT NOW();`
`SELECT`
`NOW();`✔️Multiple queries on single line`SELECT NOW();SELECT NOW();`❌Usage
-----

[](#usage)

The library provides two usages, the binary and the `\SlamMysql\Mysql` class.

### From CLI

[](#from-cli)

```
$ ./mysql -h
Usage: mysql [OPTIONS]
  --host       Connect to host     [Default: INI mysqli.default_host]
  --port       Port number         [Default: INI mysqli.default_port]
  --username   User for login      [Default: INI mysqli.default_user]
  --password   Password to use     [Default: INI mysqli.default_pw]
  --database   Database to use     [Default: empty]
  --socket     The socket file     [Default: INI mysqli.default_socket]

$ printf "CREATE DATABASE foobar;\nSHOW DATABASES;" | ./mysql
information_schema
foobar
mysql
performance_schema
sys

$ ./mysql --database foobar < foobar_huge_dump.sql

```

### From PHP

[](#from-php)

```
$mysql = new \SlamMysql\Mysql('localhost', 'root', 'pwd', 'my_database', 3306, '/socket');
$return = $mysql->run(\STDIN, \STDOUT, \STDERR);
exit((int) (true !== $return));
```

`\SlamMysql\Mysql::run` accepts any type of resource consumable by `fgets/fwrite` functions.

Related projects
----------------

[](#related-projects)

1. [ifsnop/mysqldump-php](https://github.com/ifsnop/mysqldump-php): `mysqldump` binary port in pure PHP

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance24

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 71.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~211 days

Recently: every ~315 days

Total

7

Last Release

1277d ago

Major Versions

v0.2.1 → v1.0.02022-04-21

PHP version history (4 changes)v0.0.1PHP ^7.3

v0.2.1PHP ^7.4 || ^8.0

v1.0.0PHP ~8.0.0 || ~8.1.0

v1.1.0PHP ~8.1.0 || ~8.2.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/50348?v=4)[Sahn Lam](/maintainers/Slam)[@slam](https://github.com/slam)

---

Top Contributors

[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (99 commits)")[![Slamdunk](https://avatars.githubusercontent.com/u/152236?v=4)](https://github.com/Slamdunk "Slamdunk (36 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")

---

Tags

mysqlphpmysql

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/slam-mysql-php/health.svg)

```
[![Health](https://phpackages.com/badges/slam-mysql-php/health.svg)](https://phpackages.com/packages/slam-mysql-php)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k605.0M6.8k](/packages/doctrine-dbal)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k32.6M46](/packages/kirschbaum-development-eloquent-power-joins)[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58825.9M54](/packages/scienta-doctrine-json-functions)[cytopia/mysqldump-secure

Secure mysqldump script with encryption, compression, logging, blacklisting and Nagios monitoring integration

1474.7k1](/packages/cytopia-mysqldump-secure)[ark/database

Light weight database abstraction

117.8k](/packages/ark-database)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
