mysql启动报错和主从同步报错解决方法

启动mysql报错:

(一)进入/var/run/mysql目录下ll查看是否有mysqld.pid这个文件或者这个文件权限是否正确

srwxrwxrwx  1 mysql mysql    0 Jul  3 17:48 mysql.sock=
-rw-rw----  1 mysql mysql    5 Jul  3 17:48 mysqld.pid
-rw-r--r--  1 root  root    22 Jul  3 17:48 tmpdir

修改文件的权限:(并查看属组,属主是否是mysql)

chmod 777 mysqld.pid

重启服务,测试成功。

/etc/init.d/mysql start
Starting service MySQL                                                       done

测试登录mysql是否成功:

[root@localhost mysqld]#/var/run/mysql # mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.5.30-log Source distribution

Copyright (c) 2000, 2013, 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.

mysql>


(二)如果登录报错:

[root@localhost mysqld]# mysql -uroot -p123456
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

修改密码登陆也无效

[root@localhost mysqld]# pkill mysql

[root@localhost mysqld]# ps -ef|grep mysql
root     11644 17452  0 13:29 pts/1    00:00:00 grep mysql

不使用密码连接

root@localhost mysqld]# mysqld_safe --skip-grant-tables &
[1] 11696

以下操作参照

http://6257393.blog.51cto.com/6247393/1228380



主从同步报错

报错如下:

导致这个报错的原因可能是主键重复了,解决方法如下:

1、先到数据库log里面找到保错的position

2.再执行

就ok了。

你可能感兴趣的:(mysql启动报错,主从同步报错)