iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
Move a MySQL data directory by making a tested backup, shutting the server down cleanly, copying the complete directory to a mounted destination, changing the active datadir setting, updating security policy and any related paths, then starting and validating the same instance. Do not start MySQL until the destination mount is present: an empty mount point can be mistaken for a new data directory and trigger initialization.
What a MySQL data-directory move changes
The data directory is more than a collection of database folders. It normally contains InnoDB system and redo files, table files, binary or relay logs that are configured there, certificates and keys, the server PID file, mysqld-auto.cnf, and metadata needed by the existing instance. Changing datadir changes where MySQL looks for that complete set of files.
A successful relocation preserves the existing instance: databases, tables, users, grants, server metadata and storage-engine files remain intact. It does not, by itself, move files whose settings point elsewhere. Before copying, record separate locations for the error log, general and slow query logs, socket, PID file, binary logs, relay logs, temporary files and any InnoDB data or undo locations.
Choose the migration method before scheduling downtime
| Method | Consistency and downtime | What it preserves | When it fits |
|---|---|---|---|
| Clean shutdown and filesystem copy | Consistent when the server is stopped cleanly; downtime covers shutdown, copy and validation. | The existing data directory, users, tablespaces, server metadata and files stored under it. | The normal choice for moving the same MySQL installation to another local disk or mounted volume. |
| Logical dump and restore | Downtime depends on dump and restore duration; consistency is controlled by the dump procedure. | Logical schema and row data. Physical files, tablespace layout and some server metadata are recreated rather than copied. | Cross-version or cross-platform migrations where a physical copy is unsuitable. |
| Storage-level snapshot | Can reduce downtime, but only a crash-consistent or application-consistent snapshot is safe for the chosen storage system. | Whatever the storage snapshot includes; separate log or mount volumes must be coordinated. | Large data sets on storage that provides a tested, consistent snapshot and a reliable rollback. |
The procedure below follows the official MySQL approach for copying an existing data directory. A snapshot or logical migration needs its own consistency and recovery procedure; do not combine those methods casually with a live file copy.
#1 Best Overall
- Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
- With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
- Wide Application: attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
- Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
- Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.
Inventory the running instance
Do this while the current server is still healthy. The goal is to change the configuration that the service actually uses, not an unused example file.
Find the effective data directory and service
- Connect with an administrative client and run:
SHOW VARIABLES LIKE 'datadir';
SHOW VARIABLES LIKE 'basedir';
SHOW VARIABLES LIKE 'log_error';
SHOW VARIABLES LIKE 'socket';
SHOW VARIABLES LIKE 'pid_file';
SHOW VARIABLES LIKE 'log_bin';
SHOW VARIABLES LIKE 'relay_log';
SHOW VARIABLES LIKE 'innodb_data_home_dir';
SHOW VARIABLES LIKE 'innodb_undo_directory';
Some variables can be empty, use relative paths, or point outside the data directory. Record the values exactly. Also note the MySQL version, the operating-system account that runs mysqld, and whether more than one instance is installed.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteIdentify option-file order
MySQL reads option files in a platform- and installation-dependent order. Inspect the service definition and the process command line to see which files are loaded. On Unix-like systems, useful checks include:
systemctl cat mysql # Debian-family service name may be mysql
systemctl cat mysqld # RPM-family service name is commonly mysqld
ps -ef | grep '[m]ysqld'
my_print_defaults mysqld
Use the service name that exists on your host. Common locations are an included file below /etc/mysql/ on Debian-family systems and /etc/my.cnf or an included file below /etc/my.cnf.d/ on RPM-family systems. Edit the file that is active for the [mysqld] group; changing a dormant sample file has no effect.
List every path that may need changing
datadirand any relative paths resolved from it.- Error, general, slow-query and audit-log locations.
socket,pid-file, binary-log and relay-log paths.- InnoDB system tablespace, undo tablespace, temporary tablespace and file-per-table locations.
- TLS certificates, keys, plugin directories and other files protected by the same security policy.
The MySQL manual requires pathnames to be changed when an existing directory is copied. A move that changes only datadir can leave the server looking for logs or tablespace files in the old location.
Prepare a safe, mounted destination
Make and test a recovery copy
Take a backup or storage snapshot appropriate to your installation before touching the original. A backup is useful only if you can restore it, so verify that it contains representative databases and that your restore process is documented. Keep the original directory unchanged until the new instance has passed database and application checks.
Verify the destination mount
Create the destination on the filesystem intended to hold the data, and verify that it is mounted before stopping the server. For example:
Rank #2
- Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
- Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
- Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
- Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
- Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth
findmnt /srv/mysql-data
mountpoint /srv/mysql-data
df -h /srv/mysql-data
Replace the example path with your actual mount. If the command shows no expected device, stop and fix the mount or its boot-time dependency. A systemd-managed package can see an empty directory at an absent mount point and initialize it as a fresh data directory. Where the package supports it, the documented NO_INIT=true setting suppresses that automatic initialization behavior; it does not replace checking the mount yourself.
Plan ownership and access
On Unix, the files must be owned by the account running mysqld, normally mysql. Every parent directory also needs execute (traverse) permission for that account. Preserve symbolic links, modes, timestamps, hard links where applicable, ACLs and extended attributes required by your platform.
Move the directory on Linux
1. Stop the correct service cleanly
Use the service name identified during inventory:
sudo systemctl stop mysql
# or
sudo systemctl stop mysqld
sudo systemctl is-active mysql
sudo systemctl is-active mysqld
A clean shutdown is mandatory because MySQL must flush pending changes before the files are copied. Confirm that no server process remains:
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →pgrep -a mysqld
If a process is still running, do not copy the directory. Investigate the service, its alternate instance, or a failed shutdown first.
2. Create and verify the destination
sudo mkdir -p /srv/mysql-data
findmnt /srv/mysql-data
sudo chown mysql:mysql /srv/mysql-data
Do not start MySQL between the mount check and the copy. If the destination is a remote filesystem, confirm that its locking, latency and durability characteristics are supported; NFS in particular introduces file-locking and performance risks and is unsuitable for many deployments.
3. Copy the complete stopped directory
With the source server stopped, copy its contents, not merely the visible database subdirectories. A typical Linux copy is:
sudo rsync -aHAX --numeric-ids /var/lib/mysql/ /srv/mysql-data/
Replace /var/lib/mysql/ with the recorded source and keep the trailing slash semantics shown. If rsync is unavailable, an archive-preserving copy such as cp -a /var/lib/mysql/. /srv/mysql-data/ can be used, followed by an explicit ownership and attribute check. Copy files on every related path when logs, binary logs, relay logs or InnoDB files are outside the source directory.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #3
- 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
- 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
- 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
- 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
- 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
Check the result before changing configuration:
sudo find /srv/mysql-data -maxdepth 1 -mindepth 1 -printf '%fn' | sort
sudo stat -c '%U:%G %a %n' /srv/mysql-data
sudo du -sh /var/lib/mysql /srv/mysql-data
The sizes need not match byte-for-byte when sparse files or filesystem accounting differ, but an unexpected omission or a dramatically smaller copy requires investigation.
4. Point the active option file at the copy
Under the existing [mysqld] section, set:
datadir=/srv/mysql-data
Update every other configured pathname that still refers to the old directory. Do not delete the old setting from an included file while another later option file overrides it; inspect the effective configuration again after editing.
5. Apply AppArmor on Debian-family systems
Debian AppArmor profiles commonly permit the default locations but deny access to a custom data directory. Edit the profile used by the server, commonly /etc/apparmor.d/usr.sbin.mysqld, and add rules for the new directory and its contents using the profile’s existing syntax. Reload the profile, then check the kernel or system logs for denials:
sudo apparmor_parser -r /etc/apparmor.d/usr.sbin.mysqld
sudo journalctl -k -b | grep -i apparmor
Do not work around an AppArmor denial by making the directory world-writable. Permit only the paths MySQL needs.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitches6. Apply SELinux labels on enforcing systems
SELinux checks labels in addition to Unix ownership. The default MySQL data-directory type is mysqld_db_t. Inspect the current and new labels:
ls -Zd /var/lib/mysql /srv/mysql-data
ls -Z /srv/mysql-data | head
ps -eZ | grep mysqld
For a persistent custom location, assign a file-context rule and relabel it:
sudo semanage fcontext -a -t mysqld_db_t '/srv/mysql-data(/.*)?'
sudo restorecon -Rv /srv/mysql-data
If semanage is not installed, install the distribution package that supplies it according to your operating-system policy, or use the approved equivalent. Check audit logs for AVC denials after the first start; changing labels temporarily with chcon alone is not persistent across a relabel.
Rank #4
- 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
- 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
- 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
- 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
- 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.
7. Reload systemd only when its configuration changed, then start
If you edited a unit, drop-in, mount dependency or environment file, run:
sudo systemctl daemon-reload
Start the service and immediately inspect its state and log:
sudo systemctl start mysql
sudo systemctl status mysql --no-pager
sudo journalctl -u mysql -b --no-pager
Use mysqld in each command on an RPM-family system. Also inspect the MySQL error log at the configured location. A successful systemd start alone is not proof that the intended directory was used.
Move the directory on Windows
1. Identify the service and option file
Use the Services console or the service configuration to determine the MySQL service name and executable arguments. The service may load my.ini from the installation directory or another path specified at registration. Confirm the active file rather than editing a similarly named sample.
2. Stop MySQL and verify that it is stopped
Stop the service from Services or an elevated command prompt:
Recommended Free Tools
net stop MySQL80
Substitute the actual service name. Confirm that no mysqld.exe process remains in Task Manager or with an appropriate process query before copying files.
3. Copy the complete directory and preserve access
Copy the existing data directory, including hidden files and all InnoDB, log, certificate and metadata files, to a local NTFS volume. Retain the service account’s NTFS permissions on the destination and ensure that the account can traverse every parent directory. Do not copy only individual schema folders.
Best Value
- 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
- 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
- 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
- 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
- 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.
4. Change datadir in the service’s option file
A minimal configuration may look like this:
[mysqld]
basedir=C:Program FilesMySQLMySQL Server 8.0
datadir=D:MySQLdata
Use the actual installation and destination paths. Update other settings that still contain the old pathname, including log, socket-equivalent, PID, binary-log, relay-log and InnoDB locations. Start the service with that same option file; the official copy procedure also requires copying the option file when a separate instance directory is created.
5. Start and validate
net start MySQL80
Review the Windows service result and MySQL error log, connect with an administrative client, and verify the reported datadir plus representative schemas and tables. Keep the old directory untouched until application checks pass.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Validate that MySQL is using the intended files
- Confirm the service is active and there is only one
mysqldprocess for the instance. - Connect and run
SHOW VARIABLES LIKE 'datadir';; compare the result with the new absolute path. - Check representative databases, table counts and recent rows. Include an InnoDB table and any application-critical schemas.
- Verify that the configured error, binary and relay logs are being written where intended and that rotation still works.
- Run an application-level smoke test: authenticate, read data, perform a controlled write, and verify that the write is durable.
- Check filesystem ownership, free space, mount persistence after reboot, AppArmor status or SELinux contexts, and backup jobs.
Only after these checks and a successful application test should you archive or remove the old directory. Retaining it for a defined rollback window is safer than deleting it immediately.
Diagnose common failures
| Symptom | Likely cause | Recovery |
|---|---|---|
| Permission denied in the error log | Incorrect owner, missing parent-directory traverse permission, AppArmor denial or SELinux label mismatch. | Check ownership and modes on every parent; inspect AppArmor and SELinux logs; apply the approved profile or mysqld_db_t context. Do not make the tree world-writable. |
| MySQL creates an empty system database | The destination mount was absent, so the package saw an empty directory and initialized it. | Stop MySQL immediately. Verify the mount, restore the original data copy or backup, correct datadir and initialization safeguards, then retry. |
| InnoDB errors, missing tablespaces or redo-log messages | The copy was made while the server was running, related files were omitted, or a path still points to the old location. | Stop the server, return to the retained original or verified backup, repeat a clean shutdown and complete copy, and review all InnoDB and log paths. |
| The service starts the wrong instance | An alternate option file, service unit, command-line argument or second installation overrides the edited setting. | Inspect the service definition, process command line, option-file order and SQL-reported datadir; stop duplicate instances before retrying. |
| Starts manually but not at boot | The mount is not available before MySQL starts, or the service lacks a dependency on the mount. | Fix the filesystem’s boot configuration and service ordering, then test a reboot while monitoring the mount and service logs. |
| Slow or unstable operation on a network share | Latency, locking and durability behavior differ from local storage; NFS adds particular file-locking risks. | Use supported local or block storage unless the complete MySQL and storage design has been tested for the workload. |
Rollback without losing the original
If validation fails, do not attempt to repair an uncertain copy while applications are writing to it.
- Stop the MySQL service and confirm the process is gone.
- Preserve the failed destination for diagnosis instead of overwriting it.
- Restore the original
datadirsetting and any changed log or tablespace paths. - Ensure the original mount, ownership and security labels are correct. Restore its AppArmor or SELinux rules if they were changed.
- Start the service against the retained original directory and verify the reported
datadir. - Review the error log and the failed copy procedure before scheduling another attempt.
Never run two MySQL servers against one data directory. Concurrent access can cause interference and is unsuitable for most storage engines. A second server for testing must use its own complete data directory, ports, sockets, logs and configuration.
Operational details after the move
- Add the new mount and its availability requirements to disaster-recovery documentation.
- Update monitoring paths, disk-space alerts, backup includes and restore runbooks.
- Check scheduled jobs that reference the old directory, including log collection, antivirus exclusions and cleanup scripts.
- Document the service name, active option file, security-policy changes and rollback location.
- After the rollback window expires, remove the old copy only through a documented change, and confirm that no other instance or backup job still depends on it.
The relocation is complete when MySQL reports the new directory, all required files and related paths are accessible under the correct security policy, representative data operations succeed, and the destination mount is guaranteed to be present before the service starts.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

