当前位置:网站首页>View and modify the MySQL data storage directory under centos7
View and modify the MySQL data storage directory under centos7
2022-07-05 12:34:00 【just4you】
Software version
- CentOS 7
- MySQL 5.7
View the data storage directory
Use command
SHOW VARIABLES LIKE '%datadir%';
# perhaps
SELECT @@datadir;
Get the default storage directory :/var/lib/mysql
mobile data
stop it mysql service
systemctl stop mysqld
Create a new data storage directory
mkdir -p /data01/mysql/data
Copy the data
take mysql Copy directory to /data01/mysql/data Under the table of contents
cp -a /var/lib/mysql /data01/mysql/data/
Add permissions to the directory
chown -R mysql:mysql /data01/mysql/data/mysql
chown -R mysql:mysql /data01/mysql/data
Modify the configuration my.cnf
open /etc/my.cnf file , find [mysqld] keyword , modify datadir and socket Value
[mysqld]
datadir=/data01/mysql/data/mysql
socket=/data01/mysql/data/mysql/mysql.sock
restart mysql service
systemctl start mysqld
problem
Error phenomenon
After restart , The project can normally access the database , But using the command line to access the database will report an error :
mysql -uroot -p
......
Can't connect to local MySQL server through socket '/var/lib/mysql'
......
solve
modify /etc/my.cnf, find [client] paragraph , Add the configuration
[client]
default-character-set=utf8mb4
port=3306
socket=/data01/mysql/data/mysql/mysql.sock
socket Field may not exist , Can be added to .
边栏推荐
- Get all stock data of big a
- Understand redis persistence mechanism in one article
- MVVM framework part I lifecycle
- Programming skills for optimizing program performance
- 【ijkplayer】when i compile file “compile-ffmpeg.sh“ ,it show error “No such file or directory“.
- Interviewer: is acid fully guaranteed for redis transactions?
- 16 channel water lamp experiment based on Proteus (assembly language)
- Just a coincidence? The mysterious technology of apple ios16 is actually the same as that of Chinese enterprises five years ago!
- Semantic segmentation experiment: UNET network /msrc2 dataset
- ZABBIX agent2 installation
猜你喜欢
Redis's memory elimination mechanism, read this article is enough.
Hexadecimal conversion summary
Yum only downloads the RPM package of the software to the specified directory without installing it
Pytorch two-layer loop to realize the segmentation of large pictures
Pytoch implements tf Functions of the gather() function
Master the new features of fluent 2.10
嵌入式软件架构设计-消息交互
Seven ways to achieve vertical centering
Keras implements verification code identification
Two minutes will take you to quickly master the project structure, resources, dependencies and localization of flutter
随机推荐
Video networkstate property
Making and using the cutting tool of TTF font library
MySQL basic operation -dql
GPON other manufacturers' configuration process analysis
MySQL multi table operation
How to recover the information server and how to recover the server data [easy to understand]
How does MySQL execute an SQL statement?
Hexadecimal conversion summary
Summary of C language learning problems (VS)
MySQL regular expression
Two minutes will take you to quickly master the project structure, resources, dependencies and localization of flutter
Introduction to GNN
C alarm design
Leetcode-1. Sum of two numbers (Application of hash table)
MySQL transaction
IPv6与IPv4的区别 网信办等三部推进IPv6规模部署
Why do you always fail in automated tests?
Swift - enables textview to be highly adaptive
语义分割实验:Unet网络/MSRC2数据集
Migrate data from Mysql to neo4j database