MySQL安装过程中出现的问题(二)

2014-11-24 10:33:01 · 作者: · 浏览: 4
munity Server (GPL) 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_secret中
[html] 
cat .mysql_secret  
进入mysql之后需要设置密码,否则不能进行任何操作,如果提示ERROR 1862 (HY000): Your password has expired. To log in you must

change it using a client that supports expired passwords. \

那么也需要重新设置密码
MySQL文档中词条MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS有下面的信息
查找SET PASSWORD
为root用户设置新密码
[html] 
set password for ‘root’@’localhost’=password(‘root’)  

之后可以进行正常的操作
忘记mysql root密码的解决方法
一. MySQL密码的恢复方法之一
如果忘记了MySQL的root密码,可以用以下方法重新设置:
1. KILL掉系统里的MySQL进程;

[html] 
killall -TERM mysqld  
2. 用以下命令启动MySQL,以不检查权限的方式启动;
[html] 
safe_mysqld --skip-grant-tables &  

3. 然后用空密码方式使用root用户登录 MySQL;
[html] 
mysql -u root  
4. 修改root用户的密码;
[html] 
mysql> update mysql.user set password=PASSWORD('新密码') where User='root';  
  
mysql> flush privileges;  
  
mysql> quit  

重新启动MySQL,就可以使用新密码登录了。
二. MySQL密码的恢复方法二
有可能你的系统没有 safe_mysqld 程序(比如我现在用的 ubuntu操作系统, apt-get安装的mysql) , 下面方法可以恢复
1. 停止mysqld;
[html] 
/etc/init.d/mysql stop  

(您可能有其它的方法,总之停止mysqld的运行就可以了)
2. 用以下命令启动MySQL,以不检查权限的方式启动;
[html] 
mysqld --skip-grant-tables &  

3. 然后用空密码方式使用root用户登录 MySQL;
mysql -u root
4. 修改root用户的密码;
[html] 
mysql> update mysql.user set password=PASSWORD('newpassword') where User='root';  
  
mysql> flush privileges;  
  
mysql> quit  

重新启动MySQL
[html] 
/etc/init.d/mysql restart  

就可以使用新密码 newpassword 登录了
mysql The server quit without updating PID file异常解决办法
安装好mysql后,用
Java代码
/usr/local/mysql/bin/mysqld_safe &
去启动mysql,总是处于僵死状态,后来去suport_files 用mysql.server start 来启动,
提示mysql The server quit without updating PID file。在网上找了下,原来说是有mysql
启动的僵死进程。
用ps -ef |grep mysql 发现有
Php代码  

root      4507     1  0 21:40          00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe -

-user=mysql  

mysql     4793  4507  0 21:40          00:00:03 /usr/local/mysql/bin/mysqld --basedir=

/usr/local/mysql.......  

于是kill 4793,再启动。就正常了
ps:kill root下的进程4507是没
Mysql报错的解决'Can't connect to local MySQL server through socket '/tmp/mysql.sock'
[root@localhost mysql]# mysql

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)

[root@localhost mysql]# service mysqld restart 这里说明mysqld并没有启动,

MySQL manager or server PID file could not be found!       [FAILED]

Starting MySQL/etc/init.d/mysqld: line 159: kill: (18977) - No such process

                                                           [FAILED]

[root@localhost mysql]# cd bin

[root@localhost bin]# ./mysql

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)        这里就说了不能通过/tmp/mysql.sock连接数据库。

[root@localhost bin]# cd /tmp    进去检查,看到有这个文件,所以看别的原因。

[root@localhost tmp]# ls

gconfd-root  mapping-root  mysql.sock  mysql-test-ports  mysql-test-ports.sem  scim-panel-socket:0-root  VMwareDnD