CentOS下以RPM方式安装MySQL5.5。
首先去mySQL官网下载页面:
dev.mysql/downloads/mysql/#downloads
Select Platform 选择 Oracle & Red Hat Linux 4 & 5
分别下载以下三个文件(由于我的机器是32位,下面是32位版本的包,如果你的机器是64位的请下载64位版本):
1. Red Hat & Oracle Linux 5 (x86, 32-bit), RPM Package
MySQL Server
2. Red Hat & Oracle Linux 5 (x86, 32-bit), RPM Package
Client Utilities
3. Red Hat & Oracle Linux 5 (x86, 32-bit), RPM Package
Development Libraries
使用wget命令使用断点传输的方式将这三个文件下载
[plain] view plain copy print?
wget -c cdn.mysql/Downloads/MySQL-5.5/MySQL-server-5.5.28-1.rhel5.i386.rpm
wget -c cdn.mysql/Downloads/MySQL-5.5/MySQL-client-5.5.28-1.rhel5.i386.rpm
wget -c cdn.mysql/Downloads/MySQL-5.5/MySQL-devel-5.5.28-1.rhel5.i386.rpm
下载完成后开始安装:
rpm -ivh MySQL-server-5.5.28-1.rhel5.i386.rpm rpm -ivh MySQL-client-5.5.28-1.rhel5.i386.rpm rpm -ivh MySQL-devel-5.5.28-1.rhel5.i386.rpm[plain] view plain copy print?
error: Failed dependencies:
libaio.so.1()(64bit) is needed by MySQL-server-5.5.28-1.rhel5.x86_64
libaio.so.1(LIBAIO_0.1)(64bit) is needed by MySQL-server-5.5.28-1.rhel5.x86_64
libaio.so.1(LIBAIO_0.4)(64bit) is needed by MySQL-server-5.5.28-1.rhel5.x86_64
error: Failed dependencies:
libaio.so.1()(64bit) is needed by MySQL-server-5.5.28-1.rhel5.x86_64
libaio.so.1(LIBAIO_0.1)(64bit) is needed by MySQL-server-5.5.28-1.rhel5.x86_64
libaio.so.1(LIBAIO_0.4)(64bit) is needed by MySQL-server-5.5.28-1.rhel5.x86_64
是依赖库缺少,安装依赖库即可
[plain] view plain copy print?
yum install libaio
提示安装完成后,输入mysql 看是否安装成功[plain] view plain copy print?
mysql
[plain] view plain copy print?
service mysql start
然后再输入mysql,若出现以下提示信息,说明成功。[plain] view plain copy print?
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.16 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, 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.
如果出现错误
[plain] view plain copy print?
Starting MySQL…. ERROR! The server quit without updating PID file (/var/lib/mysql/lechiexxxxx.pid).
[plain] view plain copy print?
[ERROR] Fatal error: Can’t open and lock privilege tables: Table ‘mysql.host’ doesn’t exist
121012 15:12:05 mysqld_safe mysqld from pid file /var/lib/mysql/lechiexxxxxx.pid ended
[ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
121012 15:12:05 mysqld_safe mysqld from pid file /var/lib/mysql/lechiexxxxxx.pid ended
所以是少了表。
执行表的初始化
[plain] view plain copy print?
之后执行启动还是失败,查看日志:[plain] view plain copy print?
[ERROR] Failed to open log (file ’./mysql-bin.000004’, errno 13)
应该是没有权限了,赋予mysql权限[plain] view plain copy print?
chown -R mysql:mysql /var/lib/mysql/
[plain] view plain copy print?
我一般是一直回车几次退出 putty或secureCRT,然后重开一个会话即可
[plain] view plain copy print?
whereis mysql
来查看到底安装到哪里去了。[plain] view plain copy print?
cp /usr/share/mysql/my-huge.cnf /etc/my.cnf
[plain] view plain copy print?
例如: /usr/bin/mysqladmin -u root password 123456[plain] view plain copy print?
mysql -u root –p新密码XXXXX