centos/linux下面用rpm方法安装mysql5.1

首先还是要下载,因为我是64位的linux,所以下载的是64bit的版本,需要下三个文件server和

64bit mysql 下载地址
MySQL-server-community-5.1.36-0.rhel5.x86_64.rpm
http://dev.mysql.com/get/Downloads/MySQL-5.1/MySQL-server-community-5.1.36-0.rhel5.x86_64.rpm/from/ftp://mysql.cdpa.nsysu.edu.tw/Unix/Database/MySQL/
MySQL-client-community-5.1.36-0.rhel5.x86_64.rpm
http://dev.mysql.com/get/Downloads/MySQL-5.1/MySQL-client-community-5.1.36-0.rhel5.x86_64.rpm/from/ftp://ftp.stu.edu.tw/pub/Unix/Database/Mysql/
MySQL-devel-community-5.1.36-0.rhel5.x86_64.rpm
http://dev.mysql.com/get/Downloads/MySQL-5.1/MySQL-devel-community-5.1.36-0.rhel5.x86_64.rpm/from/ftp://ftp.mirror.tw/pub/mysql/

32bit和更多下载镜像,请自己上www.mysql.com下载

这里预设下载目录为/usr/local/src/
依次执行以下命令
#下载所需rpm包

cd /usr/local/src/
wget http://dev.mysql.com/get/Downloads/MySQL-5.1/MySQL-server-community-5.1.36-0.rhel5.x86_64.rpm/from/ftp://mysql.cdpa.nsysu.edu.tw/Unix/Database/MySQL/
wget http://dev.mysql.com/get/Downloads/MySQL-5.1/MySQL-client-community-5.1.36-0.rhel5.x86_64.rpm/from/ftp://ftp.stu.edu.tw/pub/Unix/Database/Mysql/
wget http://dev.mysql.com/get/Downloads/MySQL-5.1/MySQL-devel-community-5.1.36-0.rhel5.x86_64.rpm/from/ftp://ftp.mirror.tw/pub/mysql/

#开始安装

rpm -ivh MySQL-server-community-5.1.36-0.rhel5.x86_64.rpm MySQL-client-community-5.1.36-0.rhel5.x86_64.rpm MySQL-devel-community-5.1.36-0.rhel5.x86_64.rpm

然后运行一下mysql看是否安装成功
mysql
提示:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.1.36-community-log MySQL Community Server (GPL)
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql>

即为安装成功

修改登录密码:

mysqladmin -u root password ‘new-password’
格式:mysqladmin -u用户名 -p旧密码 password 新密码

再次登录

mysql -u root -p