第一步:修改pid路径
查看日志文件:
cat /var/log/mysqld.log
2013-10-26 16:39:34 3712 [ERROR] /usr/sbin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2 - No such file or directory)
2013-10-26 16:39:34 3712 [ERROR] Can't start server: can't create PID file: No such file or directory
原因:
mysql 用户没有操作/var/run目录的权限,所以pid文件无法创建,导致登陆时无法建立 进程信息文件,登陆进程就无法开启,自然无法登陆。
解决:
修改 /etc/my.conf
原来的
#pid-file=/var/run/mysqld/mysqld.pid
修改为
pid-file=/var/lib/mysql/mysqlid.pid
检查发现,mysql用户根本无法 cd /var/run/。修改为mysql可以有权限的目录后再执行mysql就进入数据库了。
第二步:修改数据库默认密码
/etc/init.d/mysql stop (service mysqld stop )
/usr/bin/mysqld_safe --skip-grant-tables
另外开个SSH连接
[root@localhost ~]# mysql
mysql>use mysql
mysql>update user set password=password("123456") where user="root";
mysql>flush privileges;
mysql>exit
然后
[mysql@localhost etc]$ ps -A | grep mysql
4532 pts/0 00:00:00 mysqld_safe
5542 pts/0 00:00:00 mysqld
[mysql@localhost etc]$ kill -9 4532 5542
正常启动 MySQL:/etc/init.d/mysql start (service mysqld start)
第三步:
登陆ok。 mysql -uroot -p
相关文章
- Centos7解决MySQL登录ERROR 1045 (28000): Access denied for user ‘‘@‘localhost‘ (using
- ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: N O) MYSQL
- mysql cmd ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: N O)
- 连接本地数据库出现:1045 - Access denied for user 'root'@localhost'(using password:YES) 本人解决方案:
- 解决MySql 数据库 提示:1045 access denied for user 'root'@'localhost' using password YES
- 关于Navicat mysql连接出现1045 access denied for user 'root'@'localhost' using password: yes
- MySQL在登陆时出现ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)错误
- windows XP中,mysql连接时提示:1045 access denied for user 'root'@'localhost' using password yes 的解决方法
- mac os x 安装mysql遇到 Access denied for user 'root'@'localhost' (using password: YES)的解决方法
- (转载)解决MySql 数据库 提示:1045 access denied for user 'root'@'localhost' using password yes