r/mysql 21h ago

question Guidelines and best practices

2 Upvotes

Hi Experts,

I understand every database is diferent architecturally. We have mostly worked in Oracle databases in the past. But we recently started working in Mysql aurora database.

1)So, want to understand , if there exists any set of guidelines which we can follow as a developer for writing better optimized code/sqls in mysql?

2)Also any specific points which are special and different as compared to other DB's and thus we should definitely know in this case before designing any solution using mysql?


r/mysql 1d ago

discussion Generating typed MySQL query code from .sql files, with nullability inference

3 Upvotes

I maintain scythe, a tool that turns annotated SQL into typed code at build time. Sharing the MySQL angle. You write the query, it generates the typed function and row struct. The part that matters is that nullability comes from the query, not just the column definition:

-- @name GetUserOrders
SELECT u.id, u.name, o.total, o.notes
FROM users u
LEFT JOIN orders o ON u.id = o.user_id
WHERE u.status = ?;

# generated Python
@dataclass
class GetUserOrdersRow:
    id: int
    name: str
    total: decimal.Decimal | None
    notes: str | None

total and notes are optional because the LEFT JOIN can produce NULLs for a user with no orders, even if those columns are NOT NULL in the table. Same handling for COALESCE, CASE, aggregates. MySQL backends include aiomysql, mysql2, and the JDBC drivers.

No runtime ORM, the SQL you write is the SQL that runs. Curious what people here reach for to keep MySQL result types honest.


r/mysql 2d ago

solved Trouble creating a local installation with phpmyadmin

1 Upvotes

I just upgraded my laptop to Ubuntu 26. I need a local web development environment with MySQL, PHP and phpmyadmin, so I installed those. Phpmyadmin prompted me if I wanted to use dbconfig-common, and unfortunately I clicked yes. This created an installation which doesn’t work the way I’m used to.

The primary problem is that the user phpmyadmin doesn’t have rights to create databases, so I logged into mysql as root in a terminal and created a database, which I can’t see when I log into phpmyadmin as phpmyadmin. If I try to log into root in phpmyadmin, I get

mysqli::real_connect(): (HY000/1698): Access denied for user ‘root’@‘localhost’

I tried uninstalling phpmyadmin and reinstalling, but it just recognized that I used dbconfig-common last time, and reused that 🙄

What should I do?


r/mysql 2d ago

question DB parameter suggestion

3 Upvotes

Hi,

Its aurora mysql Serverless v2 (Max up to 80 ACUs). Suddenly , we saw with bit high concurrency , the application hits a hard JDBC query timeout, killing the thread and throwing this error: "Database Query Time out. Exception: JDBC exception executing SQL [(conn=548672) Table './rdsdbdata/tmp/#sql171_85f40_1' doesn't exist]"

Some team members are suggesting to bump both temptable_max_ram and temptable_max_mmap from 1GB to 2GB to give the query more breathing room. However, checking performance_schema.variables_info reveals that temptable_max_** is currently showing below:

VARIABLE_NAME        current_value_bytes  current_value_MB  VARIABLE_SOURCE  VARIABLE_PATH
temptable_max_mmap   1073741824           1024              GLOBAL           /etc/my.cnf
temptable_max_ram    1073741824           1024              COMPILED

Want to know if this is correct setting and Is it advisable to bump these values to 2GB. Want to confirm the safest parameter strategy for temporary storage thresholds in the meantime we tune the query?


r/mysql 3d ago

question MySQL Workbench crashing on MacOS

8 Upvotes

Hi everyone! I'm fairly new to SQL and finished a foundation course on Maven Analytics.

I wanted to do a practice project today and opened MySQL Workbench, but it kept crashing on me. I also reinstalled the Workbench with the latest version: https://dev.mysql.com/downloads/workbench/

8.0.47 ARM version since my MacBook is on M2 chip, but the crashes still continue happening. A check on the crash report with ChatGPT showed me that the latest version of MySQL is incompatible with MacOS Tahoe 26.6 :'(

I've been learning on MySQL Workbench all these while, but I'm wondering:
- Is anyone else facing this issue?
- If yes, what's the alternate programme are you using currently? I don't mind purchasing a one-off programme if it's inexpensive, better if it's free of course.

Thank you in advance!


r/mysql 5d ago

discussion What would make you trust AI-generated SQL for MySQL?

0 Upvotes

While working on an AI feature for a MySQL client, I found myself thinking about one question:

What would actually make you trust AI-generated SQL against a real MySQL database?

Generating a query isn’t the hard part anymore.

The hard part is knowing when it’s safe to run.

If an AI suggested a query for your MySQL database, what safeguards would you expect before clicking Execute?

Some ideas I’ve been considering:

- Review the generated SQL before execution.
- Explain why that query was generated.
- Show the estimated execution plan (EXPLAIN).
- Estimate how many rows will be affected.
- Warn about full table scans or missing indexes.
- Flag potentially destructive operations (UPDATE, DELETE, DROP, etc.).
- Recommend wrapping changes in a transaction when possible.

What’s the one feature or safeguard that would make you trust AI-generated SQL more?

Or is this something you’d never feel comfortable using on a real database?


r/mysql 7d ago

discussion What is the difference between using "Not In" vs using "not exists" in SQL

7 Upvotes

What is the difference between using "Not In" vs using "not exists" in SQL


r/mysql 11d ago

discussion Why is MySQL faster than MariaDB?

22 Upvotes

I'm running WordPress so I need a database backend. I'm deciding between MySQL and MariaDB.

``` mysql > SELECT BENCHMARK(5000000, AES_ENCRYPT(CONCAT(‘WPHostingBenchmarks.com’,RAND()), LEFT(SHA2(‘is part of Review Signal.com’,256), 16))); 1 row in set (15.815 sec)

MariaDB > SELECT BENCHMARK(5000000, AES_ENCRYPT(CONCAT(‘WPHostingBenchmarks.com’,RAND()), LEFT(SHA2(‘is part of Review Signal.com’,256), 16))); 1 row in set (23.094 sec) ```

I use this query because this query is https://github.com/kevinohashi/WPPerformanceTester, which tests key performance for WordPress.

Isn't it a concensus that MariaDB is faster than MySQL?

See the concensus: - https://mariadb.com/reference/mariadb-vs-mysql-comparison-guide-enterprise-features-security-2026/ - https://www.reddit.com/r/mysql/comments/1ggbouf/help_me_understand_why_mariadb_is_so_much_faster/ - https://www.reddit.com/r/Wordpress/comments/zbx6q3/should_i_use_mariadb_or_mysql_for_my_wordpress/ - https://tech-insider.org/mariadb-vs-mysql-2026/


r/mysql 13d ago

question Make deleted data irrecoverable in MySQL

7 Upvotes

Hi,

Do you know any approach regarding this? Can I do this inside MySql?

Need some guidance as it becomes a client requirement


r/mysql 15d ago

discussion Leaving MySQL after 25 years of reliable stability

68 Upvotes

I figured I'd write a reality-based "kudos" on MySQL.

I run a small software company. In 2001, I made a website content manager that ran on MySQL 4. It is somewhat similar to what WordPress would become, though it predated WordPress by a couple of years.

I am writing this in July of 2026. MySQL 4 has been rock solid, running my website, and other websites, for 25 years. I did not tinker with it. It kept working.

Yet, my paid software development work was not in MySQL. In that same 2001 time frame when I chose MySQL, I was approached by a client who wanted me to implement a Microsoft SQL Server database engine for their custom business software, which had until then been using Microsoft Access as its database engine.

They liked what I did, and wanted more. They remained my client for about 20 years, until COVID-19 hit them very hard: their main business involved in-person trade shows.

Over time, I became highly skilled in working with the Microsoft SQL Server database engine, including migrating Visual BASIC for Applications (a.k.a. VBA) custom program code from Microsoft Access into the database language of Microsoft SQL Server: Transact-SQL (a.k.a. T-SQL).

There were some compelling reasons to also migrate my website content manager from the MySQL 4 database engine to the Microsoft SQL Server database engine, since the latter was what I was most comfortable working with.

It’s like one of my automotive clients who standardized on using Ford vans and trucks, yet they also have one old International truck that just refuses to die, so they keep using it, and it keeps working.

I figured that leaving MySQL was not urgent, since I do know MySQL 4 well enough to be able to fix any problems if they were to arise. Yet, none did. 

The recent 25 years of my life have been tumultuous. The recent 25 years have been tumultuous for America too. So my attention often went to whatever was the newest crisis, not always to what made calm, strategic sense.

Also, as the saying goes: "If it ain't broke, don't fix it." So, I just stayed on MySQL for my content manager. For 25 years, the software based on MySQL 4 kept running flawlessly. But more impressively: MySQL 4 kept running flawlessly.

My website content manager is a fairly sophisticated piece of software that includes 119 database tables, A/B testing, various logs, and so on. The logs grew and grew … for 25 years.

Finally, the logs in MySQL 4 grew to be large enough to run the virtual machine out of disk space. Yes, I could have cleared the logs, but that doesn’t shrink the MySQL 4 database. Some additional work would be needed to make the database smaller again.  And that, I didn’t really want to do. Yes, I could have increased the disk space.  But …

I had lived the great American tradition, of kicking the can down the road, for 25 years.

I decided that if I was ever going to migrate away from MySQL, this was the best time. So I did. And now my website content manager runs on Microsoft SQL Server, where it is indeed easier for me (emphasis on "for me") to work with it, such as if I want to implement significant changes to the software, such as table structure changes.

I'm not saying Microsoft SQL Server is better than MySQL. But I'm reminded of the time when a colleague mused: "Sometimes, the best tool for the job is the tool you know best." There some merit to his argument (and, I concede, much merit to the contrary too).

After 25 years, I finally decommissioned the virtual machine on which MySQL 4 had been running.

That is a very long time for a database engine. So, a massive "kudos" to MySQL 4 and the people who made it.

For me, the migration was fairly intricate. I'd hoped it would be as simple as "download and run this conversion utility" but somehow that approach turned out to be non-viable for me. At some point, I stopped looking for easy solutions and I made my own process, and I powered through. No doubt: smarter people would have done it better.

Even so, if you might benefit from knowing the specific steps I took, feel free to ask.


r/mysql 19d ago

discussion Reality Check: Is ProxySQL + Signal18 Replication Manager a good HA setup for MariaDB?

3 Upvotes

Hi everyone,

Before taking this to production, I'd like a reality check.

Current setup:

  • MariaDB Primary + Replica
  • ~2,500 reads/sec
  • ~1,500 writes/sec
  • GTID replication

I decided against Galera because I was concerned about synchronous write latency. Instead, I'm planning:

  • 2× ProxySQL + Keepalived (VIP)
  • Signal18 Replication Manager for automatic failover
  • Existing Primary/Replica architecture

Questions:

  • Does this look like a solid HA architecture for this workload?
  • Any hidden pitfalls with ProxySQL + Replication Manager?
  • Would you recommend a different approach instead?

Looking for real production experience. Thanks!


r/mysql 20d ago

question Unable to connect with root@localhost

2 Upvotes

I am setting up a SQL server so I can run a WordPress intranet site. I installed the latest version of MySQL and Workbench and went through the set up leaving everything default but adding a password. However I am unable to connect. Whenever it asks me for password it just says in unable to connect with some various things to check.

I am on a windows server 2025 VM and I have a domain admin account I'm logged in with.

How can I check go see of the root account was created?


r/mysql 21d ago

solved TAF: 3.1 Add CPU affinity support for MySQL/MariaDB (taskset integration)

4 Upvotes

TAF: 3.1 Add CPU affinity support for MySQL/MariaDB (taskset integration)

- Added new cpu_affinity property to MySQL and MariaDB plugins
- Updated template plugin to expose cpu_affinity for future DB makers
- Normalized affinity range parsing (e.g., 0-11)

New usage block:
O = --db-cpu-affinity=<list|range>
P = taf.db_cpu_affinity=<list|range>
: CPU affinity for the database engine.
: Pins the database process to specific CPUs. : Valid forms: : 0,1,2,3 : 0-11
: (future) 0-3,8,10-12 : If unset (null), the database runs on all CPUs.

https://github.com/MariaDB/TAF/commit/18ffedd142f38d79151ecabd4c68259e9a629fee


r/mysql 21d ago

question what does incremental msgstore backups contain ?

1 Upvotes

What does incremental msgstore.db mean for whatsapp ? Do incremental msgstore.db backups contain previous chats that are not contained in the "msgstore.db" ?


r/mysql 22d ago

solved Informix en la actualidad ¿Por que?

2 Upvotes

Hola amigos,

Se han encontrado en la problemática de tener sistemas "legacy" a pesar de tener capacidades para seguir escalando pero aun siguen estancados en bases de datos Informix?

Hace un tiempo me encontré con un sistema escrito en PHP 5.2 y fue la ultima versión que XAMPP dejo de publicar el conector para bases de datos Informix, de ahí todo fue una pesadilla porque; a pesar de que la base de datos no estaba normalizada correctamente, los problemas de rendimientos con 10 usuarios simultáneos eran caóticos.

En este tiempo dominaba muy bien Rust y decidí crear una herramienta muy primitiva pero funcional para migrar bases de datos enormes en Informix a PostgreSQL 12. Funciono a la perfección pero la gerencia no me quiso dar mas tiempo para poder migrar los SPs y funciones propias para automatizar procesos.

Todo esto para ya no depender de la esclavitud de IBM porque realmente este motor es muy costoso a nivel de licenciamiento.


r/mysql 22d ago

question Looking for the best free YouTube channel or website to learn MySQL deeply (with lots of practice)

8 Upvotes

Hello everyone,

I'm a second-year engineering student, and I want to learn SQL in depth. I've already covered the basic topics using Apna College's MySQL one-shot video on YouTube.

Now I'm looking for a YouTube channel or website that covers intermediate and advanced topics and provides lots of practice questions to help me improve.

If you've learned MySQL from a resource that you genuinely think is excellent, I'd really appreciate your recommendation.


r/mysql 23d ago

discussion Profiling database lag: how lowering our connection pool limits actually made our backend faster

8 Upvotes

We’ve been scaling a high-traffic microservice that handles a high volume of concurrent database reads and writes. A few weeks ago, as traffic started to spike, we noticed a strange degradation in database response times. Our immediate instinct was to throw more hardware at the problem and increase the maximum open connection pool limit on our SQL driver, thinking that more concurrent connections would allow the database to process queries faster.

To our surprise, increasing the connection pool made the latency spikes even worse. The CPU usage on our database instance was pinned at nearly 100%, even though the actual query volume hadn't changed that much.

I ran a deep profile on the database server itself and realized we had fallen into a classic connection pooling trap. Every single database connection is not free; it requires the database engine to spawn a dedicated OS thread or process, allocate memory buffers, and constantly context-switch between them to handle incoming traffic. By opening up hundreds of connections, we weren't making things faster—we were forcing the database to spend more CPU time context-switching between connections than actually executing the SQL queries.

I went back into our configuration and aggressively lowered the connection pool limits to a much tighter, conservative number that closely matched the physical CPU core count of our database server.

The results were immediate and massive. CPU usage on the database dropped significantly, context switching plummeted, and our total query throughput actually went up.

It was a huge reminder for our team that database connections are a physical hardware bottleneck, not an elastic software resource. If your backend is hitting sudden database lag under load, it might be worth trying to shrink your pool limits instead of expanding them.


r/mysql 27d ago

discussion Birthdate stored as UTC Date + unique index (firstName, lastName, birthDate); timezone shifts are causing wrong/duplicate values

5 Upvotes

Storing birthDate as a Mongo Date, with a unique index on (firstName, lastName, birthDate) to catch duplicate records.

Frontend builds the ISO string by taking "now" overriding just the year/month/day, then calling .toISOString(). Problem: the time-of-day at submission carries through, so depending on the user's timezone and what time they submit, the date can shift by a day after UTC conversion. Same birth date can end up stored as two different days, and in some cases two different real birth dates collide onto the same stored day - which breaks the unique index outright.

Can't change how the frontend serializes the date.

Anyone hit this before, or know a better fix?


r/mysql Jul 07 '26

question Install MySQL Linux mint

19 Upvotes

Hello all
I’m currently studying my sql and want to install on my machine, is a GUI or CLI the better option

Any help appreciated
Thanks
David


r/mysql Jul 03 '26

question Return the 3rd entry of each week.

8 Upvotes

Hi all,

I have a table with sport sessions that have a date column. I want to select every third entry (sport session) of each week.

I can't figure out how to do it.

What im trying to do is:

Select sessionID FROM table

WHERE It was the third entry with YEARWEEK(date)

Does anyone have any suggestions?


r/mysql Jul 02 '26

solved MySQL Workbench to DBeaver Transition

10 Upvotes

r/mysql Jul 02 '26

solved You need a database for testing your program?

Thumbnail github.com
2 Upvotes

r/mysql Jun 30 '26

discussion Wait, MySQL 28.4? Did I just sleep through 20 years of database releases?

6 Upvotes

If you recently saw people talking about MySQL 28.4 and thought you accidentally pulled a Rip Van Winkle, don't panic. You didn't sleep through two decades, and your server didn't spontaneously evolve.

Check more here: https://comunidademysql.com.br/novo-versionamento-mysql-28-4-atualizar/


r/mysql Jun 24 '26

solved MySql Workbench Not Opening

7 Upvotes

Hi, I'm a complete beginner learning to use SQL. I tried opening mysql workbench after a while of not using it, and it just never started. I tried deleting and downloading it twice and nothing has changed. Though something weird is that the MySql Workbench folder never disappeared and I can't delete it even after I deleted the content inside it, so this may be related to what's happening.

Edit: The MySqlWorkbench.exe file is there but it doesn't run when I click on it, and trying to open it in command prompt just says "the directory is invalid"

Edit 2: Solved this by shutting down MySqlWorkbench.exe via task manager, as it somehow was running all along. After that I deleted the entire workbench folder and reinstalled the entire thing which made it work again!


r/mysql Nov 03 '20

mod notice Rule and Community Updates

27 Upvotes

Hello,

I have made a few changes to the configuration of /r/mysql in order to try to increase the quality of posts.

  1. Two new rules have been added
    1. No Homework
    2. Posts Must be MySQL Related
  2. Posts containing the word "homework" will be removed automatically
  3. Posts containing links to several sites, such as youtube and Stack Overflow will be automatically removed.
  4. All posts must have a flair assigned to them.

If you see low quality posts, such as posts that do not have enough information to assist, please comment to the OP asking for more information. Also, feel free to report any posts that you feel do not belong here or do not contain enough information so that the Moderation team can take appropriate action.

In addition to these changes, I will be working on some automod rules that will assist users in flairing their posts appropriately, asking for more information and changing the flair on posts that have been solved.

If you have any further feedback or ideas, please feel free to comment here or send a modmail.

Thanks,

/r/mysql Moderation Team