【澳门金沙vip】MySQL启动故障处理小记

安装MySQL

因为Oracle已经收购了MySQL,所以商业版的下载地址也转移到了edelivery.oracle.com网站上。需要的朋友可以去自行下载研究,但是要先注册Oracle网站的账号。

如果下载的是GA版本,也就是社区版,直接在

想下载老版本的MySQL,也可以在

注意:只提供使用rpm安装的程序包,大家可以选择。

RPM Bundle把MySQL相关的包都下载下来,以备不时之需。

下载上传到mysql服务器上面,解压后使用rpm命令安装即可

注意,mysql初始密码在/root/.mysql_secret,很容易被忽略,大家第一次使用root用户登陆的时候需要用到。

需要注意的是:

使用rpm安装的后,会有mysql组以及用户添加到操作系统上。

初始的文件目录:

Directory

Contents of Directory

/usr/bin

Client programs and scripts

/usr/sbin

The mysqld serverMySQL

/var/lib/mysql

Log files, databases

/usr/share/info

Manual in Info format

/usr/share/man

Unix manual pages

/usr/include/mysql

Include (header) files

/usr/lib/mysql

Libraries

/usr/share/mysql

Miscellaneous support files, including error messages, character set
files, sample configuration files, SQL for database installation

/usr/share/sql-bench

Benchmarks

使用rpm安装后,可以直接使用service mysql start 命令启动mysql数据库。

启动后会用ps命令可以看到它的启动选项

/usr/sbin/mysqld –basedir=/usr–datadir=/var/lib/mysql
–plugin-dir=/usr/lib/mysql/plugin
–user=mysql–log-error=/var/lib/mysql/mysql01.err
–pid-file=/var/lib/mysql/mysql01.pid

–basedir=/usr 根目录

–datadir=/var/lib/mysql 数据文件存放目录

–plugin-dir=/usr/lib/mysql/plugin 插件存放目录

–user=mysql 启动用户

–log-error=/var/lib/mysql/mysql01.err 错误日志文件path

–pid-file=/var/lib/mysql/mysql01.pid 进程id文件存放位置

默认选项为上述,到/etc/init.d/mysql启动脚本或者my.cnf文件中自行修改。

默认的my.cnf搜索目录是

$BASEDIR/my.cnf—-/etc/my.cnf

因为Oracle已经收购了MySQL,所以商业版的下载地址也转移到了edelivery.oracle.com网站上。需要的朋友可以去自行下载研究,但是要先注…

mysql启动报错-server PID file could not be found解决

 之前启动MySQL时,就不太正常,要多重启几次,不过能启动,也就没放在心上,今天测试测试又出现了问题,MySQL
启动正常,但是无法关闭:
 
[[email protected]
mysql]# service mysql stop
MySQL server PID file could not befound!                  [FAILED]
[[email protected]
mysql]# ./mysql.server stop
MySQL server PID file could not befound!                  [FAILED]
 
这里提示的PID
文件指:/var/lib/mysql/rac2.pid,该文件和/var/lib/mysql/mysql.sock
文件一样,仅在MySQL 运行时存在,后来的验证如下:
 
[[email protected]
lib]# ls /var/lib/mysql/rac2.pid
/var/lib/mysql/rac2.pid
[[email protected]
lib]# service mysql stop
Shutting down MySQL.                                       [  OK  ]
[[email protected]
lib]# ls /var/lib/mysql/rac2.pid
ls: /var/lib/mysql/rac2.pid: No such fileor directory
 
 所以当我的MySQL
运行正常时,应该是存在这个文件的,google的一个说法是my.cnf
参数文件的basedir
参数错误,注释掉这个参数即可,但是我都没有设过这个参数,所以和这个应该没有关系。
 
查看了一下默认值:
mysql> show variables like ‘%basedir%’;
+—————+——-+
| Variable_name | Value |
+—————+——-+
| basedir       | /usr |
+—————+——-+
1 row in set (0.00 sec)
 
[[email protected]
~]# ps -ef|grep mysql
root     2161     1  0 09:38 ?        00:00:00 /bin/sh
/usr/bin/mysqld_safe–datadir=/var/lib/mysql
–pid-file=/var/lib/mysql/rac2.pid
mysql    2418  2161  0 09:38 ?        00:00:00 /usr/sbin/mysqld
–basedir=/usr–datadir=/var/lib/mysql
–plugin-dir=/usr/lib64/mysql/plugin
–user=mysql–log-error=/var/lib/mysql/rac2.err
–pid-file=/var/lib/mysql/rac2.pid–socket=/var/lib/mysql/mysql.sock
–port=3306
root     3628  3596  0 09:57 pts/1    00:00:00 grep mysql
 
–log信息
[[email protected]
~]#cat /var/lib/mysql/rac2.err
111129 9:38:49 [Note] Plugin ‘FEDERATED’ is disabled.
111129 9:38:49 InnoDB: The InnoDB memory heap is disabled
111129 9:38:49 InnoDB: Mutexes and rw_locks use GCC atomic builtins
111129 9:38:49 InnoDB: Compressed tables use zlib 1.2.3
111129 9:38:49 InnoDB: Using Linux native AIO
111129 9:38:49 InnoDB: Initializing buffer pool, size = 128.0M
111129 9:38:50 InnoDB: Completed initialization of buffer pool
111129 9:38:50 InnoDB: highest supported file format is Barracuda.
111129 9:38:50  InnoDB: Waiting for thebackground threads to start
111129 9:38:51 InnoDB: 1.1.8 started; log sequence number 1605950
111129 9:38:52 [Note] Event Scheduler: Loaded 0 events
111129 9:38:52 [Note] /usr/sbin/mysqld: ready for connections.
Version: ‘5.5.15-log’  socket: ‘/var/lib/mysql/mysql.sock’  port: 3306
MySQL Community Server (GPL)
111129 10:50:36 mysqld_safe Starting mysqlddaemon with databases from
/var/lib/mysql
111129 10:50:37 [Note] Plugin ‘FEDERATED’is disabled.
111129 10:50:37 InnoDB: The InnoDB memoryheap is disabled
111129 10:50:37 InnoDB: Mutexes andrw_locks use GCC atomic builtins
111129 10:50:37 InnoDB: Compressed tablesuse zlib 1.2.3
111129 10:50:37 InnoDB: Using Linux nativeAIO
111129 10:50:37 InnoDB: Initializing bufferpool, size = 128.0M
111129 10:50:37 InnoDB: Completedinitialization of buffer pool
InnoDB: Unable to lock ./ibdata1, error: 11
InnoDB: Check that you do not already haveanother mysqld process
InnoDB: using the same InnoDB data or logfiles.
111129 10:50:37  InnoDB: Retrying to lock the first data file
InnoDB: Unable to lock ./ibdata1, error: 11
InnoDB: Check that you do not already haveanother mysqld process
InnoDB: using the same InnoDB data or logfiles.

InnoDB: Check that you do not already haveanother mysqld process
InnoDB: using the same InnoDB data or logfiles.
InnoDB: Unable to lock ./ibdata1, error: 11
InnoDB: Check that you do not already haveanother mysqld process
–这个提示的意思有多个mysqld 进程在运行。
 
 
解决方法:
(1)重新用:ps -ef|grep mysql
查询所有的进程,然后把所有的进程kill掉,
(2)重新对相关的目录赋权
[[email protected]
/]# chown mysql.mysql -R/var/lib/mysql/*
[[email protected]
/]# chmod 755 -R/var/lib/mysql/*
 
–再次启动成功:
[[email protected]
/]# service mysql start
Starting MySQL……                                       [  OK  ]
[[email protected]
/]# ps -ef|grep mysql
root    27936     1  1 14:08 pts/1    00:00:00 /bin/sh
/usr/bin/mysqld_safe–datadir=/var/lib/mysql
–pid-file=/var/lib/mysql/rac2.pid
mysql   28193 27936  3 14:08 pts/1    00:00:00 /usr/sbin/mysqld
–basedir=/usr–datadir=/var/lib/mysql
–plugin-dir=/usr/lib64/mysql/plugin
–user=mysql–log-error=/var/lib/mysql/rac2.err
–pid-file=/var/lib/mysql/rac2.pid–socket=/var/lib/mysql/mysql.sock
–port=3306
root    28220  3596  0 14:08 pts/1    00:00:00 grep mysql
[[email protected]
/]# ll /var/lib/mysql/mysql.sock
srwxrwxrwx 1 mysql mysql 0 Nov 29 14:08/var/lib/mysql/mysql.sock
 
再次查看log:
[[email protected]
lib]#  tail -20 /var/lib/mysql/rac2.err
111129 14:51:53 [Note] Event Scheduler:Purging the queue. 0 events
111129 14:51:53  InnoDB: Starting shutdown…
111129 14:51:54  InnoDB: Shutdown completed; log sequencenumber
1605950
111129 14:51:54 [Note] /usr/sbin/mysqld:Shutdown complete
 
111129 14:51:54 mysqld_safe mysqld from pidfile /var/lib/mysql/rac2.pid
ended
111129 14:53:34 mysqld_safe Starting mysqlddaemon with databases from
/var/lib/mysql
111129 14:53:34 [Note] Plugin ‘FEDERATED’is disabled.
111129 14:53:34 InnoDB: The InnoDB memoryheap is disabled
111129 14:53:34 InnoDB: Mutexes andrw_locks use GCC atomic builtins
111129 14:53:34 InnoDB: Compressed tablesuse zlib 1.2.3
111129 14:53:34 InnoDB: Using Linux nativeAIO
111129 14:53:34 InnoDB: Initializing bufferpool, size = 128.0M
111129 14:53:34 InnoDB: Completed initializationof buffer pool
111129 14:53:35 InnoDB: highest supportedfile format is Barracuda.
111129 14:53:35 InnoDB:1.1.8 started; log sequence number 1605950
111129 14:53:35 [Warning] Neither–relay-log nor –relay-log-index
were used; so replication may break when thisMySQL server acts as a
slave and has his hostname changed!! Please
use’–relay-log=rac2-relay-bin’ to avoid this problem.
111129 14:53:35 [Note] Event Scheduler:Loaded 0 events
111129 14:53:35 [Note]/usr/sbin/mysqld: ready for connections.
Version: ‘5.5.15-log’  socket: ‘/var/lib/mysql/mysql.sock’  port: 3306
MySQL Community Server (GPL)
[[email protected]
lib]#
 
 
说明:
      
因为之前没有保留的相关信息,修改之后,虽重复模拟多次,都不能还原当时的故障,所有缺少足够多的一手资料来证明这个问题。但是我这里的2种方法都可以尝试一下:
   
MySQL server PID file could not befound! 
–可能是相关目录的权限问题导致
 
Check that you do not already have anothermysqld process
–重复进程导致,可以先ps,在kill掉相关进程在重试。

 

作者 tianlesoftware
 

[[email protected]
~]# service mysql stop

启动正常,但是无法关闭:…

MySQL server PID file could not be found!                  [失败]

  www.2cto.com  

解决方案如下:

 

首先查看下与mysql有关的进程

 

[[email protected]
~]# ps aux |grep mysq*

root      2019  0.0  0.1   6228  1392 ?        S    09:22   0:00 /bin/sh
/usr/bin/mysqld_safe –datadir=/var/lib/mysql
–pid-file=/var/lib/mysql/yunhe.pid

mysql     2115  0.0  2.9 353596 30808 ?        Sl   09:22   0:01
/usr/sbin/mysqld –basedir=/usr –datadir=/var/lib/mysql
–plugin-dir=/usr/lib/mysql/plugin –user=mysql
–log-error=/var/lib/mysql/yunhe.err –pid-file=/var/lib/mysql/yunhe.pid

500       4258  0.0  1.6  83432 17484 ?        S    09:35   0:01 gedit
/usr/share/mysql/my-medium.cnf

root      5555  0.0  0.0   5936   768 pts/0    S+   10:04   0:00 grep
mysq*