当前位置:网站首页>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;

边栏推荐
- Silicon Valley class lesson 11 - official account news and wechat authorization
- Canvas text JS special effect composed of many circles
- Live broadcast preview | how to build an enterprise cloud management platform in the cloudy era?
- [BUUCTF-n1book][第二章 web进阶]SSRF Training
- 神经网络学习(1)前言介绍
- 『每日一问』怎么实现一个正确的双重检查锁定
- What version of Oracle10g single instance database is better to upgrade to? Ask for suggestions
- MySQL排序
- Comments on specific applications of camera
- The annualization of financial products is 4%. How much profit can you get from buying 10000 yuan a month?
猜你喜欢

Canvas dynamic picture avatar shaking JS special effect
![[buuctf-n1book][Chapter 2 advanced web]ssrf training](/img/29/8894d04b27e0e73c4458c27bd9b935.png)
[buuctf-n1book][Chapter 2 advanced web]ssrf training

ActiveMQ -- dead letter queue

360度拖拽全景图插件tpanorama.js
![[C language] dynamic memory management, flexible array](/img/da/b9455885df0cb6646908e3655d62c5.png)
[C language] dynamic memory management, flexible array
![[STL]stack&queue模拟实现](/img/92/c040c0e937e2666ee179189c60a3f2.png)
[STL]stack&queue模拟实现

Ranking of data results in MySQL

Table table expansion internal row switching effect

SQL injection

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
随机推荐
Do you know these methods of MySQL database optimization?
Silicon Valley classroom lesson 12 - official account on demand course and live broadcast management module
leetcode-238.除自身以外数组的乘积
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
Leetcode-238. product of arrays other than itself
How to write the code of wechat applet implementation tab
Leetcode组合总和+剪枝
酷炫canvas动画冲击波js特效
The simplest sklearn environment configuration tutorial in the whole network (100% success)
JS pop-up City filtering component matches mobile terminal
Shell script
API parsing of JDBC
activemq--死信队列
activemq--消息重试机制
将list集合的某一字段拼接单个String
ActiveMQ -- leveldb of persistence mechanism
The garbage classification data set used in the excellent Yolo target detection training is shared - about 3000 labeled
有误差的字符串型时间比较方法String.compareTo
NFT guide for musicians
table表格展开内部行切换效果