Usage scenario: We use Alibaba Cloud and purchased a data disk separately (large space and can be used for backup). The MySQL 8.0 database is installed on the system disk by default. In order to consider security and space issues, we need to change the default database directory to another location (I use an SSD data disk here, by mounting) Operating system: CentOS 7.6 Database: MySQL 8.0 To view more of my original articles, please click here The default data directory location for MySQL 8.0 is: /var/lib/mysql My target location is: /data/ Now let’s get started 1. First, we stop the MySQL 8.0 service and use the following command [root@JasonSong ~]# sudo systemctl stop mysqld.service Use the following command to check whether the service has stopped [root@JasonSong ~]# sudo systemctl status mysqld.service ● mysqld.service – MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: inactive (dead) since Thu 2019-02-21 13:52:24 CST; 9s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 6152 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS (code=exited, status=0/SUCCESS) Process: 6082 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 6152 (code=exited, status=0/SUCCESS) Status: "SERVER_SHUTTING_DOWN" Feb 20 16:30:39 JasonSong systemd[1]: Starting MySQL Server... Feb 20 16:30:50 JasonSong systemd[1]: Started MySQL Server. Feb 21 13:52:21 JasonSong systemd[1]: Stopping MySQL Server... Feb 21 13:52:24 JasonSong systemd[1]: Stopped MySQL Server. 2. Move the default data directory to the target location [root@JasonSong ~]# mv /var/lib/mysql/ /data/ Soft link the target location to the original location and use the following command to create a soft link [root@JasonSong ~]# ln -s /data/mysql /var/lib/ To check whether the link is successful, use the following command [root@JasonSong ~]# ls -la /var/lib/mysql lrwxrwxrwx 1 root root 11 Feb 21 14:00 /var/lib/mysql -> /data/mysql After displaying the above information, you can start the MySQL service for testing. [root@JasonSong ~]# sudo systemctl start mysqld.service [root@JasonSong ~]# sudo systemctl status mysqld.service ● mysqld.service – MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2019-02-21 14:02:13 CST; 8s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 21361 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 21379 (mysqld) Status: "SERVER_OPERATING" CGroup: /system.slice/mysqld.service └─21379 /usr/sbin/mysqld Feb 21 14:02:12 JasonSong systemd[1]: Starting MySQL Server... Feb 21 14:02:13 JasonSong systemd[1]: Started MySQL Server. The above information is displayed, which means it is OK. To view more of my original articles, please click here. This is the end of this article about changing the default data directory of MySQL 8.0 (quick operation without configuration). For more information about changing the default directory of MySQL, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Detailed deployment of docker+gitlab+gitlab-runner
>>: Vue calls the PC camera to realize the photo function
Table of contents 1. Container lifecycle manageme...
● I was planning to buy some cloud data to provid...
Data Sheet /* Navicat SQLite Data Transfer Source...
In web front-end development, it is inevitable to ...
Load balancing is a commonly used device in serve...
1. First prepare the MySQL and Eclipse environmen...
The MySQL slow query log is very useful for track...
If you are a software developer, you must be fami...
Table of contents 1. Scene introduction 2 Code Op...
This article shares with you the specific code of...
1. Command Introduction The userdel (user delete)...
Method 1: Use the lsb_release utility The lsb_rel...
Table of contents Makefile Makefile naming and ru...
<br />Scientifically Design Your Website: 23...
1. Environment and preparation 1. Ubuntu 14.04 2....