如何在 ubuntu 10.4 上恢复我的 mysql 5.1?

如何在 ubuntu 10.4 上恢复我的 mysql 5.1?

我遇到了大麻烦,无法访问我的 mysql 服务器。重启后

grep mysql /var/log/syslog 显示

Jul 30 14:30:23 of-desktop kernel: [ 4763.427066] type=1505 audit(1280480423.517:20):  operation="profile_replace" pid=11282 name="/usr/sbin/mysqld"
Jul 30 14:34:22 of-desktop kernel: [    8.780926] type=1505 audit(1280480662.866:5):  operation="profile_load" pid=803 name="/usr/sbin/mysqld"
Jul 30 14:34:24 of-desktop init: mysql main process (813) terminated with status 1
Jul 30 14:34:24 of-desktop init: mysql main process ended, respawning

在发出命令时

sudo service mysql start

它悬着。

ctrl+c 将结束它。再次给出相同的命令是

start: Job is already running: mysql

grep -v '^#" /etc/mysql/my.cnf

[client]
port        = 3306
socket      = /var/run/mysqld/mysqld.sock
[mysqld]
port        = 3306
socket      = /var/run/mysqld/mysqld.sock
skip-locking
key_buffer_size = 384M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
thread_concurrency = 8
log-bin=mysql-bin
server-id   = 1
[mysqldump]
quick
max_allowed_packet = 16M
 [mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
 [mysqlhotcopy]
interactive-timeout

dpkg -l|grep mysql 给出

ii  libdbd-mysql-perl                    4.012-1ubuntu1                                  A Perl5 database interface to the MySQL data
ii  libmysqlclient16                     5.1.41-3ubuntu12.3                              MySQL database client library
ii  libqt4-sql-mysql                     4:4.6.2-0ubuntu5                                Qt 4 MySQL database driver
ii  mysql-client                         5.1.41-3ubuntu12.3                              MySQL database client (metapackage depending
ii  mysql-client-5.1                     5.1.41-3ubuntu12.3                              MySQL database client binaries
ii  mysql-client-core-5.1                5.1.41-3ubuntu12.3                              MySQL database core client binaries
ii  mysql-common                         5.1.41-3ubuntu12.3                              MySQL database common files (e.g. /etc/mysql
ii  mysql-server                         5.1.41-3ubuntu12.3                              MySQL database server (metapackage depending
ii  mysql-server-5.1                     5.1.41-3ubuntu12.3                              MySQL database server binaries
ii  mysql-server-core-5.1                5.1.41-3ubuntu12.3                              MySQL database core server files
ii  php5-mysql                           5.3.2-1ubuntu4.2                                MySQL module for php5

grep mysql /var/log/daemon.log

Jul 30 14:30:23 of-desktop mysqld[11230]: 
Jul 30 14:30:23 of-desktop mysqld[11230]: PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
Jul 30 14:30:23 of-desktop mysqld[11230]: To do so, start the server, then issue the following commands:
Jul 30 14:30:23 of-desktop mysqld[11230]: 
Jul 30 14:30:23 of-desktop mysqld[11230]: /usr/bin/mysqladmin -u root password 'new-password'
Jul 30 14:30:23 of-desktop mysqld[11230]: /usr/bin/mysqladmin -u root -h of-desktop password 'new-password'
Jul 30 14:30:23 of-desktop mysqld[11230]: 
Jul 30 14:30:23 of-desktop mysqld[11230]: Alternatively you can run:
Jul 30 14:30:23 of-desktop mysqld[11230]: /usr/bin/mysql_secure_installation
Jul 30 14:30:23 of-desktop mysqld[11230]: 
Jul 30 14:30:23 of-desktop mysqld[11230]: which will also give you the option of removing the test
Jul 30 14:30:23 of-desktop mysqld[11230]: databases and anonymous user created by default.  This is
Jul 30 14:30:23 of-desktop mysqld[11230]: strongly recommended for production servers.
Jul 30 14:30:23 of-desktop mysqld[11230]: 
Jul 30 14:30:23 of-desktop mysqld[11230]: See the manual for more instructions.
Jul 30 14:30:23 of-desktop mysqld[11230]: 
Jul 30 14:30:23 of-desktop mysqld[11230]: Please report any problems with the /usr/bin/mysqlbug script!
Jul 30 14:30:23 of-desktop mysqld[11230]: 
Jul 30 14:30:23 of-desktop mysqld[11230]: The latest information about MySQL is available at http://www.mysql.com/
Jul 30 14:30:23 of-desktop mysqld[11230]: Support MySQL by buying support/licenses from http://shop.mysql.com/
Jul 30 14:30:23 of-desktop mysqld[11230]: 
Jul 30 14:30:23 of-desktop mysqld[11263]: #007/usr/sbin/mysqld: File './mysql-bin.index' not found (Errcode: 13)
Jul 30 14:30:23 of-desktop mysqld[11263]: 100730 14:30:23 [ERROR] Aborting
Jul 30 14:30:23 of-desktop mysqld[11263]: 
Jul 30 14:30:23 of-desktop mysqld[11263]: 100730 14:30:23 [Note] /usr/sbin/mysqld: Shutdown complete
Jul 30 14:30:23 of-desktop mysqld[11263]: 
Jul 30 14:30:23 of-desktop mysqld[11271]: #007/usr/sbin/mysqld: File './mysql-bin.index' not found (Errcode: 13)
Jul 30 14:30:23 of-desktop mysqld[11271]: 100730 14:30:23 [ERROR] Aborting
Jul 30 14:30:23 of-desktop mysqld[11271]: 
Jul 30 14:30:23 of-desktop mysqld[11271]: 100730 14:30:23 [Note] /usr/sbin/mysqld: Shutdown complete
Jul 30 14:30:23 of-desktop mysqld[11271]: 
Jul 30 14:30:23 of-desktop mysqld[11275]: #007/usr/sbin/mysqld: File './mysql-bin.index' not found (Errcode: 13)
Jul 30 14:30:23 of-desktop mysqld[11275]: 100730 14:30:23 [ERROR] Aborting
Jul 30 14:30:23 of-desktop mysqld[11275]: 
Jul 30 14:30:23 of-desktop mysqld[11275]: 100730 14:30:23 [Note] /usr/sbin/mysqld: Shutdown complete
Jul 30 14:30:23 of-desktop mysqld[11275]: 
Jul 30 14:30:23 of-desktop mysqld[11279]: #007/usr/sbin/mysqld: File './mysql-bin.index' not found (Errcode: 13)
Jul 30 14:30:23 of-desktop mysqld[11279]: 100730 14:30:23 [ERROR] Aborting
Jul 30 14:30:23 of-desktop mysqld[11279]: 
Jul 30 14:30:23 of-desktop mysqld[11279]: 100730 14:30:23 [Note] /usr/sbin/mysqld: Shutdown complete
Jul 30 14:30:23 of-desktop mysqld[11279]: 
Jul 30 14:34:24 of-desktop init: mysql main process (813) terminated with status 1
Jul 30 14:34:24 of-desktop init: mysql main process ended, respawning

可能是什么问题?谢谢...

答案1

你检查过吗/var/log/daemon.log? 也许它正在忙于重建/检查损坏的表,如果它最近崩溃了,可能需要一段时间。

你也可以尝试顶部,查看 mysql 进程是否没有变成僵尸进程或者停滞等待 I/O(符号 D,而不是 S),在这种情况下您可能遇到了硬盘问题。

答案2

重启前您是否更改了 MySQL 设置?重启是指“哎呀,我的服务器崩溃了,重启期间 MySQL 无法启动”还是“我刚刚尝试重启 MySQL”。

您可能需要检查以下两件事:

  • 文件权限是否/var/lib/mysql好吗?MySQL 用户可以访问那里吗?这是我的 Ubuntu 10.04 中的 /var/lib/mysql:

    drwx------  4 mysql mysql 4.0K 2010-07-28 20:42 .
    drwxr-xr-x 68 root  root  4.0K 2010-07-28 15:13 ..
    -rw-r--r--  1 root  root     0 2010-07-28 13:04 debian-5.1.flag
    -rw-rw----  1 mysql mysql  10M 2010-07-28 20:42 ibdata1
    -rw-rw----  1 mysql mysql 5.0M 2010-07-28 20:42 ib_logfile0
    -rw-rw----  1 mysql mysql 5.0M 2010-07-28 13:04 ib_logfile1
    drwx------  2 mysql root  4.0K 2010-07-28 13:04 mysql
    
  • 您是否更改了以下路径/etc/mysql/my.cnf? 也许 MySQL 正在从错误的地方寻找 mysql-bin.index?

答案3

尝试在 my.cnf 中设置 datadir,通常 datadir=/var/lib/mysql。

答案4

我找到了问题所在。昨天我安装了 squid,然后禁用了它。所以没问题。当我重新启动 squid 时,它自动启用了,并阻止了 mysql(我认为)。现在我完全删除了它,mysql 就可以正常工作了。我不知道为什么。但问题出在 squid 上。谢谢你的帮助。爱你的 kumar。

相关内容