How To Move a MySQL Data Directory to a New Location on Ubuntu 16.04
How To Move a MySQL Data Directory to a New Location on Ubuntu 16.04
If you need to move your MySQL data directory to a new location on Ubuntu 16.04, you can do so by following these steps:
- Stop the MySQL service:
sudo systemctl stop mysql - Copy the existing data directory to the new location using the following command:
sudo cp -R /var/lib/mysql /new/location - Edit the MySQL configuration file using your preferred text editor (e.g., nano, vim):
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf - Find the line that specifies the datadir and change it to reflect the new location:
datadir=/new/location/mysql - Save and exit the file.
- Start the MySQL service:
sudo systemctl start mysql - Verify that the new location is being used by running the following command:
sudo mysql -u root -p -e "SHOW VARIABLES LIKE 'datadir';"
That's it! Your MySQL data directory should now be located at the new location you specified.
Keywords: MySQL, Data Directory, Ubuntu 16.04, Move, Location, Stop, Service, Copy, Configuration File, datadir, Verify.
Комментарии
Отправить комментарий