mysql service started but was not found in the process

Keywords: MySQL CentOS Database

CentOS 6.5, MySQL multiple instances (in fact, the same principle applies to a single instance)

1, Problem description

[root@www ~]# /data/3308/mysql start
Starting MySQL...
[root@www ~]# ps -A|grep mysql
[root@www ~]# 

Start mysql database, and there is no result by checking the process.
2, Problem solving
Check the mysql error log. The location of the error log is known through my.cnf
[mysqld_safe]
log-error=/data/3308/mysql3308.err

[root@www 3308]# cat/data/3308/mysql3308.err

There is a line:

180128 10:27:56 [ERROR] /application/mysql-5.5.32/bin/mysqld: Can't find file: './mysql/host.frm' (errno: 13)
180128 10:27:56 [ERROR] Fatal error: Can't open and lock privilege tables: Can't find file: './mysql/host.frm' (errno: 13)

Baidu explained the reason for the authority.
View your mysql data directory

[root@www data]# ll
//Total consumption 144444
-rw-rw----. 1 mysql mysql 134217728 1month  28 13:50 ibdata1
-rw-rw----. 1 mysql mysql   4194304 1month  28 13:50 ib_logfile0
-rw-rw----. 1 mysql mysql   4194304 1month  28 10:27 ib_logfile1
-rw-rw----. 1 mysql msyql  4194304 1month  28 10:27 ib_logfile2
drwx------. 2 root root      4096 1 October 28:25 mysql
-rw-rw----. 1 root root     29629 1month  28 10:25 mysql_bin.000001
-rw-rw----. 1 root root   1058974 1month  28 10:25 mysql_bin.000002
-rw-rw----. 1 root root        38 1month  28 10:25 mysql_bin.index
drwx------. 2 root root      4096 1 October 28:25 performance_schema
drwx------. 2 root root      4096 1 October 28:25 test

The reason is that the seventh line drwx -. 2 root 4096 January 28 10:25 mysql
The root user and user group here are root, which needs to be modified to MySQL
In order to prevent other problems in the future, I changed all the root above to mysql
Execute the following statement. If your current directory is data directory, then
Method 1: modify users and user groups of data directory

[root@www data]# cd ../
[root@www 3308]# chown -R mysql.mysql data

If you're in trouble:
Method 2: (recommended by myself)

[root@www ~]#  cd /application/mysql-5.5.32/scripts/
[root@www scripts]# ./mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data --user=mysql

–user=mysql
Later parameter - the user specified by user is the user name of the process you want to run mysqld. This is variable, not necessarily mysql. After setting this user, all files created by mysqld process will belong to this user. The purpose of using MySQL users in online tutorials is to facilitate management in the production environment.
That's it.

Supplement - user=mysql
If - user=mysql is not specified, it will appear

[root@www data]# ll
//Total consumption 144444
-rw-rw----. 1 mysql mysql 134217728 1month  28 13:50 ibdata1
-rw-rw----. 1 mysql mysql   4194304 1month  28 13:50 ib_logfile0
-rw-rw----. 1 mysql mysql   4194304 1month  28 10:27 ib_logfile1
-rw-rw----. 1 mysql msyql  4194304 1month  28 10:27 ib_logfile2
drwx------. 2 root root      4096 1 October 28:25 mysql
-rw-rw----. 1 root root     29629 1month  28 10:25 mysql_bin.000001
-rw-rw----. 1 root root   1058974 1month  28 10:25 mysql_bin.000002
-rw-rw----. 1 root root        38 1month  28 10:25 mysql_bin.index
drwx------. 2 root root      4096 1 October 28:25 performance_schema
drwx------. 2 root root      4096 1 October 28:25 test

If - user=mysql is specified, root will not appear

[root@www data]# ll
//Total consumption 144444
-rw-rw----. 1 mysql mysql 134217728 1month  28 13:50 ibdata1
-rw-rw----. 1 mysql mysql   4194304 1month  28 13:50 ib_logfile0
-rw-rw----. 1 mysql mysql   4194304 1month  28 10:27 ib_logfile1
-rw-rw----. 1 mysql msyql  4194304 1month  28 10:27 ib_logfile2
drwx------. 2 mysql mysql     4096 1 October 28:25 mysql
-rw-rw----. 1 mysql mysql     29629 1month  28 10:25 mysql_bin.000001
-rw-rw----. 1 mysql mysql   1058974 1month  28 10:25 mysql_bin.000002
-rw-rw----. 1 mysql mysql        38 1month  28 10:25 mysql_bin.index
drwx------. 2 mysql mysql   4096 1 October 28:25 performance_schema
drwx------. 2 mysql mysql     4096 1 October 28:25 test

Posted by tmk4php on Thu, 30 Apr 2020 15:28:40 -0700