mysql startup error Can t change dir to xxx, No such file or directory caused by configuration error or mounting

Save money:

To mount, use /etc/fstab

Putting it in fstab will load the NFS file system before the program starts. Putting it in rc.local often results in the path not being found when the program starts loading.

 

Text: 

In an enterprise, when the server is restarted, sometimes the mysql startup error message "Can`t change dir to 'xxx', No such file or directory" will be encountered. The general meaning is that the directory cannot be changed to xxx because there is no such directory.

The reason is usually that there is a problem with the directory configured in the configuration file, or the mounting disk is slower to load than mysql starts (the data data of mysql is placed in the mounting disk)

The configuration file in Linux is my.cnf, and the usual path is /etc/my.cnf

The configuration file in windows is my.ini.

The general content of the mysql configuration file is as follows:

# mysql路径
basedir=/sata09/data/mysql
# mysql存数据的路径
datadir=/sata09/data/mysql/data

This article uses mounting problems as an example.

There are two types of mounts: rc.local, fstab .

It is recommended to use fstab. Here’s why:

Mount mount at boot,/etc/fstab and /etc/rc.d/rc .local is almost the same, the difference is that if you have a program that depends on NFS, it is better to put it in fstab. The /etc/fastab file is loaded first when the program starts.

Putting it in fstab will load the NFS file system before the program starts. Putting it in rc.local often results in the path not being found when the program starts loading.

My previous mount command was placed in /etc/rc.local, but now it is placed in /etc/fstab

mount /prd/ssd/ssd01   /ssd01   
mount /prd/sata/sata01   /sata01

The detailed log is as follows: 

Oct 17 02:50:32 ali5messrv1 mysqld: mysqld: Can`t change dir to '/sata09/data/mysql/' (Errcode: 2 - No such file or directory)
Oct 17 02:50:32 ali5messrv1 mysqld: 2023-10-16T18:50:32.060197Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
Oct 17 02:50:32 ali5messrv1 mysqld: 2023-10-16T18:50:32.060311Z 0 [Warning] Can`t create test file /sata09/data/mysql/ali5messrv1.lower-test
Oct 17 02:50:32 ali5messrv1 mysqld: 2023-10-16T18:50:32.060344Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.32-log) starting as process 3280 ...
Oct 17 02:50:32 ali5messrv1 mysqld: 2023-10-16T18:50:32.060369Z 0 [ERROR] Can`t find error-message file '/sata09/data/mysql/share/mysql/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
Oct 17 02:50:32 ali5messrv1 mysqld: 2023-10-16T18:50:32.060943Z 0 [Warning] Can`t create test file /sata09/data/mysql/ali5messrv1.lower-test
Oct 17 02:50:32 ali5messrv1 mysqld: 2023-10-16T18:50:32.060950Z 0 [Warning] Can`t create test file /sata09/data/mysql/ali5messrv1.lower-test
Oct 17 02:50:32 ali5messrv1 mysqld: 2023-10-16T18:50:32.060990Z 0 [ERROR] failed to set datadir to /sata09/data/mysql/
Oct 17 02:50:32 ali5messrv1 mysqld: 2023-10-16T18:50:32.060998Z 0 [ERROR] Aborting

Oct 17 02:50:32 ali5messrv1 systemd[1]: Starting MySQL Server...
Oct 17 02:50:32 ali5messrv1 mysqld_pre_systemd[2476]: mysqld: Can't create directory '/sata09/data/mysql/' (Errcode: 2 - No s...tory)
Oct 17 02:50:32 ali5messrv1 mysqld_pre_systemd[2476]: 2023-10-16T18:50:32.867006Z 0 [Warning] TIMESTAMP with implicit DEFAULT...ils).
Oct 17 02:50:32 ali5messrv1 mysqld_pre_systemd[2476]: 2023-10-16T18:50:32.867111Z 0 [ERROR] Can't find error-message file '/s...tive.
Oct 17 02:50:32 ali5messrv1 mysqld_pre_systemd[2476]: 2023-10-16T18:50:32.867941Z 0 [ERROR] Aborting
Oct 17 02:52:03 ali5messrv1 systemd[1]: Started MySQL Server.

The difference between mounting etc/fstab and /etc/rc.d/rc.local at startup - Alibaba Cloud Developer Community

=======================Separating line========================

The article ends here, the following is purple sweet potato pudding


Oct 17 02:50:32 ali5messrv1 mysqld: mysqld: Can't change dir to '/sata09/data/mysql/' (Errcode: 2 - No such file or directory)
Oct 17 02:50:32 ali5messrv1 mysqld: 2023-10-16T18:50:32.060197Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
Oct 17 02:50:32 ali5messrv1 mysqld: 2023-10-16T18:50:32.060311Z 0 [Warning] Can't create test file /sata09/data/mysql/ali5messrv1.lower-test
Oct 17 02:50:32 ali5messrv1 mysqld: 2023-10-16T18:50:32.060344Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.32-log) starting as process 3280 ...
Oct 17 02:50:32 ali5messrv1 mysqld: 2023-10-16T18:50:32.060369Z 0 [ERROR] Can't find error-message file '/sata09/data/mysql/share/mysql/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
Oct 17 02:50:32 ali5messrv1 mysqld: 2023-10-16T18:50:32.060943Z 0 [Warning] Can't create test file /sata09/data/mysql/ali5messrv1.lower-test
Oct 17 02:50:32 ali5messrv1 mysqld: 2023-10-16T18:50:32.060950Z 0 [Warning] Can't create test file /sata09/data/mysql/ali5messrv1.lower-test
Oct 17 02:50:32 ali5messrv1 mysqld: 2023-10-16T18:50:32.060990Z 0 [ERROR] failed to set datadir to /sata09/data/mysql/
Oct 17 02:50:32 ali5messrv1 mysqld: 2023-10-16T18:50:32.060998Z 0 [ERROR] Aborting

Oct 17 02:50:32 ali5messrv1 systemd[1]: Starting MySQL Server...
Oct 17 02:50:32 ali5messrv1 mysqld_pre_systemd[2476]: mysqld: Can't create directory '/sata09/data/mysql/' (Errcode: 2 - No s...tory)
Oct 17 02:50:32 ali5messrv1 mysqld_pre_systemd[2476]: 2023-10-16T18:50:32.867006Z 0 [Warning] TIMESTAMP with implicit DEFAULT...ils).
Oct 17 02:50:32 ali5messrv1 mysqld_pre_systemd[2476]: 2023-10-16T18:50:32.867111Z 0 [ERROR] Can't find error-message file '/s...tive.
Oct 17 02:50:32 ali5messrv1 mysqld_pre_systemd[2476]: 2023-10-16T18:50:32.867941Z 0 [ERROR] Aborting
Oct 17 02:52:03 ali5messrv1 systemd[1]: Started MySQL Server.

Guess you like

Origin blog.csdn.net/u011149152/article/details/133908850