OS: rhel 7.3
在红帽操作系统中启动mysql实例报错
[root@localhost mysql-5.6.40]# ./bin/mysqld_safe --basedir=/mysql/mysql-5.6.40 --datadir=/data/db/ --socket=/data/db/mysql.sock --log-error=/data/db/mysql_error.log&
[1] 8040
[root@localhost mysql-5.6.40]# 180723 17:37:36 mysqld_safe Logging to '/data/db/mysql_error.log'.
180723 17:37:36 mysqld_safe Starting mysqld daemon with databases from /data/db
180723 17:37:36 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended
[1]+ 完成 ./bin/mysqld_safe --basedir=/mysql/mysql-5.6.40 --datadir=/data/db/ --socket=/data/db/mysql.sock --log-error=/data/db/mysql_error.log
[root@localhost mysql-5.6.40]#
查看mysql_error.log
[root@localhost db]# tail -10 mysql_error.log
2018-07-23 17:05:01 6412 [Note] InnoDB: 5.6.40 started; log sequence number 1625987
2018-07-23 17:05:01 6412 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUI
D: 7b434fd8-8e57-11e8-bdb5-000c298119c8.
2018-07-23 17:05:01 6412 [Note] Server hostname (bind-address): '*'; port: 3306
2018-07-23 17:05:01 6412 [Note] IPv6 is available.
2018-07-23 17:05:01 6412 [Note] - '::' resolves to '::';
2018-07-23 17:05:01 6412 [Note] Server socket created on IP: '::'.
2018-07-23 17:05:01 6412 [ERROR] Can't start server: can't check PID filepath: No such file or directory
[root@localhost db]#
报错原因:找不到PID文件路径。
解决办法:
[root@localhost mysql-5.6.40]# mkdir -p /var/run/mariadb/
[root@localhost mysql-5.6.40]# chown -R mysql:mysql /var/run/mariadb/
[root@localhost mysql-5.6.40]# ./bin/mysqld_safe --basedir=/mysql/mysql-5.6.40 --datadir=/data/db/ --socket=/data/db/mysql.sock --log-error=/data/db/mysql_error.log&
[1] 8253
[root@localhost mysql-5.6.40]# 180723 17:38:10 mysqld_safe Logging to '/data/db/mysql_error.log'.
180723 17:38:10 mysqld_safe Starting mysqld daemon with databases from /data/db
验证:
[root@localhost mysql-5.6.40]# ps -ef | grep mysqld
root 8253 5909 0 17:38 pts/2 00:00:00 /bin/sh ./bin/mysqld_safe --basedir=/mysql/mysql-5.6.40 --datadir=/data/db/ --socket=/data/db/mysql.sock --log-error=/data/db/mysql_error.log
mysql 8439 8253 4 17:38 pts/2 00:00:00 /mysql/mysql-5.6.40/bin/mysqld --basedir=/mysql/mysql-5.6.40 --datadir=/data/db --plugin-dir=/mysql/mysql-5.6.40/lib/plugin --user=mysql --log-error=/data/db/mysql_error.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/data/db/mysql.sock
root 8462 5909 0 17:38 pts/2 00:00:00 grep --color=auto mysqld