Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2771917
  • 博文数量: 154
  • 博客积分: 7136
  • 博客等级: 准将
  • 技术积分: 1428
  • 用 户 组: 管理员
  • 注册时间: 2010-02-21 11:26
文章分类

全部博文(154)

文章存档

2016年(2)

2014年(2)

2013年(4)

2012年(16)

2011年(51)

2010年(68)

2009年(3)

2006年(3)

2005年(5)

分类: Mysql/postgreSQL

2011-10-04 20:44:26

最近我的ubuntu系统sudo装的数据库出现问题,迫于无奈重装,重装启动后用mysql命令客户端连接,出现如下提示:

  1. [LING mysql]$mysql -u root -p
  2.   
  3. Enter password:   
  4. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)  

 我的my.cnf如下:

  1. [mysqld]  
  2. datadir=/var/lib/mysql  
  3. socket=/var/lib/mysql/mysql.sock
  4.   
  5. user=mysql  
  6. # Default to using old password format for compatibility with mysql 3.x  
  7. # clients (those using the mysqlclient10 compatibility package).  
  8. old_passwords=1  
  9.   
  10. [mysqld_safe]  
  11. log-error=/var/log/mysqld.log  
  12. pid-file=/var/run/mysqld/mysqld.pid  
  13. port=3307  

 进入/var/lib/mysql下,发现mysql.sock存在,但/var/run/mysqld下没有mysqld.sock,灵机一动,可以通过软链接的方式使用/var/lib/mysql/mysql.sock:

  1. [ROOT mysqld]$ ln -s /var/lib/mysql/mysql.sock /var/run/mysqld/mysqld.sock
  2.   
  3. [ROOT mysqld]$ mysqld_safe --log-error=/var/lib/mysql/error.log &  

 做链接并启动mysql,查看error.log,如下:

  1. [ROOT mysql]$ more error.log
  2.   
  3. InnoDB: The log sequence number in ibdata files does not match  
  4. InnoDB: the log sequence number in the ib_logfiles!  
  5. 100313 10:48:12  InnoDB: Database was not shut down normally!  
  6. InnoDB: Starting crash recovery.  
  7. InnoDB: Reading tablespace information from the .ibd files...  
  8. InnoDB: Restoring possible half-written data pages from the doublewrite  
  9. InnoDB: buffer...  
  10. 100313 10:48:12  InnoDB: Started; log sequence number 0 43655  
  11. 100313 10:48:12 [Note] /usr/sbin/mysqld: ready for connections.  
  12. Version: '5.0.51a-3ubuntu5.5'  socket: '/var/lib/mysql/mysql.sock'  port: 3307  (Ubuntu)  
  13. [ROOT mysql]$  

 重新链接,成功了!

http://181054867.iteye.com/blog/614640


阅读(19329) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~