🛠 How to Restore MySQL Database from Backup in XAMPP If you're trying to restore your MySQL databases from a backup using XAMPP, follow these steps carefully: 📁 Step 1: Rename the Existing data Folder First, you’ll want to rename the current MySQL data directory to keep a backup of it: bas rename mysql/data to mysql/data_old Or manually: Navigate to C:\xampp\mysql . Rename the data folder to data_old . 📂 Step 2: Copy the Backup Folder Now, copy your backup folder and rename it to data : mysql/backup to mysql/data Manually: Copy the entire backup folder located in C:\xampp\mysql . Paste it inside the same mysql directory. Rename the copied folder to data . 📄 Step 3: Copy Database Folders and MySQL System Folder Next, copy your actual databases and the mysql system folder from the old data directory to the new one: Go to C:\xampp\mysql\data_old . Copy all your custom database folders (except performance_schema , phpmyadmin , etc.). Also copy the my...
A trick for using LAST_INSERT_ID() to generate sequences in MySQL. Quoting from the Manual: Create a table to hold the sequence counter and initialize it: mysql> CREATE TABLE sequence (id INT NOT NULL); mysql> INSERT INTO sequence VALUES (0); Use the table to generate sequence numbers like this: mysql> UPDATE sequence SET id=LAST_INSERT_ID(id+1); mysql> SELECT LAST_INSERT_ID(); This trick calls for trouble. Contention A customer was using this trick to generate unique session IDs for his JBoss sessions. These IDs would eventually be written back to the database in the form of log events. Business go well, and one day the customer adds three new JBoss servers (doubling the amount of webapps). All of a sudden, nothing works quite as it used to. All kinds of queries take long seconds to complete; load average becomes very high. A short investigation reveals that a very slight load is enough to make for an accumulation of sequence-UPDAT...