Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How do I change the default path of mysql data files in linux?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

After installing the MySQL database using the rpm installation, the default path for the data file is / var/lib/mysql, but the root directory is not suitable for storing the data file, so we need to change the default path for the database file.

The change method is as follows:

Environment introduction:

Original path: / var/lib/mysql

Destination path: / home/mysql_data/mysql

Linux system version: centos7.6

MySQL database version: 5.7.25

Free study video tutorial: mysql video tutorial

Specific steps:

1. Create the target path

Mkdir-p / home/mysql_data

2. Close MySQL

Systemctl stop mysqld

3. Copy data files

Cp-arp / var/lib/mysql / home/mysql_data

4. Modify the configuration file / etc/my.cnf

Modify the original path in datadir and socket to the target path

Datadir=/home/mysql_data/mysqlsocket=/home/mysql_data/mysql/mysql.sock

5. Start the MySQL service

Systemctl start mysqld

NOTE:

1. The error is as follows:

Resolve:

Execute the command:

Setenforce 1

And then reboot.

2. The error report is as follows:

Can't connect to local MySQL server through socket'/ var/lib/mysql/mysql.sock'

Resolve:

Modify the configuration file my.cnf to add or modify the following configuration:

[client] socket = / home/mysql_data/mysql/mysql.sock

These are the details of changing the default path of mysql data files under linux. Please pay more attention to other related articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report