{"id":16390169,"url":"https://github.com/slamdunk/mysql-php","last_synced_at":"2025-10-26T13:31:03.923Z","repository":{"id":35020872,"uuid":"197359240","full_name":"Slamdunk/mysql-php","owner":"Slamdunk","description":"PHP version of mysql cli that comes with MySQL","archived":false,"fork":false,"pushed_at":"2024-09-13T06:12:06.000Z","size":126,"stargazers_count":6,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-13T17:22:47.287Z","etag":null,"topics":["mysql","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Slamdunk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["Slamdunk"],"custom":"https://paypal.me/filippotessarotto"}},"created_at":"2019-07-17T09:32:39.000Z","updated_at":"2024-07-24T11:17:56.000Z","dependencies_parsed_at":"2024-01-25T22:28:49.841Z","dependency_job_id":"feade2b6-03f6-4e99-9f35-17d74a0e5325","html_url":"https://github.com/Slamdunk/mysql-php","commit_stats":{"total_commits":36,"total_committers":2,"mean_commits":18.0,"dds":0.05555555555555558,"last_synced_commit":"c794f53c175b368779ebcd1a4564e1579a25abcc"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Slamdunk%2Fmysql-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Slamdunk%2Fmysql-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Slamdunk%2Fmysql-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Slamdunk%2Fmysql-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Slamdunk","download_url":"https://codeload.github.com/Slamdunk/mysql-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219862887,"owners_count":16555951,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mysql","php"],"created_at":"2024-10-11T04:35:08.121Z","updated_at":"2025-10-26T13:30:58.607Z","avatar_url":"https://github.com/Slamdunk.png","language":"PHP","funding_links":["https://github.com/sponsors/Slamdunk","https://paypal.me/filippotessarotto"],"categories":[],"sub_categories":[],"readme":"# MySQL bin in PHP\n\n[![Latest Stable Version](https://img.shields.io/packagist/v/slam/mysql-php.svg)](https://packagist.org/packages/slam/mysql-php)\n[![Downloads](https://img.shields.io/packagist/dt/slam/mysql-php.svg)](https://packagist.org/packages/slam/mysql-php)\n[![Integrate](https://github.com/Slamdunk/mysql-php/workflows/CI/badge.svg?branch=master)](https://github.com/Slamdunk/mysql-php/actions)\n[![Code Coverage](https://codecov.io/gh/Slamdunk/mysql-php/coverage.svg?branch=master)](https://codecov.io/gh/Slamdunk/mysql-php?branch=master)\n\nPHP light version of mysql cli that comes with MySQL.\n\n## Why\n\n1. You are inside a PHP only environment, like a PHP Docker image\n1. You need to import a large mysql dump\n1. You don't have access to the native `mysql` client\n\n## Performance\n\nSpeed is exactly the **same** of the original `mysql` binary thanks to streams usage.\n\n## Supported formats\n\n|Input type|Example|Supported?|\n|---|---|:---:|\n|`mysqldump` output|*as is*|:heavy_check_mark:|\n|Single query on single line|`SELECT NOW();`|:heavy_check_mark:|\n|Single query on multiple lines|`SELECT`\u003cbr /\u003e`NOW();`|:heavy_check_mark:|\n|Multiple queries on separated single or multiple lines|`SELECT NOW();`\u003cbr /\u003e`SELECT`\u003cbr /\u003e`NOW();`|:heavy_check_mark:|\n|Multiple queries on single line|`SELECT NOW();SELECT NOW();`|:x:|\n\n## Usage\n\nThe library provides two usages, the binary and the `\\SlamMysql\\Mysql` class.\n\n### From CLI\n\n```\n$ ./mysql -h\nUsage: mysql [OPTIONS]\n  --host       Connect to host     [Default: INI mysqli.default_host]\n  --port       Port number         [Default: INI mysqli.default_port]\n  --username   User for login      [Default: INI mysqli.default_user]\n  --password   Password to use     [Default: INI mysqli.default_pw]\n  --database   Database to use     [Default: empty]\n  --socket     The socket file     [Default: INI mysqli.default_socket]\n\n$ printf \"CREATE DATABASE foobar;\\nSHOW DATABASES;\" | ./mysql\ninformation_schema\nfoobar\nmysql\nperformance_schema\nsys\n\n$ ./mysql --database foobar \u003c foobar_huge_dump.sql\n```\n\n### From PHP\n\n```php\n$mysql = new \\SlamMysql\\Mysql('localhost', 'root', 'pwd', 'my_database', 3306, '/socket');\n$return = $mysql-\u003erun(\\STDIN, \\STDOUT, \\STDERR);\nexit((int) (true !== $return));\n```\n\n`\\SlamMysql\\Mysql::run` accepts any type of resource consumable by `fgets/fwrite` functions.\n\n## Related projects\n\n1. [ifsnop/mysqldump-php](https://github.com/ifsnop/mysqldump-php): `mysqldump` binary port in pure PHP\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslamdunk%2Fmysql-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslamdunk%2Fmysql-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslamdunk%2Fmysql-php/lists"}