<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>MySQL on Mimus</title><link>https://mimus.pgsty.com/docs/mysql/</link><description>Recent content in MySQL on Mimus</description><generator>Hugo</generator><language>en-US</language><atom:link href="https://mimus.pgsty.com/docs/mysql/index.xml" rel="self" type="application/rss+xml"/><item><title>Protocol, dialect and origins</title><link>https://mimus.pgsty.com/docs/mysql/architecture/</link><guid>https://mimus.pgsty.com/docs/mysql/architecture/</guid><description>&lt;h2 id="flow"&gt;From TCP connection to table&#10;&lt;/h2&gt;&#10;&lt;p&gt;Patch 300 imports the OpenHalo server hooks. At startup the preloaded extension registers a TCP listener. On connection, a PostgreSQL backend exchanges a MySQL handshake, chooses the native database configured in &lt;code&gt;mysql.database&lt;/code&gt; and authenticates the PostgreSQL role. It checks for the extension in that database before accepting application SQL. The database name sent by the client selects a schema inside it. &lt;a href="https://mimus.pgsty.com/docs/patches/mysql/"&gt;300/301 kernel patches&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Limits and troubleshooting</title><link>https://mimus.pgsty.com/docs/mysql/status/</link><guid>https://mimus.pgsty.com/docs/mysql/status/</guid><description>&lt;h2 id="connections"&gt;Connection problems&#10;&lt;/h2&gt;&#10;&lt;div class="td-table-scroll td-table-scroll--static"&gt;&#10;&lt;table&gt;&#10; &lt;thead&gt;&#10; &lt;tr&gt;&#10; &lt;th scope="col"&gt;Symptom&lt;/th&gt;&#10; &lt;th scope="col"&gt;What to check&lt;/th&gt;&#10; &lt;th scope="col"&gt;Action&lt;/th&gt;&#10; &lt;/tr&gt;&#10; &lt;/thead&gt;&#10; &lt;tbody&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;&lt;code&gt;mysql&lt;/code&gt; looks for a socket file, or gets a protocol error&lt;/td&gt;&#10; &lt;td&gt;The MySQL listener is TCP-only. Port 5432 normally speaks PostgreSQL.&lt;/td&gt;&#10; &lt;td&gt;Use &lt;code&gt;--protocol=TCP -h 127.0.0.1 -P 3306&lt;/code&gt; or substitute the configured address and port.&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Connection refused after a configuration change&lt;/td&gt;&#10; &lt;td&gt;Via &lt;code&gt;psql&lt;/code&gt;, check &lt;code&gt;SHOW shared_preload_libraries&lt;/code&gt; and &lt;code&gt;pg_settings.pending_restart&lt;/code&gt;. In the server log look for &lt;code&gt;MySQL protocol listening on port&lt;/code&gt; or a socket bind warning.&lt;/td&gt;&#10; &lt;td&gt;Restart after changing the preloads, addresses or port. Check port conflicts, &lt;code&gt;mysql.listener_on&lt;/code&gt; and whether &lt;code&gt;mysql.port=0&lt;/code&gt;.&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Login fails before any SQL&lt;/td&gt;&#10; &lt;td&gt;Check the first matching HBA line using the &lt;strong&gt;PostgreSQL database name&lt;/strong&gt;, role, client IP and TLS mode. Check the role has &lt;code&gt;LOGIN&lt;/code&gt;, a current password and the required verifier.&lt;/td&gt;&#10; &lt;td&gt;Correct the matching rule, reload HBA, reconnect and verify the certificate. For cold-cache SHA-2 login use TLS or a client configured for RSA exchange.&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Ordinary role is told to install the extension&lt;/td&gt;&#10; &lt;td&gt;In &lt;code&gt;psql&lt;/code&gt; check &lt;code&gt;SHOW mysql.database&lt;/code&gt;. Connect to that database and query &lt;code&gt;pg_extension&lt;/code&gt; there.&lt;/td&gt;&#10; &lt;td&gt;As a superuser run &lt;code&gt;CREATE EXTENSION pg_mysql&lt;/code&gt; in the target. Grant the application access to its schema.&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Login works but tables are missing&lt;/td&gt;&#10; &lt;td&gt;Compare MySQL &lt;code&gt;SELECT DATABASE()&lt;/code&gt; with native &lt;code&gt;SELECT current_database()&lt;/code&gt; and the table&amp;rsquo;s schema.&lt;/td&gt;&#10; &lt;td&gt;Use &lt;code&gt;USE app&lt;/code&gt; in MySQL and a schema-qualified name such as &lt;code&gt;app.notes&lt;/code&gt; in the native target database.&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Module missing or server refuses to start after removing a preload&lt;/td&gt;&#10; &lt;td&gt;Check the selected installation&amp;rsquo;s &lt;code&gt;pg_config --pkglibdir&lt;/code&gt;, the preload list and the startup log. A cluster can record &lt;code&gt;mysql&lt;/code&gt; in &lt;code&gt;mimus_required_features&lt;/code&gt; once it has installed MySQL objects.&lt;/td&gt;&#10; &lt;td&gt;Restore the matching kernel, module and preload. To close the port while keeping the required callbacks, restart with &lt;code&gt;mysql.listener_on=off&lt;/code&gt;. &lt;a href="https://mimus.pgsty.com/docs/patches/mysql/"&gt;Kernel checks&lt;/a&gt;&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&#10;&lt;h2 id="gaps"&gt;Unexpected results or failed restore&#10;&lt;/h2&gt;&#10;&lt;div class="td-table-scroll td-table-scroll--static"&gt;&#10;&lt;table&gt;&#10; &lt;thead&gt;&#10; &lt;tr&gt;&#10; &lt;th scope="col"&gt;Observation&lt;/th&gt;&#10; &lt;th scope="col"&gt;Check or remedy&lt;/th&gt;&#10; &lt;/tr&gt;&#10; &lt;/thead&gt;&#10; &lt;tbody&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;1264 on a large positive ID, 1366 on text, 1292 on a date or time&lt;/td&gt;&#10; &lt;td&gt;Compare the source range, raw bytes or temporal value. Convert explicitly before replay. &lt;a href="https://mimus.pgsty.com/docs/mysql/compatibility/#semantics"&gt;Type examples&lt;/a&gt;&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Unique-key conflicts differ or ordering changed&lt;/td&gt;&#10; &lt;td&gt;Run &lt;code&gt;SHOW WARNINGS&lt;/code&gt; immediately after DDL, then &lt;code&gt;SHOW CREATE TABLE&lt;/code&gt;. Compare the effective collation, key prefix and candidate duplicates. For a comparator version warning, inventory dependent indexes and partition keys before rebuilding and checking them. &lt;a href="https://mimus.pgsty.com/docs/mysql/compatibility/#collation"&gt;Collation example&lt;/a&gt;&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;A foreign-key violation persists after disabling checks&lt;/td&gt;&#10; &lt;td&gt;Check referenced-key uniqueness and the owner of each referencing table. Re-enabling checks does not repair old rows. &lt;a href="https://mimus.pgsty.com/docs/mysql/compatibility/#constraints"&gt;FK behavior&lt;/a&gt;&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;A dump contains rows, but the client exited nonzero&lt;/td&gt;&#10; &lt;td&gt;Treat the dump as incomplete. Inspect generated columns, trigger definitions and the exact client version. Oracle 5.7.32 returned 2 on the quick-start identity table with default trigger export. &lt;a href="https://mimus.pgsty.com/docs/mysql/operations/#mysql-dump"&gt;Rehearsed alternatives&lt;/a&gt;&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;&lt;code&gt;pgcmp&lt;/code&gt; installation conflicts over the &lt;code&gt;bit&lt;/code&gt; to &lt;code&gt;bytea&lt;/code&gt; cast&lt;/td&gt;&#10; &lt;td&gt;Install &lt;code&gt;pgcmp&lt;/code&gt; and &lt;code&gt;pg_mysql&lt;/code&gt; in separate PostgreSQL databases.&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&#10;&lt;h2 id="summary"&gt;Limits to account for before cutover&#10;&lt;/h2&gt;&#10;&lt;p&gt;Stored procedures through the MySQL dialect, MySQL Unix sockets, &lt;code&gt;KILL [QUERY]&lt;/code&gt;, &lt;code&gt;COM_CHANGE_USER&lt;/code&gt; and MySQL GTID replication are unavailable. Applications requiring these interfaces need changes before cutover. For consistent reporting or exclusive maintenance, use the &lt;a href="https://mimus.pgsty.com/docs/mysql/compatibility/#transactions"&gt;tested transaction behavior&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Clients and drivers</title><link>https://mimus.pgsty.com/docs/mysql/drivers/</link><guid>https://mimus.pgsty.com/docs/mysql/drivers/</guid><description>&lt;h2 id="clients"&gt;What a successful connection proves&#10;&lt;/h2&gt;&#10;&lt;p&gt;All results below used the matching Mimus 19.0.1 full kernel and &lt;code&gt;pg_mysql&lt;/code&gt; 1.0 on Rocky Linux 10 x86-64. A handshake identifies the advertised protocol. A simple query exercises parsing and one result set. An application test goes further by binding values, mutating rows, checking types and observing commit or rollback from another connection.&lt;/p&gt;&#10;&lt;div class="td-table-scroll td-table-scroll--static"&gt;&#10;&lt;table&gt;&#10; &lt;thead&gt;&#10; &lt;tr&gt;&#10; &lt;th scope="col"&gt;Client&lt;/th&gt;&#10; &lt;th scope="col"&gt;Login and query&lt;/th&gt;&#10; &lt;th scope="col"&gt;Workload actually exercised&lt;/th&gt;&#10; &lt;/tr&gt;&#10; &lt;/thead&gt;&#10; &lt;tbody&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;MariaDB &lt;code&gt;mysql&lt;/code&gt; 10.11.19&lt;/td&gt;&#10; &lt;td&gt;TCP, certificate-verified TLS, SCRAM-backed role, schema selection, &lt;code&gt;@@version&lt;/code&gt;&lt;/td&gt;&#10; &lt;td&gt;Ordinary user created a table, inserted one row and read it. Native &lt;code&gt;psql&lt;/code&gt; read the same key and text.&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;PyMySQL 1.1.1&lt;/td&gt;&#10; &lt;td&gt;Advertised version &lt;code&gt;5.7.32-log&lt;/code&gt;, &lt;code&gt;utf8mb4&lt;/code&gt;, selected schema&lt;/td&gt;&#10; &lt;td&gt;Orders workflow: parameterized insert, &lt;code&gt;lastrowid=1&lt;/code&gt;, three-row &lt;code&gt;executemany&lt;/code&gt;, aggregates and Python &lt;code&gt;Decimal&lt;/code&gt; / &lt;code&gt;datetime&lt;/code&gt; results. Updated two rows, rolled back, then counted zero rows with the new status. Missing table reported 1146.&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Go &lt;code&gt;database/sql&lt;/code&gt; + go-sql-driver/mysql 1.9.3&lt;/td&gt;&#10; &lt;td&gt;Default connection and TLS exercised&lt;/td&gt;&#10; &lt;td&gt;Server-side parameters, generated ID and row count, NULL, bytes, decimal, temporal scans with &lt;code&gt;parseTime=true&lt;/code&gt;, duplicate key 1062 and subsequent reuse. A second connection saw the write only after commit.&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;MySQL Connector/J 8.4.0&lt;/td&gt;&#10; &lt;td&gt;Preferred and required TLS, a separate RSA login and cached login&lt;/td&gt;&#10; &lt;td&gt;&lt;code&gt;useServerPrepStmts=true&lt;/code&gt;: prepare-time metadata, generated keys, BLOB/NULL, batch and duplicate-key handling. &lt;code&gt;setAutoCommit(false)&lt;/code&gt;, rollback, commit and re-enabling autocommit passed.&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Oracle MySQL &lt;code&gt;mysqldump&lt;/code&gt; and &lt;code&gt;mysql&lt;/code&gt; 5.7.32&lt;/td&gt;&#10; &lt;td&gt;Authenticated and selected the fixture schema&lt;/td&gt;&#10; &lt;td&gt;Exported and replayed supported DDL, a view, binary/generated values, a prefix PK and foreign keys. Destination was Mimus. &lt;a href="https://mimus.pgsty.com/docs/mysql/operations/#mysql-dump"&gt;Restore procedure&lt;/a&gt;&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&#10;&lt;h2 id="instance"&gt;Connect an application&#10;&lt;/h2&gt;&#10;&lt;p&gt;With the schema and role from the quick start, use TCP and pass the application schema as &lt;code&gt;database&lt;/code&gt;. This Python example prompts for the password. Set &lt;code&gt;MYSQL_CA&lt;/code&gt; to the trusted CA file or the public certificate from the loopback example.&lt;/p&gt;</description></item><item><title>SQL and type compatibility</title><link>https://mimus.pgsty.com/docs/mysql/compatibility/</link><guid>https://mimus.pgsty.com/docs/mysql/compatibility/</guid><description>&lt;p&gt;The examples on this page use an ordinary MySQL connection to a scratch schema. The native PostgreSQL connection sees the same stored rows. Parser rules, transaction boundaries and driver result types depend on the entry point.&lt;/p&gt;&#10;&lt;h2 id="dialect"&gt;SQL at the two endpoints&#10;&lt;/h2&gt;&#10;&lt;div class="td-table-scroll td-table-scroll--static"&gt;&#10;&lt;table&gt;&#10; &lt;thead&gt;&#10; &lt;tr&gt;&#10; &lt;th scope="col"&gt;Task&lt;/th&gt;&#10; &lt;th scope="col"&gt;MySQL behavior in 19.0.1&lt;/th&gt;&#10; &lt;th scope="col"&gt;Migration consequence&lt;/th&gt;&#10; &lt;/tr&gt;&#10; &lt;/thead&gt;&#10; &lt;tbody&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Create and alter tables&lt;/td&gt;&#10; &lt;td&gt;Backticks, inline &lt;code&gt;KEY&lt;/code&gt;, &lt;code&gt;AUTO_INCREMENT&lt;/code&gt;, &lt;code&gt;MODIFY&lt;/code&gt; and &lt;code&gt;CHANGE&lt;/code&gt; are handled by the dialect. Auto-increment uses a PostgreSQL identity sequence.&lt;/td&gt;&#10; &lt;td&gt;Compare the next generated value after loading explicit keys. A change to a default or generation expression deserves a write test.&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Query and join&lt;/td&gt;&#10; &lt;td&gt;Backticks, &lt;code&gt;LIMIT offset,count&lt;/code&gt;, single-target &lt;code&gt;UPDATE … JOIN&lt;/code&gt; and selected &lt;code&gt;DELETE FROM target USING …&lt;/code&gt; forms are implemented.&lt;/td&gt;&#10; &lt;td&gt;Rewrite multi-target writes and &lt;code&gt;DELETE target FROM … JOIN&lt;/code&gt; as explicit single-target operations. Compare affected rows inside the intended transaction.&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Update a duplicate key&lt;/td&gt;&#10; &lt;td&gt;&lt;code&gt;ON DUPLICATE KEY UPDATE&lt;/code&gt; checks unique keys. &lt;code&gt;REPLACE&lt;/code&gt; deletes conflicting rows and inserts a new row using column defaults. FK actions and triggers can run.&lt;/td&gt;&#10; &lt;td&gt;Use an explicit update when omitted columns or referencing rows must survive. Plain &lt;code&gt;UPDATE&lt;/code&gt; counts matched rows, including unchanged rows.&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Use a boolean or integer predicate&lt;/td&gt;&#10; &lt;td&gt;&lt;code&gt;SELECT 1 WHERE 1&lt;/code&gt; returns &lt;code&gt;1&lt;/code&gt;; inserting &lt;code&gt;1=1&lt;/code&gt; into an &lt;code&gt;INT&lt;/code&gt; column stores &lt;code&gt;1&lt;/code&gt;. Native &lt;code&gt;psql&lt;/code&gt; rejects the integer predicate (SQLSTATE 42804).&lt;/td&gt;&#10; &lt;td&gt;Write &lt;code&gt;WHERE flag &amp;lt;&amp;gt; 0&lt;/code&gt; in portable SQL. Native integer/boolean conversions require explicit casts. Some extension-provided casts and types are visible database-wide.&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Inspect or replay definitions&lt;/td&gt;&#10; &lt;td&gt;&lt;code&gt;SHOW CREATE TABLE&lt;/code&gt;, &lt;code&gt;SHOW COLUMNS&lt;/code&gt; and &lt;code&gt;SHOW INDEX&lt;/code&gt; expose MySQL-facing definitions. &lt;code&gt;information_schema&lt;/code&gt;, &lt;code&gt;SHOW STATUS&lt;/code&gt; and system variables cover a subset.&lt;/td&gt;&#10; &lt;td&gt;Replay the DDL in a scratch schema. Compare constraints and physical storage via native catalogs.&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&#10;&lt;p&gt;This example returned affected-row counts &lt;code&gt;1, 1, 2, 2&lt;/code&gt; for the four writes. The final row was &lt;code&gt;(1,9)&lt;/code&gt;: the omitted column took its default on replacement.&lt;/p&gt;</description></item><item><title>Install and connect</title><link>https://mimus.pgsty.com/docs/mysql/quickstart/</link><guid>https://mimus.pgsty.com/docs/mysql/quickstart/</guid><description>&lt;p&gt;This walkthrough uses a fresh Linux instance, a local PostgreSQL administrator and a MariaDB &lt;code&gt;mysql&lt;/code&gt; client. Install the OpenSSL command-line tool for the certificate step. Both ports must be free. At the end, the application owns one schema and can create and read its own tables. The TLS certificate below is for this loopback example.&lt;/p&gt;&#10;&lt;h2 id="build"&gt;Install the matching server and extension&#10;&lt;/h2&gt;&#10;&lt;p id="rpm"&gt;This example builds the &lt;code&gt;19.0.1-r4&lt;/code&gt; server and MySQL extension from two local repositories, &lt;code&gt;pgsty/mimus&lt;/code&gt; in &lt;code&gt;mimus/&lt;/code&gt; and &lt;code&gt;pgsty/pg_mysql&lt;/code&gt; in &lt;code&gt;pg_mysql/&lt;/code&gt;. The candidate branches are pending upload. Run the commands in Bash from their common parent directory. Have the administrator prepare a fresh &lt;code&gt;/usr/mimus-19&lt;/code&gt; prefix writable by the build user. On Debian 13 the build uses &lt;code&gt;build-essential&lt;/code&gt;, &lt;code&gt;git&lt;/code&gt;, &lt;code&gt;tar&lt;/code&gt;, &lt;code&gt;bison&lt;/code&gt;, &lt;code&gt;flex&lt;/code&gt;, &lt;code&gt;perl&lt;/code&gt; (including FindBin), &lt;code&gt;pkg-config&lt;/code&gt;, &lt;code&gt;libicu-dev&lt;/code&gt;, &lt;code&gt;libssl-dev&lt;/code&gt;, &lt;code&gt;libreadline-dev&lt;/code&gt; and &lt;code&gt;zlib1g-dev&lt;/code&gt;.&lt;/p&gt;</description></item></channel></rss>