热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

MySQL启动故障处理一例(errno13)_MySQL

之前在系统上装了个MySQL用于测试,今天发现启动mysqld_safe进程的时候报错,如下所示:[root@baklocal]mysqld_safe[1]2631[root@baklocal]Startingmysqlddaemonwithdatabasesfro
之前在系统上装了个MySQL用于测试,今天发现启动mysqld_safe进程的时候报错,如下所示:
[root@bak local]# mysqld_safe & [1] 2631 [root@bak local]# Starting mysqld daemon with databases from /data/mysql/mysql_3306/data STOPPING server from pid file /data/mysql/mysql_3306/data/bak.pid 141017 09:20:23 mysqld ended

[1]+ Done mysqld_safe
由于我的my.cnf并没有改名,使用的是默认的/etc/my.cnf这个位置,因此mysqld_safe &可以不用指定任何参数,需要的参数已经在my.cnf中指定了,如果使用的my.cnf位置不在/etc/下面,或者改过了自定义的名字,那么需要用--defaults-file参数来指定my.cnf文件的位置
[root@bak local]# cd /data/mysql/mysql_3306/logs/ [root@bak logs]# ll total 0
查看日志,并没有任何binlog生成,这里说明一下,这个环境是从原来的一台主机上clone过来的,clone完以后没有启动过MySQL,我想可能是因为这个缘故
[root@bak mysql_3306]# cd /usr/local
[root@bak local]# chown -R mysql:mysql /data/mysql/
[root@bak local]# chown -R mysql:mysql /usr/local/mysql/ [root@bak local]# ll total 76 drwxr-xr-x 2 mysql 502 4096 Aug 25 11:39 bin -rw-rw---- 1 mysql root 432 Oct 17 09:20 error.log drwxr-xr-x 2 mysql 502 4096 Aug 8 2008 etc drwxr-xr-x 2 mysql 502 4096 Aug 8 2008 games drwxr-xr-x 2 mysql 502 4096 Aug 8 2008 include drwxr-xr-x 2 mysql 502 4096 Aug 8 2008 lib drwxr-xr-x 2 mysql 502 4096 Aug 8 2008 libexec lrwxrwxrwx 1 root root 38 Sep 24 00:12 mysql -> /opt/mysql/mysql-5.5.39-linux2.6-i686/ drwxr-xr-x 2 mysql 502 4096 Aug 8 2008 sbin drwxr-xr-x 5 mysql 502 4096 Aug 25 11:39 share drwxr-xr-x 2 mysql 502 4096 Sep 23 20:34 src
[root@bak local]# id mysql uid=501(mysql) gid=1000(mysql) groups=1000(mysql) mysql用户id为501,但不知为何显示的是mysql 502的形式,而不是mysql mysql
开始以为是因为/usr/local/mysql这个目录是root:root的缘故,但改为mysql:mysql后,依然无法启动
[root@bak data]# chown -R mysql:mysql /usr/local [root@bak data]# cd /usr/local [root@bak local]# ll total 76 drwxr-xr-x 2 mysql 502 4096 Aug 25 11:39 bin -rw-rw---- 1 mysql root 432 Oct 17 09:20 error.log drwxr-xr-x 2 mysql 502 4096 Aug 8 2008 etc drwxr-xr-x 2 mysql 502 4096 Aug 8 2008 games drwxr-xr-x 2 mysql 502 4096 Aug 8 2008 include drwxr-xr-x 2 mysql 502 4096 Aug 8 2008 lib drwxr-xr-x 2 mysql 502 4096 Aug 8 2008 libexec lrwxrwxrwx 1 mysql mysql 38 Sep 24 00:12 mysql -> /opt/mysql/mysql-5.5.39-linux2.6-i686/ drwxr-xr-x 2 mysql 502 4096 Aug 8 2008 sbin drwxr-xr-x 5 mysql 502 4096 Aug 25 11:39 share drwxr-xr-x 2 mysql 502 4096 Sep 23 20:34 src [root@bak local]# mysqld_safe & [1] 2692 [root@bak local]# Starting mysqld daemon with databases from /data/mysql/mysql_3306/data
[root@bak local]# mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
报了一个无法通过socket连接到服务器,于是想是不是应该在client项目中添加socket=/tmp/mysql.sock这个参数
--先查看下原来有的配置 [root@bak local]# cat /etc/my.cnf [client] port = 3306 socket = /tmp/mysql.sock
[mysqld_safe] open_files_limit = 8192 user = mysql log-error = error.log
...省略以下部分
看来client总已经指定了socket,应该不是这个问题,要判断问题出在哪里,最直接都就是查看error.log文件,由于我在my.cnf参数中指定了error.log的位置,放在了数据文件目录下,并更改了名字。如果没有改,默认的名字为.error
[root@bak local]# cat /data/mysql/mysql_3306/data/error.log 141017 9:24:53 [Warning] Using unique option prefix myisam_recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
141017 9:24:53 [Note] Plugin 'FEDERATED' is disabled. /usr/libexec/mysqld: Table 'mysql.plugin' doesn't exist 141017 9:24:53 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it. 141017 9:24:53 InnoDB: The InnoDB memory heap is disabled 141017 9:24:53 InnoDB: Mutexes and rw_locks use InnoDB's own implementation 141017 9:24:53 InnoDB: Compressed tables use zlib 1.2.3 141017 9:24:53 InnoDB: Using Linux native AIO 141017 9:24:53 InnoDB: Initializing buffer pool, size = 128.0M 141017 9:24:53 InnoDB: Completed initialization of buffer pool InnoDB: The first specified data file ./ibdata1 did not exist: InnoDB: a new database to be created! 141017 9:24:53 InnoDB: Setting file ./ibdata1 size to 100 MB InnoDB: Database physically writes the file full: wait... InnoDB: Progress in MB: 100 141017 9:24:58 InnoDB: Log file ./ib_logfile0 did not exist: new to be created InnoDB: Setting log file ./ib_logfile0 size to 100 MB InnoDB: Database physically writes the file full: wait... InnoDB: Progress in MB: 100 141017 9:25:03 InnoDB: Log file ./ib_logfile1 did not exist: new to be created InnoDB: Setting log file ./ib_logfile1 size to 100 MB InnoDB: Database physically writes the file full: wait... InnoDB: Progress in MB: 100 141017 9:25:08 InnoDB: Log file ./ib_logfile2 did not exist: new to be created InnoDB: Setting log file ./ib_logfile2 size to 100 MB InnoDB: Database physically writes the file full: wait... InnoDB: Progress in MB: 100 InnoDB: Doublewrite buffer not found: creating new InnoDB: Doublewrite buffer created InnoDB: 127 rollback segment(s) active. InnoDB: Creating foreign key constraint system tables InnoDB: Foreign key constraint system tables created 141017 9:25:13 InnoDB: Waiting for the background threads to start 141017 9:25:14 InnoDB: 5.5.39 started; log sequence number 0 141017 9:25:14 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306 141017 9:25:14 [Note] - '0.0.0.0' resolves to '0.0.0.0'; 141017 9:25:14 [Note] Server socket created on IP: '0.0.0.0'. 141017 9:25:14 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist 141017 9:26:15 [Warning] Using unique option prefix myisam_recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead. 141017 9:26:15 [Note] Plugin 'FEDERATED' is disabled. /usr/libexec/mysqld: Table 'mysql.plugin' doesn't exist 141017 9:26:15 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it. 141017 9:26:15 InnoDB: The InnoDB memory heap is disabled 141017 9:26:15 InnoDB: Mutexes and rw_locks use InnoDB's own implementation 141017 9:26:15 InnoDB: Compressed tables use zlib 1.2.3 141017 9:26:15 InnoDB: Using Linux native AIO 141017 9:26:15 InnoDB: Initializing buffer pool, size = 128.0M 141017 9:26:15 InnoDB: Completed initialization of buffer pool 141017 9:26:15 InnoDB: highest supported file format is Barracuda. InnoDB: Log scan progressed past the checkpoint lsn 48941 141017 9:26:15 InnoDB: Database was not shut down normally! InnoDB: Starting crash recovery. InnoDB: Reading tablespace information from the .ibd files... InnoDB: Restoring possible half-written data pages from the doublewrite InnoDB: buffer... InnoDB: Doing recovery: scanned up to log sequence number 1595668 141017 9:26:15 InnoDB: Starting an apply batch of log records to the database... InnoDB: Progress in percents: 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 InnoDB: Apply batch completed 141017 9:26:15 InnoDB: Waiting for the background threads to start 141017 9:26:16 InnoDB: 5.5.39 started; log sequence number 1595668 141017 9:26:16 [Note] Recovering after a crash using /data/mysql/mysql_3306/logs/mysql-bin 141017 9:26:16 [Note] Starting crash recovery... 141017 9:26:16 [Note] Crash recovery finished. 141017 9:26:17 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306 141017 9:26:17 [Note] - '0.0.0.0' resolves to '0.0.0.0'; 141017 9:26:17 [Note] Server socket created on IP: '0.0.0.0'. 141017 9:26:17 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
日志中报错提示无法打开mysql.plugin表,也不存在mysql.host这张表,由于是测试环境,没有什么数据,于是决定重新初始化MySQL
[root@bak local]# cd mysql
[root@bak mysql]# ./scripts/mysql_install_db Installing MySQL system tables... 141017 9:28:24 [Warning] options --log-slow-admin-statements, --log-queries-not-using-indexes and --log-slow-slave-statements have no effect if --log_slow_queries is not set OK Filling help tables... 141017 9:28:25 [Warning] options --log-slow-admin-statements, --log-queries-not-using-indexes and --log-slow-slave-statements have no effect if --log_slow_queries is not set OK
To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password' /usr/local/mysql/bin/mysqladmin -u root -h bak password 'new-password'
Alternatively you can run: /usr/local/mysql/bin/mysql_secure_installation
which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with: cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
[root@bak mysql]# mysqld_safe & [1] 2858 [root@bak mysql]# Starting mysqld daemon with databases from /data/mysql/mysql_3306/data
[root@bak mysql]# mysqSTOPPING server from pid file /data/mysql/mysql_3306/data/bak.pid l141017 09:28:36 mysqld ended

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) [1]+ Done mysqld_safe
初始化时成功的,可以看到有2个OK,不过启动依然报错,再次查看error.log
[root@bak mysql]# cat /data/mysql/mysql_3306/data/error.log 141017 9:24:53 [Warning] Using unique option prefix myisam_recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead. 141017 9:24:53 [Note] Plugin 'FEDERATED' is disabled. /usr/libexec/mysqld: Table 'mysql.plugin' doesn't exist 141017 9:24:53 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it. 141017 9:24:53 InnoDB: The InnoDB memory heap is disabled 141017 9:24:53 InnoDB: Mutexes and rw_locks use InnoDB's own implementation 141017 9:24:53 InnoDB: Compressed tables use zlib 1.2.3 141017 9:24:53 InnoDB: Using Linux native AIO 141017 9:24:53 InnoDB: Initializing buffer pool, size = 128.0M 141017 9:24:53 InnoDB: Completed initialization of buffer pool InnoDB: The first specified data file ./ibdata1 did not exist: InnoDB: a new database to be created! 141017 9:24:53 InnoDB: Setting file ./ibdata1 size to 100 MB InnoDB: Database physically writes the file full: wait... InnoDB: Progress in MB: 100 141017 9:24:58 InnoDB: Log file ./ib_logfile0 did not exist: new to be created InnoDB: Setting log file ./ib_logfile0 size to 100 MB InnoDB: Database physically writes the file full: wait... InnoDB: Progress in MB: 100 141017 9:25:03 InnoDB: Log file ./ib_logfile1 did not exist: new to be created InnoDB: Setting log file ./ib_logfile1 size to 100 MB InnoDB: Database physically writes the file full: wait... InnoDB: Progress in MB: 100 141017 9:25:08 InnoDB: Log file ./ib_logfile2 did not exist: new to be created InnoDB: Setting log file ./ib_logfile2 size to 100 MB InnoDB: Database physically writes the file full: wait... InnoDB: Progress in MB: 100 InnoDB: Doublewrite buffer not found: creating new InnoDB: Doublewrite buffer created InnoDB: 127 rollback segment(s) active. InnoDB: Creating foreign key constraint system tables InnoDB: Foreign key constraint system tables created 141017 9:25:13 InnoDB: Waiting for the background threads to start 141017 9:25:14 InnoDB: 5.5.39 started; log sequence number 0 141017 9:25:14 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306 141017 9:25:14 [Note] - '0.0.0.0' resolves to '0.0.0.0'; 141017 9:25:14 [Note] Server socket created on IP: '0.0.0.0'. 141017 9:25:14 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist 141017 9:26:15 [Warning] Using unique option prefix myisam_recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead. 141017 9:26:15 [Note] Plugin 'FEDERATED' is disabled. /usr/libexec/mysqld: Table 'mysql.plugin' doesn't exist 141017 9:26:15 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it. 141017 9:26:15 InnoDB: The InnoDB memory heap is disabled 141017 9:26:15 InnoDB: Mutexes and rw_locks use InnoDB's own implementation 141017 9:26:15 InnoDB: Compressed tables use zlib 1.2.3 141017 9:26:15 InnoDB: Using Linux native AIO 141017 9:26:15 InnoDB: Initializing buffer pool, size = 128.0M 141017 9:26:15 InnoDB: Completed initialization of buffer pool 141017 9:26:15 InnoDB: highest supported file format is Barracuda. InnoDB: Log scan progressed past the checkpoint lsn 48941 141017 9:26:15 InnoDB: Database was not shut down normally! InnoDB: Starting crash recovery. InnoDB: Reading tablespace information from the .ibd files... InnoDB: Restoring possible half-written data pages from the doublewrite InnoDB: buffer... InnoDB: Doing recovery: scanned up to log sequence number 1595668 141017 9:26:15 InnoDB: Starting an apply batch of log records to the database... InnoDB: Progress in percents: 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 InnoDB: Apply batch completed 141017 9:26:15 InnoDB: Waiting for the background threads to start 141017 9:26:16 InnoDB: 5.5.39 started; log sequence number 1595668 141017 9:26:16 [Note] Recovering after a crash using /data/mysql/mysql_3306/logs/mysql-bin 141017 9:26:16 [Note] Starting crash recovery... 141017 9:26:16 [Note] Crash recovery finished. 141017 9:26:17 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306 141017 9:26:17 [Note] - '0.0.0.0' resolves to '0.0.0.0'; 141017 9:26:17 [Note] Server socket created on IP: '0.0.0.0'. 141017 9:26:17 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist 141017 9:28:34 [Warning] Using unique option prefix myisam_recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead. 141017 9:28:34 [Note] Plugin 'FEDERATED' is disabled. /usr/libexec/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13) 141017 9:28:34 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it. 141017 9:28:34 InnoDB: The InnoDB memory heap is disabled 141017 9:28:34 InnoDB: Mutexes and rw_locks use InnoDB's own implementation 141017 9:28:34 InnoDB: Compressed tables use zlib 1.2.3 141017 9:28:34 InnoDB: Using Linux native AIO 141017 9:28:34 InnoDB: Initializing buffer pool, size = 128.0M 141017 9:28:34 InnoDB: Completed initialization of buffer pool 141017 9:28:34 InnoDB: highest supported file format is Barracuda. InnoDB: The log sequence number in ibdata files does not match InnoDB: the log sequence number in the ib_logfiles! 141017 9:28:34 InnoDB: Database was not shut down normally! InnoDB: Starting crash recovery. InnoDB: Reading tablespace information from the .ibd files... InnoDB: Restoring possible half-written data pages from the doublewrite InnoDB: buffer... 141017 9:28:34 InnoDB: Waiting for the background threads to start 141017 9:28:35 InnoDB: 5.5.39 started; log sequence number 1595668 /usr/libexec/mysqld: File '/data/mysql/mysql_3306/logs/mysql-bin.000004' not found (Errcode: 13) 141017 9:28:35 [ERROR] Failed to open log (file '/data/mysql/mysql_3306/logs/mysql-bin.000004', errno 13) 141017 9:28:35 [ERROR] Could not open log file 141017 9:28:35 [ERROR] Can't init tc log 141017 9:28:35 [ERROR] Aborting
141017 9:28:35 InnoDB: Starting shutdown... 141017 9:28:36 InnoDB: Shutdown completed; log sequence number 1595668 141017 9:28:36 [Note] /usr/libexec/mysqld: Shutdown complete
141017 9:30:32 [Warning] Using unique option prefix myisam_recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead. 141017 9:30:32 [Note] Plugin 'FEDERATED' is disabled. /usr/libexec/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13) 141017 9:30:32 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it. 141017 9:30:32 InnoDB: The InnoDB memory heap is disabled 141017 9:30:32 InnoDB: Mutexes and rw_locks use InnoDB's own implementation 141017 9:30:32 InnoDB: Compressed tables use zlib 1.2.3 141017 9:30:32 InnoDB: Using Linux native AIO 141017 9:30:32 InnoDB: Initializing buffer pool, size = 128.0M 141017 9:30:32 InnoDB: Completed initialization of buffer pool 141017 9:30:32 InnoDB: highest supported file format is Barracuda. 141017 9:30:32 InnoDB: Waiting for the background threads to start 141017 9:30:33 InnoDB: 5.5.39 started; log sequence number 1595668 /usr/libexec/mysqld: File '/data/mysql/mysql_3306/logs/mysql-bin.000004' not found (Errcode: 13) 141017 9:30:33 [ERROR] Failed to open log (file '/data/mysql/mysql_3306/logs/mysql-bin.000004', errno 13) 141017 9:30:33 [ERROR] Could not open log file 141017 9:30:33 [ERROR] Can't init tc log 141017 9:30:33 [ERROR] Aborting
141017 9:30:33 InnoDB: Starting shutdown... 141017 9:30:34 InnoDB: Shutdown completed; log sequence number 1595668 141017 9:30:34 [Note] /usr/libexec/mysqld: Shutdown complete
现在error.log里很明显地指出errno为13,我们知道13就是权限问题,这个可以perror命令查看 [root@bak mysql]# perror 13 OS error code 13: Permission denied
位置可以通过which来定位 [root@bak mysql]# which perror
/usr/bin/perror
或者用find定位也是可以的 [root@bak mysql]# find / -name perror -print
/opt/mysql/mysql-5.5.39-linux2.6-i686/bin/perror
/usr/bin/perror

既然找到了无法启动的真正原因,那么对症下药,把权限问题解决,问题就可以搞定了
[root@bak mysql]# cd /data/mysql/mysql_3306/data
[root@bak data]# ll total 410036 -rw-rw---- 1 mysql mysql 7950 Oct 17 09:30 error.log -rw-rw---- 1 mysql mysql 104857600 Oct 17 09:30 ibdata1 -rw-rw---- 1 mysql mysql 104857600 Oct 17 09:30 ib_logfile0 -rw-rw---- 1 mysql mysql 104857600 Oct 17 09:25 ib_logfile1 -rw-rw---- 1 mysql mysql 104857600 Oct 17 09:25 ib_logfile2 drwx------ 2 root root 4096 Oct 17 09:28 mysql drwx------ 2 root root 4096 Oct 17 09:28 performance_schema drwx------ 2 root root 4096 Oct 17 09:28 test [root@bak data]# chown -R mysql:mysql ./ [root@bak data]# ll total 410036 -rw-rw---- 1 mysql mysql 7950 Oct 17 09:30 error.log -rw-rw---- 1 mysql mysql 104857600 Oct 17 09:30 ibdata1 -rw-rw---- 1 mysql mysql 104857600 Oct 17 09:30 ib_logfile0 -rw-rw---- 1 mysql mysql 104857600 Oct 17 09:25 ib_logfile1 -rw-rw---- 1 mysql mysql 104857600 Oct 17 09:25 ib_logfile2 drwx------ 2 mysql mysql 4096 Oct 17 09:28 mysql drwx------ 2 mysql mysql 4096 Oct 17 09:28 performance_schema drwx------ 2 mysql mysql 4096 Oct 17 09:28 test
开始还去调整了/data/mysql/mysql_3306/data目录下面几个数据库的权限,但发现依然无法启动,看来不是这几个目录的权限问题

[root@bak data]# mysqld_safe & [1] 2988 [root@bak data]# Starting mysqld daemon with databases from /data/mysql/mysql_3306/data
[root@bak data]# mysqlSTOPPING server from pid file /data/mysql/mysql_3306/data/bak.pid 141017 09:32:08 mysqld ended

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) [1]+ Done mysqld_safe
error.log日志内容和之前一样,仍然报errno 13,就不贴了。针对之前给出的error.log日志里提示的对mysql-bin.000004读写权限的问题做一下处理
[root@bak mysql]# cd /data/mysql/mysql_3306/logs [root@bak logs]# ll total 1092 -rw-rw---- 1 mysql mysql 107 Oct 17 09:25 mysql-bin.000001 -rw-rw---- 1 mysql mysql 107 Oct 17 09:26 mysql-bin.000002 -rw-rw---- 1 root root 27681 Oct 17 09:28 mysql-bin.000003 -rw-rw---- 1 root root 1070549 Oct 17 09:28 mysql-bin.000004 -rw-rw---- 1 mysql mysql 180 Oct 17 09:28 mysql-bin.index [root@bak logs]# chown -R mysql:mysql ./ [root@bak logs]# ll total 1092 -rw-rw---- 1 mysql mysql 107 Oct 17 09:25 mysql-bin.000001 -rw-rw---- 1 mysql mysql 107 Oct 17 09:26 mysql-bin.000002 -rw-rw---- 1 mysql mysql 27681 Oct 17 09:28 mysql-bin.000003 -rw-rw---- 1 mysql mysql 1070549 Oct 17 09:28 mysql-bin.000004 -rw-rw---- 1 mysql mysql 180 Oct 17 09:28 mysql-bin.index
原来是root root权限,改为mysql mysql了,再次启动MySQL进程
[root@bak logs]# ps -ef|grep mysql root 3060 2591 0 09:35 pts/0 00:00:00 grep mysql [root@bak logs]# mysqld_safe & [1] 3061 [root@bak logs]# Starting mysqld daemon with databases from /data/mysql/mysql_3306/data
[root@bak logs]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.5.39-log MySQL Community Server (GPL)
Copyright (c) 2000, 2014, 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.
(testing)root@localhost [(none)]> exit
[root@bak logs]# ps aux | grep -v grep | grep mysql
root 3061 0.0 0.1 4484 1152 pts/0 S 09:35 0:00 /bin/sh /usr/bin/mysqld_safe mysql 3095 0.0 3.1 330320 32216 pts/0 Sl 09:35 0:02 /usr/libexec/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql/mysql_3306/data --user=mysql --pid-file=/data/mysql/mysql_3306/data/bak.pid --skip-external-locking --port=3306 --socket=/tmp/mysql.sock
这次,数据库顺利启动了,从mysql进程中可以看到,mysqld_safe实际去调用的还是mysqld

总结:
当我们遭遇数据库无法启动,如:自动终止进程stopping from pid file或是无法通过socket连接到服务器等错误,首先要去查看数据库的error.log日志,其中有详细的提示(各种ERROR和WARNING),来给你提供无法启动的线索,我们要做的就是更具这些线索,来做相应的处理,才能更快、更好地解决问题。
推荐阅读
  • 本文介绍了在开发Android新闻App时,搭建本地服务器的步骤。通过使用XAMPP软件,可以一键式搭建起开发环境,包括Apache、MySQL、PHP、PERL。在本地服务器上新建数据库和表,并设置相应的属性。最后,给出了创建new表的SQL语句。这个教程适合初学者参考。 ... [详细]
  • 本文介绍了在Hibernate配置lazy=false时无法加载数据的问题,通过采用OpenSessionInView模式和修改数据库服务器版本解决了该问题。详细描述了问题的出现和解决过程,包括运行环境和数据库的配置信息。 ... [详细]
  • 腾讯安全平台部招聘安全工程师和数据分析工程师
    腾讯安全平台部正在招聘安全工程师和数据分析工程师。安全工程师负责安全问题和安全事件的跟踪和分析,提供安全测试技术支持;数据分析工程师负责安全产品相关系统数据统计和分析挖掘,通过用户行为数据建模为业务决策提供参考。招聘要求包括熟悉渗透测试和常见安全工具原理,精通Web漏洞,熟练使用多门编程语言等。有相关工作经验和在安全站点发表作品的候选人优先考虑。 ... [详细]
  • Linux服务器密码过期策略、登录次数限制、私钥登录等配置方法
    本文介绍了在Linux服务器上进行密码过期策略、登录次数限制、私钥登录等配置的方法。通过修改配置文件中的参数,可以设置密码的有效期、最小间隔时间、最小长度,并在密码过期前进行提示。同时还介绍了如何进行公钥登录和修改默认账户用户名的操作。详细步骤和注意事项可参考本文内容。 ... [详细]
  • 搭建Windows Server 2012 R2 IIS8.5+PHP(FastCGI)+MySQL环境的详细步骤
    本文详细介绍了搭建Windows Server 2012 R2 IIS8.5+PHP(FastCGI)+MySQL环境的步骤,包括环境说明、相关软件下载的地址以及所需的插件下载地址。 ... [详细]
  • 本文介绍了如何使用php限制数据库插入的条数并显示每次插入数据库之间的数据数目,以及避免重复提交的方法。同时还介绍了如何限制某一个数据库用户的并发连接数,以及设置数据库的连接数和连接超时时间的方法。最后提供了一些关于浏览器在线用户数和数据库连接数量比例的参考值。 ... [详细]
  • Centos7.6安装Gitlab教程及注意事项
    本文介绍了在Centos7.6系统下安装Gitlab的详细教程,并提供了一些注意事项。教程包括查看系统版本、安装必要的软件包、配置防火墙等步骤。同时,还强调了使用阿里云服务器时的特殊配置需求,以及建议至少4GB的可用RAM来运行GitLab。 ... [详细]
  • 本文介绍了Hyperledger Fabric外部链码构建与运行的相关知识,包括在Hyperledger Fabric 2.0版本之前链码构建和运行的困难性,外部构建模式的实现原理以及外部构建和运行API的使用方法。通过本文的介绍,读者可以了解到如何利用外部构建和运行的方式来实现链码的构建和运行,并且不再受限于特定的语言和部署环境。 ... [详细]
  • 图解redis的持久化存储机制RDB和AOF的原理和优缺点
    本文通过图解的方式介绍了redis的持久化存储机制RDB和AOF的原理和优缺点。RDB是将redis内存中的数据保存为快照文件,恢复速度较快但不支持拉链式快照。AOF是将操作日志保存到磁盘,实时存储数据但恢复速度较慢。文章详细分析了两种机制的优缺点,帮助读者更好地理解redis的持久化存储策略。 ... [详细]
  • http:my.oschina.netleejun2005blog136820刚看到群里又有同学在说HTTP协议下的Get请求参数长度是有大小限制的,最大不能超过XX ... [详细]
  • 本文介绍了在Linux下安装Perl的步骤,并提供了一个简单的Perl程序示例。同时,还展示了运行该程序的结果。 ... [详细]
  • 本文介绍了RPC框架Thrift的安装环境变量配置与第一个实例,讲解了RPC的概念以及如何解决跨语言、c++客户端、web服务端、远程调用等需求。Thrift开发方便上手快,性能和稳定性也不错,适合初学者学习和使用。 ... [详细]
  • 计算机存储系统的层次结构及其优势
    本文介绍了计算机存储系统的层次结构,包括高速缓存、主存储器和辅助存储器三个层次。通过分层存储数据可以提高程序的执行效率。计算机存储系统的层次结构将各种不同存储容量、存取速度和价格的存储器有机组合成整体,形成可寻址存储空间比主存储器空间大得多的存储整体。由于辅助存储器容量大、价格低,使得整体存储系统的平均价格降低。同时,高速缓存的存取速度可以和CPU的工作速度相匹配,进一步提高程序执行效率。 ... [详细]
  • 如何在服务器主机上实现文件共享的方法和工具
    本文介绍了在服务器主机上实现文件共享的方法和工具,包括Linux主机和Windows主机的文件传输方式,Web运维和FTP/SFTP客户端运维两种方式,以及使用WinSCP工具将文件上传至Linux云服务器的操作方法。此外,还介绍了在迁移过程中需要安装迁移Agent并输入目的端服务器所在华为云的AK/SK,以及主机迁移服务会收集的源端服务器信息。 ... [详细]
  • 本文介绍了在CentOS上安装Python2.7.2的详细步骤,包括下载、解压、编译和安装等操作。同时提供了一些注意事项,以及测试安装是否成功的方法。 ... [详细]
author-avatar
用户yfkae7hw22
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有