首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

Centos中装配mysql

2013-03-01 
Centos中安装mysql分为以下两种方式进行(一)使用rpm包安装(hd16上进行)(二)使用源代码进行安装(hd18上进行

Centos中安装mysql
分为以下两种方式进行
(一)使用rpm包安装(hd16上进行)
(二)使用源代码进行安装(hd18上进行)
首先需要下载到rpm包,下载地址:http://www.mysql.com/downloads/mysql/

我下载的是:
MySQL-client-5.6.10-1.linux_glibc2.5.x86_64.rpm
MySQL-server-5.6.10-1.linux_glibc2.5.x86_64.rpm
MySQL-devel-5.6.10-1.linux_glibc2.5.x86_64.rpm(Mysql连接包)

源码:
http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.10.tar.gz/from/http://cdn.mysql.com/
一、rpm方式安装
1.查询是否曾经安装过mysql版本

[root@hd16 ~]# rpm -qa|grep mysqlmysql-devel-5.0.95-1.el5_7.1mysql-5.0.95-1.el5_7.1mysql-devel-5.0.95-1.el5_7.1mysql-5.0.95-1.el5_7.1

2.如已经安装,先停服务,后卸载
[root@hd21 mysql-rpm]# /etc/init.d/mysqld stoprpm -e MySQL-xxx.rpm

3.安装mysql服务
#安装server、client[root@hd16 mysql-rpm]# rpm -ivh MySQL-server-5.6.10-1.linux_glibc2.5.x86_64.rpm Preparing...                ########################################### [100%]ls: /var/lib/mysql/*.err: No such file or directoryls: /var/lib/mysql/*.err: No such file or directory   1:MySQL-server           ########################################### [100%]一定要注意这句:A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !You will find that password in '/root/.mysql_secret'.[root@hd16 lib]# /etc/init.d/mysql start


4.登录客户端
找到root密码登录吧,修改密码方式:
mysql> SET PASSWORD = PASSWORD('tonylee');

二、源码安装
0.卸载已经安装的mysql
1.确保以下必要的软件包已经安装
yum -y install  gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake

2.解压、编译、安装
[root@hd18 mysql-5.6.10]# tar xvzf  mysql-5.6.10.tar.gz[root@hd18 mysql-5.6.10]# cd mysql-5.6.10[root@hd18 mysql-5.6.10]# groupadd mysql[root@hd18 mysql-5.6.10]# useradd -r -g mysql mysql[root@hd18 mysql-5.6.10]# cmake .#make并安装,默认情况是安装在 /usr/local/mysql路径下[root@hd18 mysql-5.6.10]# make && make install#将目录授权给mysql用户组[root@hd18 mysql]# chown -R mysql:mysql /usr/local/mysql#安装数据库mysql ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data#进入support-files将相应的文件copy至/etc目录下[root@hd18 support-files]# cp mysql.server /etc/rc.d/init.d/mysql[root@hd18 support-files]# cp my-default.cnf /etc/my.cnf#启动mysql服务[root@hd18 support-files]# chkconfig --add mysql[root@hd18 support-files]# chkconfig mysql on[root@hd18 support-files]#  service mysql start#登入mysql客户端[root@hd18 bin]# cp mysql /usr/bin/mysql[root@hd18 ~]# mysqlWelcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 4Server version: 5.6.10 Source distributionCopyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> 

热点排行