#############################################
我以为会重新生成默认的/etc/my.cnf,发现没有。又找了一台服务器安装了mysql,导出默认的/etc/my.cnf
###################################
重装之后,在不修改默认配置是可以正常启动的。但只要导入生产/etc/my.cnf配置后又是错误
[root@###### ~]# service mysql start
Starting MySQL (Percona Server).The server quit without upd[FAILED]D file (/home/mysql/mysql.pid).
[root@###### data]# !tail
tail -20 /var/log/mysqld.log
160524 14:07:20 mysqld_safe Starting mysqlddaemon with databases from /data/mysql
2016-05-24 14:07:20 13213 [Warning] Can't create test file/data/mysql/mfs-data3.lower-test
2016-05-24 14:07:20 13213 [Warning] Can'tcreate test file /data/mysql/mfs-data3.lower-test
/usr/sbin/mysqld: File'/data/mysql/mysql-bin.index' not found (Errcode: 13 - Permission denied)
2016-05-24 14:07:20 13213 [ERROR] Aborting
花了点时间找到该错误是由selinux引起的。 关闭selinux
setenforce 0
sed -i "s#enforcing#disabled#g" /etc/selinux/config
再次启动
[root@###### mysql]# service mysql start
Starting MySQL (Percona Server)..The server quit without up[FAILED]ID file (/home/mysql/mysql.pid).
[root@yyqdb02 mysql]# cat log/mysql-error.log
160524 14:31:37 mysqld_safe Starting mysqld daemon with databases from /home/mysql/data/
2016-05-24 14:31:38 6632 [Warning] Can't create test file /data/mysql/data/*.lower-test
2016-05-24 14:31:38 6632 [Warning] Can't create test file /data/mysql/data/*.lower-test
/usr/sbin/mysqld: Can't change dir to '/data/mysql/data/' (Errcode: 2 - No such file or directory)
2016-05-24 14:31:38 6632 [ERROR] Aborting
改为 mysql_install_db --user=mysql --datadir=/data/mysql/data
再次使用/etc/init.d/mysql restart终于成功了。
[root@###### data]# service mysql restart
Shutting down MySQL (Percona Server).. SUCCESS!
Starting MySQL (Percona Server).. SUCCESS!
三、恢复从库身份
之前主库一直有备份,所以不用担心在主库工作时间做主从同步了。
将主备份拷贝到从
[root@##### tmp]# scp 192.168.2.105:/data/bak/all_2016-05-22.sql.gz ./
root@172.30.1.10's password:
all_2016-05-22.sql.gz 100% 21MB 20.9MB/s 00:00
[root@##### tmp]# ls
all_2016-05-22.sql.gz
[root@yyqdb02 tmp]# gzip -d all_2016-05-22.sql.gz
[root@yyqdb02 tmp]# less all_2016-05-22.sql
-- MySQL dump 10.13 Distrib 5.6.20-68.0, for Linux (x86_64)
--
-- Host: localhost Database:
-- ------------------------------------------------------
-- Server version 5.6.20-68.0-log
/*!40101 SET@OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET@OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET@OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS,UNIQUE_CHECKS=0 */;
/*!40014 SET@OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE,SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0*/;
--
-- Position to start replication or point-in-timerecovery from
--
-- CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000042', MASTER_LOG_POS=142703;
--
-- Current Database: `decorate`
--
[root@##### tmp]# service mysql status # mysql服务器运行着
MySQL (Percona Server) running (17022) [ OK ]
[root@yyqdb02 tmp]#mysql -uroot -p < all_2016-05-22.sql
Enter password:
[root@##### tmp]# mysql -uroot -p # 由于没有flush privileges,密码为空。害我输了好几次导入后的root密码
Enter password:
ERROR 1045 (28000): Access denied for user'root'@'localhost' (using password: YES)
[root@###### tmp]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.20-68.0-log Percona Server (GPL),Release 68.0, Revision 656
Copyright (c) 2009-2014 Percona LLC and/or itsaffiliates
Copyright (c) 2000, 2014, Oracle and/or its affiliates.All rights reserved.
Oracle is a registered trademark of Oracle Corporationand/or its
affiliates. Other names may be trademarks of theirrespective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear thecurrent input statement.