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 to modify the database directory in mysql

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

Today, I will talk to you about how to modify the database directory in mysql. Many people may not know much about it. In order to let you know more, Xiaobian summarized the following contents for you. I hope you can gain something according to this article.

Environment:

OS:Red Hat Linux As 5

DB:MySql 5.5

After installing mysql under linux, the default data file path is stored in the/var/lib/mysql directory.

The following steps describe how to migrate data files from this directory to another directory.

1. Create a database directory and modify the directory permissions owner to mysql

[root@host1 /]# mkdir -p mysql/data

[root@host1 /]# chown -R mysql:mysql ./ mysql

2. Stop mysql service

[root@host1 etc]# service mysql stop

Shutting down MySQL. [ OK ]

3. modify my.cnf file modify

Add a new data storage path under [mysqld]

datadir=/mysql/data

4. cp all files and directories from the default datapath to the new directory

[root@host1 mysql]#cd /var/lib/mysql

[root@host1 mysql]#cp -R * /mysql/data/

Note here that copy the previous directory permission owner needs to be modified to mysql, directly modified here

The mysql directory can be.

[root@host1 mysql]# chown -R mysql:mysql ./ mysql

4. start the database

[root@host1 mysql]# service mysql start

Starting MySQL.... [ OK ]

-- The End --

After reading the above, do you have any further understanding of how to modify the database directory in mysql? If you still want to know more knowledge or related content, please pay attention to the industry information channel, thank you for your support.

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