三.解决安装错误
1.根据提示找到日志
[root@TEST mysql]# pwd
/var/lib/mysql
[root@TEST mysql]# ls
ibdata1 ib_logfile0 ib_logfile1 mysql mysql.sock TEST.err test
[root@TEST mysql]# cat TEST.err
080410 15:18:23 mysqld started
080410 15:18:23 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
080410 15:18:23 InnoDB: Starting log scan based on checkpoint at
InnoDB: log sequence number 0 36808.
InnoDB: Doing recovery: scanned up to log sequence number 0 43655
080410 15:18:23 InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percents: 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
InnoDB: Apply batch completed
080410 15:18:24 InnoDB: Started; log sequence number 0 43655
080410 15:18:24 [ERROR] /usr/local/mysql/bin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2)
080410 15:18:24 [ERROR] Can't start server: can't create PID file: No such file or directory
080410 15:18:24 mysqld ended
据此推断,可能是mysql 启动时会向此文件夹内写一些东西,但 mysql 的进程用户mysql 却没有权限写,导致mysql 无法启动,用touch /var/run/mysqld/mysqld.pid 命令创建mysql 所需要文件,chown -R mysql:mysql/var/run/mysqld将/var/run/mysqld 的目录权限转给 mysql.
2.解雇方法
[root@TEST mysql]# cd /var/run/
[root@TEST run]# mkdir mysqld
[root@TEST run]# touch mysqld/mysqld.pid
[root@TEST run]# chown -R mysql:mysql /var/run/mysqld
3.再尝试启动mysql
[root@TEST mysql]# bin/mysqld_safe --user=mysql &
[1] 11723
[root@TEST mysql]# Starting mysqld daemon with databases from /var/lib/mysql
4.测试mysql
[root@TEST mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.26-standard
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.03 sec)
到此安装成功