查看数据库版本
mysql> select version();
+------------+
| version() |
+------------+
| 5.7.22-log |
+------------+
1 row in set (0.01 sec)
停掉数据库,启动的时候报错:
[root@node1 /]# /etc/init.d/mysql start
Starting MySQL. ERROR! The server quit without updating PID file (/data/mysql//node1.pid).
查看配置文件和目录权限
[root@node1 /]# cat /etc/my.cnf
[mysqld]
datadir=/data/mysql/
basedir=/usr/local/mysql
socket=/tmp/mysql.sock
log-bin=mysql-bin
binlog-format=ROW
#server_id=2
user=mysql
bind-address=*
port=3306
character-set-server=utf8
secure-file-priv=''
#pid-file=/var/run/mysqld.pid
#skip-grant-tables
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
[root@node1 /]# ll /data/mysql
total 110636
-rw-r----- 1 mysql mysql 56 Sep 26 11:11 auto.cnf
-rw-r----- 1 mysql mysql 1620 Sep 26 13:43 ib_buffer_pool
-rw-r----- 1 mysql mysql 12582912 Sep 26 13:43 ibdata1
-rw-r----- 1 mysql mysql 50331648 Sep 26 13:43 ib_logfile0
-rw-r----- 1 mysql mysql 50331648 Sep 4 17:29 ib_logfile1
drwxr-x--- 2 mysql mysql 4096 Sep 4 10:21 mysql
-rw-r----- 1 mysql mysql 177 Sep 26 11:14 mysql-bin.000001
-rw-r----- 1 mysql mysql 177 Sep 26 13:43 mysql-bin.000002
-rw-r----- 1 mysql mysql 38 Sep 26 13:43 mysql-bin.index
drwxr-x--- 2 mysql mysql 4096 Sep 4 10:21 performance_schema
drwxr-x--- 2 mysql mysql 12288 Sep 4 10:21 sys
drwxr-x--- 2 mysql mysql 4096 Sep 4 10:25 test
[root@node1 /]# ll /data/
total 40
drwx------ 18 postgres postgres 4096 Jul 25 15:51 94data
-rwxr-xr-x 1 root root 3036 Jun 12 18:01 cluster.sh
drwxr-xr-x 6 mysql mysql 4096 Sep 26 13:44 mysql
drwxr-xr-x 6 root root 4096 Jul 23 16:19 pg94
drwxr-xr-x 6 root root 4096 Jun 11 16:00 pg96
drwx------ 20 postgres postgres 4096 Jul 20 16:53 pgdata
-rw-r--r-- 1 root root 8395 Jun 12 18:03 pgsql_cfg
-rw-r--r-- 1 root root 1603 Aug 6 14:09 testdb.sql
[root@node1 /]#
把配置文件的server_id=2注释去掉,再次启动数据库:
[root@node1 /]# /etc/init.d/mysql start
Starting MySQL. SUCCESS!
[root@node1 /]# mysql -u root -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.22-log MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
至于为什么server_id会引起这样的错误,还没找到相关的说明。