Deploys the server-side component that bridges EDB2MySQL to the MySQL/MariaDB database.
| File | Role |
|---|---|
edbapi.php |
API entry point — deploy inside the webroot |
config.php |
Credentials and access control — store outside the webroot |
Place edbapi.php inside the webroot and
config.php in a sibling folder outside it:
/var/www/
html/ ← webroot
edbapi.php
private/ ← outside webroot (cPanel standard)
config.php
edb2mysql-api.log ← created automatically
The path edbapi.php uses to find config.php
is set by the EDB2MYSQL_CONFIG constant at the top of the
file:
define('EDB2MYSQL_CONFIG', __DIR__ . '/../private/config.php');Change it if your layout differs.
Copy config-example.php to config.php and
adjust the values.
define('DB_HOST', 'localhost'); // MySQL/MariaDB hostname or IP
define('DB_NAME', ''); // target database (leave empty to require from client)
define('DB_USER', ''); // MySQL username
define('DB_PASS', ''); // MySQL passwordValues defined here are fallbacks — the client request always takes
priority. Storing credentials in config.php (outside the
webroot) means the application does not need to hold the database
password.
define('API_ENABLED', true); // false = disable the API entirely
define('API_KEY', ''); // required X-API-Key value; '' = no key check
define('ALLOWED_IPS', []); // IP whitelist; [] = allow all
define('BLOCKED_IPS', []); // IP blacklist; evaluated before ALLOWED_IPS
define('CORS_ORIGIN', '*'); // Access-Control-Allow-Origin header valueFor any internet-facing deployment: set a strong API_KEY
and restrict ALLOWED_IPS to the IP of the machine running
EDB2MySQL. Set CORS_ORIGIN to the exact origin of the
client if cross-origin restrictions are required; the default
'*' is permissive.
define('MAX_SCRIPT_SIZE', 10 * 1024 * 1024); // optional; reject scripts larger than 10 MBWhen this constant is not defined in config.php, no size
limit is enforced by edbapi.php. The value shown above is a
recommended safeguard.
These constants are optional. The defaults work for most deployments; adjust only if you encounter memory or performance issues.
define('RESULT_PAGE_SIZE', 500); // rows per page from script_run / result_page
define('MAX_RESULT_BUFFER_MB', 64); // PDO buffer cap for libmysqlclient driver (MB)
// define('RESULT_INLINE_BLOB_MAX_BYTES', 65536); // OOB threshold in bytes (default: all inline)RESULT_PAGE_SIZE controls how many rows are returned per
round-trip. Larger values reduce network overhead for big result sets
but increase per-response memory use on both server and client. Has no
effect on data migration batch size.
MAX_RESULT_BUFFER_MB applies only when
PHP uses the libmysqlclient driver (not the default
mysqlnd). It caps the PDO connection buffer to prevent OOM
crashes when a BLOB cell exceeds available memory — PDO raises a
controlled error instead of exhausting the process heap. Has no effect
with mysqlnd.
RESULT_INLINE_BLOB_MAX_BYTES sets a server-side default
for the out-of-band BLOB threshold. BLOB and CLOB cells larger than this
value are stored as temporary files on the server and fetched
individually rather than being sent inline in result pages. This keeps
result pages small even when the querying client does not specify its
own threshold. When not defined, the default is all BLOBs inline
(backward-compatible with older clients). Example:
define('RESULT_INLINE_BLOB_MAX_BYTES', 65536); (64 KB).
define('LOG_FILE', __DIR__ . '/edb2mysql-api.log'); // __DIR__ is private/ hereThe log file location is determined at runtime. When
LOG_FILE is not defined in
config.php, edbapi.php defaults to placing the
log alongside config.php in the private/
folder — outside the webroot. On nginx and LiteSpeed deployments this is
important, as those servers do not process .htaccess; a log
file inside the webroot could be served as a plain-text HTTP
response.
When LOG_FILE is defined (as shown
above using __DIR__), the path is relative to the directory
containing config.php, which is already
private/. Either way the log ends up outside the webroot in
a standard deployment.
Upgrade note: if you have a previous deployment without a
LOG_FILEdefinition and are runningedbapi.phpolder than v184, the log may be atPHP/edb2mysql-api.log(inside the webroot). After upgrading, delete that file — future log entries will be written to the new location.
EDB2MySQL reads these values via Get Server Information and uses them to auto-configure batch and BLOB limits.
| Setting | Relevance |
|---|---|
memory_limit |
PHP memory available for result sets and BLOBs. -1 =
unlimited. |
post_max_size |
Maximum POST body — limits the migration batch size. |
upload_max_filesize |
Per-file upload limit — limits individual BLOB chunk uploads. |
max_execution_time |
Scripts with many DDL statements may need this increased. |
For databases with large BLOBs, memory_limit of at least
256M is recommended.
In EDB2MySQL, go to the Remote Configuration tab:
https://yourserver.com/edbapi.php) and click
Test API — green indicator confirms the API is
reachable.