最近项目需要用到MySQL,由于服务器无法上外网,安装MySQL时,只能上载安装包到服务器进行离线安装。
安装分以下几步:
1、检查服务器的位数
root:~ # arch
x86_64
x86_64 是64位系统
x86 是32位系统
或者
root:~ # cat /proc/cpuinfo | grep flags | grep ' lm ' | wc -l
16
结果大于0, 说明支持64bit计算,否则是32bit的. lm指long mode, 支持lm则是64bit。
2、下载RPM安装包
由于官网(http://www.mysql.com)太慢,我选择了国内搜狐的镜像站(http://mirrors.sohu.com/mysql/),进去选择自己所需的版本,注意对应自己的操作系统版本,否则依赖包的版本关系会搞死人。
mysql我选择了5.1,对应下载了我服务器suse10的版本,对于服务器上面的常规使用,下载server和client就够用了。
MySQL-server-community-5.1.73-1.sles10.x86_64.rpm
MySQL-client-community-5.1.73-1.sles10.x86_64.rpm
3、安装mysql服务端
root:/home/install/mysql_for_suse10 # rpm -ivh MySQL-server-community-5.1.73-1.sles10.x86_64.rpm
Preparing... ########################################### [100%]
1:MySQL-server-community ########################################### [100%]
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h Test-I2000 password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
Please report any problems with the /usr/bin/mysqlbug script!
Starting MySQL. done
Giving mysqld 2 seconds to start
看到Giving mysqld 2 seconds to start,证明安装成功
4、安装mysql客户端
root:/home/install/mysql_for_suse10 # rpm -ivh MySQL-client-community-5.1.73-1.sles10.x86_64.rpm
Preparing... ########################################### [100%]
1:MySQL-client-community ########################################### [100%]
root:/home/install/mysql_for_suse10 # mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.73-community MySQL Community Server (GPL)
Copyright (c) 2000, 2013, 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.
mysql>
看到以上内容,则证明客户端安装成功