您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息
三六零分类信息网 > 阿里分类信息网,免费分类信息发布

阿里云安装mysql

2024/6/17 9:05:46发布24次查看
1 、申请阿里云 linux 服务器 昨天在阿里云申请了一个免费试用 5 天的 linux 云服务器。 操作系统: red hat enterprise linux server 5.4 64 位。 cpu : 1 核 内存: 512m 硬盘空间: 20g 带宽: 1mbps 。 今天在这台云服务器上安装了基本环境( jdk 、 to
1、申请阿里云linux服务器昨天在阿里云申请了一个免费试用5天的linux云服务器。
操作系统:red hat enterprise linux server 5.4 64位。
cpu:1核
内存:512m
硬盘空间:20g
带宽:1mbps。
今天在这台云服务器上安装了基本环境(jdk、tomcat和mysql)。本文主要在阿里云linux云服务器安装mysql全过程,以及对安装时遇到的问题进行记录。
2、下载mysql服务器和客户端         访问mysql的官网,进入其下载页面(http://dev.mysql.com/downloads/mysql/#downloads),选择mysql community server,在“select platform”下拉框中选择“oracle & red hat linux 4 & 5”。
         因为是64位的操作系统,所以选择下载如下rpm包:
(1)mysql-server-5.6.10-1.rhel5.x86_64.rpm:mysql服务器;
(2)mysql-client-5.6.10-1.rhel5.x86_64.rpm:mysql客户端;
(3)mysql-devel-5.6.10-1.rhel5.x86_64.rpm:mysql开发依赖包。
将这些rpm包通过ftp上传到linux服务器的某个目录,例如:/root/software。
也可在linux服务器上通过wget命令取得这些rpm包,linux命令如下:
wget –c http://dev.mysql.com/get/downloads/mysql-5.6/mysql-server-5.6.10-1.rhel5.x86_64.rpm/from/http://cdn.mysql.com
wget –c http://dev.mysql.com/get/downloads/mysql-5.6/mysql-client-5.6.10-1.rhel5.x86_64.rpm/from/http://cdn.mysql.com
wget –c http://dev.mysql.com/get/downloads/mysql-5.6/mysql-devel-5.6.10-1.rhel5.x86_64.rpm/from/http://cdn.mysql.co
3、安装mysql服务器和客户端3.1 安装mysql服务器         下载完成后使用如下命令开始安装mysql服务器:
rpm -ivh mysql-server-5.6.10-1.rhel5.x86_64.rpm
3.1.1 安装依赖包libaio在运行第一条安装mysql服务器时会提示依赖包libaio.so.1没有安装,错误提示如下:
error: failed dependencies: 
libaio.so.1()(64bit) is needed by mysql-server-5.6.10-1.rhel5.x86_64 
libaio.so.1(libaio_0.1)(64bit) is needed by mysql-server-5.6.10-1.rhel5.x86_64
libaio.so.1(libaio_0.4)(64bit) is needed by mysql-server-5.6.10-1.rhel5.x86_64
需要使用yum命令快速安装依赖包libaio,运行如下命令:
yum install libaio
运行该命令时会发现在这台云服务器上无法通过yum快速安装软件,搜索了一些资料,原来是阿里云安装的是red hat5.4的64位系统,但是提供的是centos 32位的系统。错误信息参考如下:
setting up install process 
no package libaio available.
nothing to do
    网上找到的一个解决方案是将yum替换成centos的版本,我尝试了下是可行的。过程如下:
(1)通过rpm命令查看有哪些yum包,然后进行卸载
笔者在云服务器进行的操作如下:
[root@ay130221101729bc93912 software]# rpm -qa|grep yum
yum-3.2.22-20.el5
yum-metadata-parser-1.1.2-3.el5
[root@ay130221101729bc93912 software]# rpm -e --nodeps yum-3.2.22-20.el5
warning: /etc/yum.conf saved as /etc/yum.conf.rpmsave
[root@ay130221101729bc93912 software]# rpm -e --nodeps yum-metadata-parser-1.1.2-3.el5
(2)通过wget命令在163的镜像上下载centos的yum包
参考命令如下:
wget http://mirrors.163.com/centos/5/os/x86_64/centos/yum-3.2.22-40.el5.centos.noarch.rpm
wget http://mirrors.163.com/centos/5/os/x86_64/centos/yum-metadata-parser-1.1.2-4.el5.x86_64.rpm 
wget http://mirrors.163.com/centos/5/os/x86_64/centos/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
说明:可能版本会有一些不同,请大家在http://mirrors.163.com/centos/5/os/x86_64/centos/下查找yum-3xxx开头、yum-metadata开头和yum-fastestmirror开头的rpm包下载。
    (3)安装yum相关的rpm包
     使用如下命令安装在(2)中下载的rpm包:
rpm -ivh yum-*
   (4)下载centos-base.repo
找一个centos的包资源配置库,名为centos-base.repo,放到/etc/yum.repos.d/路径:
[root@ay130221101729bc93912 software]# cd /etc/yum.repos.d/
[root@ay130221101729bc93912 yum.repos.d]# wget http://www.linuxidc.com/files/2011/05/06/centos-base.repo
--2013-02-22 08:58:27-- http://www.linuxidc.com/files/2011/05/06/centos-base.repo
resolving www.linuxidc.com 60.191.129.94
connecting to www.linuxidc.com|60.191.129.94|:80 connected.
http request sent, awaiting response 200 ok
length: 1426 (1.4k) [application/octet-stream]
saving to: `centos-base.repo'
100%[==========================================================================================>] 1,426       --.-k/s   in 0s
2013-02-22 08:58:28 (124 mb/s) - `centos-base.repo' saved [1426/1426]
(5)生成缓存文件到/var/cache/yum目录
[root@ay130221101729bc93912 yum.repos.d]# yum makecache
loaded plugins: fastestmirror
determining fastest mirrors
addons                                                                                  | 1.9 kb     00:00     
addons/filelists_db                                                             | 568 b     00:00
addons/other_db                                                                                   
base   
……                                                                                                                                                    3641/3641
base                                                                                                                      3641/3641
metadata cache createdp align=justify>p>
(6)安装依赖包libaio
第(5)步做完后,此时可以成功运行yum install libaio命令,参考执行情况如下:
[root@ay130221101729bc93912 yum.repos.d]# yum install libaio 
loaded plugins: fastestmirror
loading mirror speeds from cached hostfile
setting up install process
resolving dependencies
……
complete
3.1.2 安装mysql server的rpm包         依赖包安装完成后,可以执行rpm -ivh mysql-server-5.6.10-1.rhel5.x86_64.rpm包安装mysql的服务器端。参考执行情况如下(省略了部分内容):
[root@ay130221101729bc93912 software]# rpm -ivh mysql-server-5.6.10-1.rhel5.x86_64.rpm 
preparing                ########################################### [100%]
  1:mysql-server           ########################################### [100%]
2013-02-22 09:03:18 0 [warning] timestamp with implicit default value is deprecated. please use --explicit_defaults_for_timestamp server option (see documentation for more details).
…….
a random root password has been set. you will find it in '/root/.mysql_secret'.
2013-02-22 09:03:25 4132 [note] binlog end
2013-02-22 09:03:25 4132 [note] innodb: fts optimize thread exiting.
……
        安装完成后会生成root用户的随机密码,请使用“cat /root/.mysql_secret”或类似命令进行查看。
3.2 安装mysql客户端         服务端安装完成后,使用如下命令安装mysql客户端,命令如下:
rpm -ivh mysql-client-5.5.28-1.rhel5.i386.rpm
3.3 安装mysql开发依赖包         接着安装mysql-devel-5.5.28-1.rhel5.i386.rpm,命令如下:
rpm -ivh mysql-devel-5.5.28-1.rhel5.i386.rpm
3.4 mysql的几个重要目录(1)数据库目录
 /var/lib/mysql/
(2)配置文件
 /usr/share/mysql(mysql.server命令及配置文件)
(3)相关命令
 /usr/bin(mysqladmin mysqldump等命令)
 (4)启动脚本
 /etc/rc.d/init.d/(启动脚本文件mysql的目录)
         若想查看mysql安装到哪个目录,可使用“whereis mysql”命令查看,参考执行结果如下所示:
[root@ay130221101729bc93912 mysql]# whereis mysql
mysql: /usr/bin/mysql /usr/include/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz
3.5 启动mysql         安装完成后mysql是没有启动的,运行mysql命令会提示如下错误:
[root@ay130221101729bc93912 software]# mysql
error 2002 (hy000): can't connect to local mysql server through socket '/var/lib/mysql/mysql.sock' (2)
      可使用如下命令启动mysql:
service mysql start
      或者使用如下命令:
/etc/init.d/mysql start
3.6 登录mysql使用mysql命令登录mysql服务器,运行mysql的命令时,会提示需要设置root用户密码,提示信息如下:
[root@ay130221101729bc93912 mysql]# mysql -u root -p
enter password: 
welcome to the mysql monitor. commands end with ; or \g.
your mysql connection id is 5
server version: 5.6.10
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> show databases;
error 1820 (hy000): you must set password before executing this statement
可使用set password命令修改root用户的密码,参考如下:
mysql> set password = password('root123456');
query ok, 0 rows affected (0.00 sec)
mysql> show databases;
+--------------------+
| database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
3.7 设置开机自启动       设置开机自启动的方法有很多,例如使用chkconfig命令,另外也可以在/etc/rc.local文件中加上如下mysql的启动命令,例如:
/etc/init.d/mysql start
     设置完成后重启系统,使用natstat –nat命令可看到mysql的3306端口:
netstat -nat
active internet connections (servers and established)
proto recv-q send-q local address               foreign address             state      
tcp        0      0 127.0.0.1:8005              0.0.0.0:*                   listen      
tcp        0      0 0.0.0.0:8009                0.0.0.0:*                   listen      
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   listen   
……
5、参考文档(1)《在linux下安装和使用mysql》:http://www.yesky.com/187/1754687.shtml
(2)《centos下以rpm方式安装mysql5.5》:http://blog.seweal.com/post/centos-mysql-install-rpm
(3)《redhat linux无法使用yum快速安装软件解决方案》:
     http://www.2cto.com/os/201112/113105.html
(4)centos的一些rpm包的镜像下载路径:http://mirrors.163.com/centos/5/os/x86_64/centos/
(5)mysql的server和client端的下载路径:http://dev.mysql.com/downloads/mysql/#downloads
posted on 2013-02-22 18:23 阿蜜果 阅读(13846) 评论(9)  编辑  收藏 所属分类: mysql 、解决方案
阿里分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录