首先下载;下载MySQL-client-5.1.73-1.glibc23.x86_64.rpm和MySQL-server-5.1.73-1.glibc23.x86_64.rpm
地址:http://ftp.ntu.edu.tw/pub/MySQL/Downloads/MySQL-5.1/
然后把下载好的包拉进Linux系统中!
接下来查看一下Linux系统自己带的数据库;
命令;rpm -qa | grep mysql
我们看到Linux系统中有它自己的数据库,我们要把它卸载掉,换成自己刚刚下载好的数据库,接下来执行卸载命令
rpm -e mysql-libs-5.1.71-1.el6.x86_64
我们发现Linux系统数据库有依赖,但是没关系,也不耽误我们卸载他,执行此命令强行卸载
rpm -e mysql-libs-5.1.71-1.el6.x86_64 --nodeps
卸载成功后,接下来我们安装数据库,我们使用命令rpm -ivh MySQL-server-5.1.73-1.glibc23.x86_64.rpm来进行安装,其中i是安装的意思,v是显示详情的意思,h是显示进度条的意思。
安装成功!我们在来安装MySQL-client-5.1.73-1.glibc23.x86_64.rpm,为了方便配置。
安装命令;rpm -ivh MySQL-client-5.1.73-1.glibc23.x86_64.rpm
然后初始化MySQL
由于我们现在还不知道mysql的用户名和密码,因此我们需要对mysql进行初始化,那么怎么初始化呢?其实我们安装
MySQL-server-5.1.73-1.glibc23.x86_64.rpm的时候人家已经告诉我们了,在安装的信息当中有这么一段话,意思是我们可以使用
/usr/bin/mysql_secure_installation这条命令来进行初始化。
Alternatively you can run:
/usr/bin/mysql_secure_installation
那我们便使用/usr/bin/mysql_secure_installation这个脚本来初始化一下
[root@itcast05 ~]#
/usr/bin/mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
第一个停顿的地方我们直接回车就可以
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
接下来会让我们选择是否现在设置密码,我们选择"Y"
Set root password? [Y/n] Y
这里输入密码,比如我们就用root作为密码
New password:
再次输入密码,我们再次输入root
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
提示是否删除所有匿名用户,我们选择"Y"进行删除。
Remove anonymous users? [Y/n] Y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
提示是否不允许远程连接,我们选择"n"意思是允许远程连接
Disallow root login remotely? [Y/n] n
... skipping.
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
提示是否删除测试数据库,我们不删除,选择n
Remove test database and access to it? [Y/n] n
... skipping.
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
提示是否重新刷新表权限,我们选择"Y"
Reload privilege tables now? [Y/n] Y
... Success!
Cleaning up...
到此我们的mysql初始化便完成了。
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
然后检验一下安装结果,图片截图
安装完成!