当前位置:网站首页>CentOS changes MySQL database directory
CentOS changes MySQL database directory
2022-07-25 09:19:00 【Why don't you laugh】
centos change mysql Database directory
This tutorial passed the test MySQL edition :
- centos7
- mysql5.7.32 and mysql5.7.27
- Other database versions should be the same , Not tested yet
1. Stop mysql service
systemctl stop msyql
Tips :centos Of selinux I need to set to disabled, After setting, you need to restart the server
vim /etc/selinux/config

Or perform setenforce 0 close selinux, Provisional entry into force
2. Create a new mysql Database directory
# The specific directory location can be created according to your own needs
mkdir /opt/mysqldata
The next step is to install by default mysql Move to the newly created mysqldata Under the table of contents
3. Move mysql To the newly created directory
Because it's through rpm The way to install mysql,mysql By default, it will be stored in /var/lib/mysql Catalog
hold /var/lib/msyql Move the whole to /opt/mysqldata/
mv /var/lib/mysql /opt/mysqldata/
4. Set up mysqldata Directory permissions
change mysqldata User name and user group of directory
chown -R mysql:mysql /opt/mysqldata/mysql
modify mysqldata Access to directory
chmod 755 /opt/mysqldata/mysql
# Set the outermost layer directly , Set only one mysql May not be enough
chmod 755 /opt
5. modify /etc/my.cnf
It needs to be revised my.cnf The path in the file points to the new directory
# modify datadir For the new directory address
#datadir=/var/lib/mysql
datadir=/opt/mysql/mysql
# modify socket For the new directory address
#socket=/var/lib/mysql/mysql.sock
socket=/opt/mysql/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# adopt rpm Installed , Will it client modular , Need to add , Otherwise mysql -u -p The command cannot log in to mysql
[client]
socket=/opt/mysql/mysql/mysql.sock
# adopt rpm Installed , Will it [mysql_safe], Need to add
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
The contents of the red box are added and modified on the basis of the original document

After this change, you can restart
systemctl start mysqld
6. The verification results
Sign in mysql
mysql -u root -p
Check the database address
select @@datadir;

边栏推荐
- Programmers can't SQL? Ashes Engineer: all waiting to be eliminated! This is a must skill!
- What is steel grating?
- How to realize the drop-down option box of wechat applet
- JDBC quick start
- [buuctf-n1book][Chapter 2 advanced web]ssrf training
- 音乐人的 NFT 指南
- 28.插槽
- The simplest sklearn environment configuration tutorial in the whole network (100% success)
- 28. Slot
- OmniPeek packet capturing tool
猜你喜欢

Guangzhou has carried out in-depth "100 day action" to check the safety of self built commercial houses, and more than 2 million houses have been checked in two months

Wechat applet obtains the data of ---- onenet and controls the on-board LED of STM32

图解LeetCode——919. 完全二叉树插入器(难度:中等)

table表格展开内部行切换效果

activemq--延迟投递和定时投递

PL/SQL工具导出sql文件所使用的命令是什么?

Probe into Druid query timeout configuration → who is the querytimeout of datasource and jdbctemplate effective?

JS pop-up City filtering component matches mobile terminal

Live broadcast preview | how to build an enterprise cloud management platform in the cloudy era?

实现简单的RESTful API服务器
随机推荐
Software examination system architecture designer concise tutorial | software life cycle
神经网络学习(1)前言介绍
为什么说DAO是未来的公司形式
activemq--死信队列
ActiveMQ -- AMQ of persistent mechanism
『怎么用』代理模式
[STL]list模拟实现
这家十年内容产业基建公司,竟是隐形的Web3先行者
ActiveMQ -- dead letter queue
Opencv realizes simple face tracking
Do you know these methods of MySQL database optimization?
JS touch screen game source code ice and snow journey
Dark horse programmer JDBC
Composition of the interview must ask items
Six storage types in C language: Auto register static extern const volatile
JDBC快速入门
NFT guide for musicians
Ranking of data results in MySQL
A picture to quickly understand envoyfilter in istio
360 degree drag panorama plug-in tpanorama.js