当前位置:网站首页>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 .
边栏推荐
- Ecplise development environment configuration and simple web project construction
- Migrate data from Mysql to neo4j database
- Matlab label2idx function (convert the label matrix into a cell array with linear index)
- Matlab imoverlay function (burn binary mask into two-dimensional image)
- MySQL view
- Understand kotlin from the perspective of an architect
- Four operations and derivative operations of MATLAB polynomials
- GPON other manufacturers' configuration process analysis
- Seven ways to achieve vertical centering
- Differences between IPv6 and IPv4 three departments including the office of network information technology promote IPv6 scale deployment
猜你喜欢
Why learn harmonyos and how to get started quickly?
About cache exceptions: solutions for cache avalanche, breakdown, and penetration
16 channel water lamp experiment based on Proteus (assembly language)
Two minutes will take you to quickly master the project structure, resources, dependencies and localization of flutter
Learn memory management of JVM 01 - first memory
Matlab boundarymask function (find the boundary of the divided area)
How can beginners learn flutter efficiently?
Take you hand in hand to develop a service monitoring component
ZABBIX customized monitoring disk IO performance
7月华清学习-1
随机推荐
July Huaqing learning-1
Solve the problem of cache and database double write data consistency
Knowledge representation (KR)
MySQL index - extended data
ZABBIX agent2 monitors mongodb templates and configuration operations
Keras implements verification code identification
Why learn harmonyos and how to get started quickly?
Distributed solution - completely solve website cross domain requests
C language structure is initialized as a function parameter
Video networkstate property
End to end neural network
Embedded software architecture design - message interaction
Experimental design - using stack to realize calculator
SENT协议译码的深入探讨
Take you hand in hand to develop a service monitoring component
Acid transaction theory
Hexadecimal conversion summary
Automated test lifecycle
What is digital existence? Digital transformation starts with digital existence
How to clear floating?