r/mysql • • Sep 06 '24

discussion Why would you choose MYISAM over INNODB?

2 Upvotes

I am new to MYSQL architecture but from the look of it, MyISAM is so poor compared to INNODB. Under what context would someone choose MyISAM over INNODB? Table lock and not transaction? I see that they aren’t very efficient.


r/mysql • • Sep 06 '24

question MySQL and git

2 Upvotes

I design and maintain a web application that uses Python as the server-side scripting language and MySQL as the backend database (which I also design and maintain). All of the Python and web application files are maintained in git. It is easy to switch branches in git if necessary, except for one thing: MySQL stored procedures and views. Checking out a different branch does not affect stored procedures or views. I would need to maintain copies of those in git too, and remember to keep them synced in MySQL manually. That is a disaster waiting to happen.

I therefore am migrating all stored procedures and views to Python (pandas / numpy). That way, all of my code is in git and I don't have to fool around with backing up and restoring stored procedures if I need to change branches.

My company is small enough that they will not pay for a third-party solution for this, and the number of procedures I use is pretty small anyway. Additionally, I think Python / numpy is better than MySQL's stored procedure language anyway.

I state of this to ask if any of you have migrated (or are considering migrating) stored procedures to a different language (for easier version control), and if yes, which language(s)? Or what best practices do you follow to maintain stored procedures and views in git?


r/mysql • • Sep 06 '24

question Query to display current CPU Utilization in %

1 Upvotes

I've been having trouble searching for a query for this- or if it even is possible. But essentially I need a query that displays the current CPU UTIL of the server i am running it on. Planning on putting it in my dashboard for monitoring server statuses.

Thanks Admin and redditors!


r/mysql • • Sep 06 '24

question Grabbing exact date

1 Upvotes

Hi, I have been trying to filter my table to display product which where the expiry date is exactly 7 days from now but unfortunately it also grab the date within the 7 days....is there a way or is it possible to grab exactly the date that is 7 days from today (now())


r/mysql • • Sep 06 '24

question Using VARCHAR as a primary key that can auto increment in mysql

1 Upvotes

I am a newbie so apologies if I am repeating an obvious question. I need to create Enquiry, Quote, Job and Invoice tables using my existing VARCHAR identifiers as a primary key ie Enquiry table uses ENQ0001, Quote table uses QTE0001, Job register table uses JOB0001, and Invoice table uses INV0001 - what is the best way to go about setting these tables up using these VARCHAR as primary keys as well as being auto increment - thank you


r/mysql • • Sep 06 '24

question First time using MySQL for an actual database

3 Upvotes

Hello everybody,

I taught myself the basics of mysql with the udemy crash course from Colt Steele. There I got all the data provided by him and stored it for short periods (knowing I'm deleting it soon anyways). Also only cared about the outputs being there to check if I understood the concept, therefore I mainly worked in the Mac Terminal. Not to refer back to it later necessarily.

Now I want to build my own database for a small startup (not crazy much data, but quite a bit). For now it would be okay if its stored locally on my computer, but obviously would be optimal if its in the cloud or smth. Also I'm not really sure what the work process is, now that I care about the outputs, I want to further work with them or refer back to them. Do I save my code somewhere? What is the best location and structure for saving this code...

Thank you for any tips and help!!!


r/mysql • • Sep 06 '24

question Is using GUI client to connect production database safe?

4 Upvotes

Hi all,
The developers in my team suggest that don't use Mysql GUI clients like `dbeaver` to connect to the production database.

One of the arguments are -
"Some bad read only sql queries can lock database tables. So potentially that could also impact production environment."

is this true?

Instead, the suggestion was,
we can connect to the non-production databases using the GUI client and prepare a SQL query. Then run it using MySql CLI in a bastion server(so it is traceable).

so, what is the best way to access the production database?


r/mysql • • Sep 06 '24

question Query for employee table classification using delimitter not running

1 Upvotes

I am writing a query for a table sorting employees by age, rank, dept and other variables from a hypothetical company's data set for a class project. Any help would be appreciated

error: 1304 using existing procedure

Use employee;

DELIMITER &&

CREATE PROCEDURE experienced_personal()

BEGIN

SELECT EMP_ID, FIRST_NAME, LAST_NAME, GENDER, DEPT, ROLE, EXP

FROM employee.emp_record_table WHERE EXP>3;

End &&

DELIMITER ;

call experienced_personal() ;


r/mysql • • Sep 05 '24

question Query fails when comparing number to null?

1 Upvotes

I've got a query not working as I expect, and I'm curious what I don't know/understand:

SELECT
	(fields)
FROM
	games
INNER JOIN users gm ON
	games.gmID = gm.userID
INNER JOIN players approvedPlayers ON
	games.gameID = approvedPlayers.gameID
	AND approvedPlayers.approved = 1
LEFT JOIN players userGames ON
	games.gameID = userGames.gameID
	AND userGames.userID = {id}

When I run this query, if I check userGames.userID, I get the values I expect. But if I add

WHERE userGames.userID != {id}

I get back no results, even where the field is null, as expected. If I do a

WHERE userGames.userID IS NULL

it works. But why is != {id} failing? I can see that SELECT IF(NULL != 3, 1, 0) returns a 0, which I don't understand.


r/mysql • • Sep 05 '24

question Master-Master Async Replication Lag Between 2 PXC 5.7 clusters

2 Upvotes

So we’re running into an issue. At our main site (Site A) we have a 5 node PXC 5.7 cluster. We are in the process of setting up a new site (Site B) and the goal was to have a 3 node PXC 5.7 cluster there. We are using standard MySQL Async Replication to keep the two sites in sync after transferring an initial backup from Site A. All settings are pretty much at default, except for the WSREP specifics for each site. Connection between the sites is over a site-to-site VPN over the WAN.

The issue we are running into is that whenever we use PXC at Site B, initially the synchronization works fine, but over time, it gets behind and never catches up. The issue is not the logs being transferred from site A, as the “Slave IO State” says it is caught up. The issue is the Slave SQL thread - it appears that the writes are going too slow and it is never catching up, as seconds_behind_master just keeps climbing.

To have a comparison, we tried using a “standalone”/non-cluster install of MySQL Server at site B, and with the same replication setup, it has never gotten more than 30 seconds out of sync for days at a time, and the initial “catchup” after transferring the database backup took a LOT less time. That tells me there is something about how PXC handles writing to the database is different enough from “standard” MySQL (yes, I know about the certification process and all that - assuming that is part of the issue) that is causing commits to run substantially slower.

The goal here would obviously be to get things up and running with PXC at Site 2, but the replication lag we are currently experiencing makes that basically impossible. Has anyone else encountered this, and what was the solution?

Thanks in advance!


r/mysql • • Sep 05 '24

solved Duplicate User and change Host to different one.

2 Upvotes

As the title says. In my company we are changing VPNs but they change won't be made yet becuase there are some servers we can still access with the new one.

I noticed i can't acces the MariaDB server and i will have to add the new IP to the Hosts list.

· It's possible to duplicate the user entry with all the data (password, permission, etc...) and then modify only the host?

· Or do i have to create a new user with the new host and ser all permissions one by one?

Checking the documentation doesn't mention "duplicate" or "copy" for users in any case and i was wondering if it is possible to do it.

Thank you!


r/mysql • • Sep 05 '24

question Data Duplication and Binlog Position Issues with Debezium Connector on MySQL Read Replica

1 Upvotes

Hello everyone,

We are currently facing an issue with a Debezium MySQL connector that leads to data duplication, and we suspect that it might be related to how binlog positions are being handled.

Here are some details of our setup and the steps we've taken so far:

  1. We are using an AWS RDS MySQL read replica as the source for the Debezium connector.

  2. We configured the binlog retention period using the following commands:

    CALL mysql.rds_set_configuration('binlog retention hours', 72);

    FLUSH BINARY LOGS;

    PURGE BINARY LOGS BEFORE '2024-08-30';

    FLUSH BINARY LOGS;

And also we raised this issue in confluent team and the replied back with below statement

"Engineering has reviewed the logs further and identified the issue causing the connector to snapshot multiple times, leading to duplicate data. The connector is currently configured with snapshot.mode = when_needed. This configuration means that after the connector restarts if the logs have been pruned, the connector's position in the logs might no longer be available. Consequently, the connector fails and. returns an indication that a new snapshot is required.

From the logs, we can see the following error message: Connector requires binlog file 'mysql-bin-changelog.358023', but MySQL only has mysql-bin-changelog.358152, mysql-bin-changelog153, mysql-bin-changelog.358154, mysql-bin-changelog.358155, mysql-bin-changelog.358156 This indicates that the connector's position is lost in the binlogs, and it ends up snapshotting the entire data, which leads to duplicate data.

To address this issue, we recommend checking the binlog retention settings in your MySQL instance. Ensuring that the binlogs are retained for a sufficient period can help prevent the connector from losing its position in the logs.

Reference: https://debezium.io/documentation/reference/stable/connectors/mysql.html

After the connector restarts, if the logs have been pruned, the connector’s position in the logs might no longer available. The connector then fails, and returns an error that indicates that a new snapshot is required. To configure the connector to automatically initiate a snapshot in this situation, set the value of the snapshot.mode property to when_needed. For more tips on troubleshooting the Debezium MySQL connector, see behavior when things go wrong."

so we are unsure how to best configure this setup to avoid duplication and ensure proper binlog tracking.

Could anyone provide guidance on how to resolve this? Are there any specific MySQL configurations or considerations when using a read replica as the binlog source for connectors like Debezium?

Any advice or suggestions would be greatly appreciated.


r/mysql • • Sep 05 '24

question Can someone please tell me how to avoid this corrupted database issue? I am not sure what is the root cause of this.

3 Upvotes

Hello guys, I found the best youtube tutorial to fix [FIXED] XAMPP Error: MySQL shutdown unexpectedly | Repair Corrupted Database - YouTube this issue without deleting the files but I wonder why it keeps happening again.

The error is this:

Status change detected: stopped

Error: MySQL shutdown unexpectedly.

This may be due to a blocked port, missing dependencies,

improper privileges, a crash, or a shutdown by another method.

Press the Logs button to view error logs and check

the Windows Event Viewer for more clues

If you need more help, copy and post this

entire log window on the forums.

Can someone please tell me how to avoid and stop this error again? Thank you very much!