码迷,mamicode.com
首页 > 数据库 > 详细

Mysql安装部署

时间:2016-12-11 23:42:04      阅读:358      评论:0      收藏:0      [点我收藏+]

标签:linux   mysql   数据库   二进制   用户组   

Mysql安装部署


1、安装概览

MySQL有几种不同的产品线,且每种产品线又有很多不同的版本,这里选择当前企业使用最广的社区版MySQL5.5系列作为LNMP的组合环境数据库平台。

企业场景MySQL安装方式一览

序号

MySQL安装方式

特点说明

1

yum/rpm包安装

特点是简单,但是没法定制安装,入门新手常用这种方式。

2

二进制安装

解压软件简单配置后就可以使用,不用安装,速度较快,专业DBA喜欢这种方式,软件名如:mysql-5.5.32-liux2.6-x86_64.tar.gz.  

3

源码编译安装

特点是可以定制安装参数,但安装时间长,便  如:安符集安装路径,软件名如:mysql-5.5.32.tar.gz

4

源码软件结合

把源码软件制作成符合要求的rpm,放到yum仓库里,然后通过yum来安装。结合上面13的优点,即安装快速,可任意定制参数,但是也需要具有备更深能力的人员才行。

安装步骤介绍

1创建MySQL用户的账号

首先以root身份登录到Linux系统中,然后执行如下命令创建mysql组用户组账号:

[root@web01 ~]# groupadd mysql

提示:MySQL5.5产品系列和早期的MySQl5.05.1系列属于不同的产品线,因此,安装方式有所不同。

创建mysql用户

[root@web01 ~]# useradd -s /sbin/nologin -M mysql

创建存放安装包的目录

[root@web01 ~]# mkdir /home/oldboy/tools/ -p

[root@web01 ~]# cd /home/oldboy/tools/

[root@web01 ~]# mkdir /application/mysql/data/ -p

[root@web01 tools]# wget -q http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.53-linux2.6-x86_64.tar.gz

2、初始化

[root@web01 tools]# ls

mysql-5.5.53-linux2.6-x86_64.tar.gz  nginx-1.6.3 nginx-1.6.3.tar.gz

[root@web01 tools]# tar xf mysql-5.5.53-linux2.6-x86_64.tar.gz

[root@web01 tools]# ls

mysql-5.5.53-linux2.6-x86_64  xf mysql-5.5.53-linux2.6-x86_64.tar.gz  nginx-1.6.3 nginx-1.6.3.tar.gz

[root@web01 tools]# mvmysql-5.5.53-linux2.6-x86_64/ mysql-5.5.53

[root@web01 tools]# ls

mysql-5.5.53 mysql-5.5.53.tar.gz nginx-1.6.3  nginx-1.6.3.tar.gz

[root@web01 tools]# cd mysql-5.5.53

[root@web01 application]# ln -s/application/mysql-5.5.53/ /application/mysql

[root@web01 mysql]# ls -l /application/

总用量 8

lrwxrwxrwx  1root root   26 12月 11 15:56 mysql -> /application/mysql-5.5.53/

drwxr-xr-x 13 root root 4096 12月 11 15:46 mysql-5.5.53

lrwxrwxrwx  1root root   25 12月 11 10:47 nginx -> /application/nginx-1.6.3/

drwxr-xr-x 11 root root 4096 12月 11 10:53 nginx-1.6.3

[root@web01 mysql]# \cpsupport-files/my-small.cnf  /etc/my.cnf

[root@web01 mysql]# ./scripts/mysql_install_db--user=mysql --basedir=/application/mysql --datadir=/application/mysql/data/

Installing MySQL system tables...

161211 16:10:40 [Note] Ignoring --secure-file-privvalue as server is running with --bootstrap.

161211 16:10:40 [Note]/application/mysql/bin/mysqld (mysqld 5.5.53) starting as process 11591 ...

OK

Filling help tables...

161211 16:10:40 [Note] Ignoring --secure-file-privvalue as server is running with --bootstrap.

161211 16:10:40 [Note]/application/mysql/bin/mysqld (mysqld 5.5.53) starting as process 11598 ...

OK

提示两个OK,代表成功了。

3、配置及启动Mysql数据库

cd /application/mysql/

[root@web01 mysql]# ls -ld /tmp

drwxrwxrwt. 3 root root 4096 12月 11 17:32 /tmp

[root@web01 mysql]# chmod -R 1777 /tmp/

设置MySQL启动脚本

[root@web01 mysql]#cpsupport-files/mysql.server  /etc/init.d/mysqld

[root@web01 mysql]# chmod +x /etc/init.d/mysqld

[root@web01 mysql]# sed -i‘s#/usr/local/mysql#/application/mysql#g‘ /application/mysql/bin/mysqld_safe/etc/init.d/mysqld

[root@web01 mysql]# /etc/init.d/mysqld start

Starting MySQL.. SUCCESS!

查看MySQL服务有没有启动

[root@web01 mysql]# lsof -i :3306

COMMAND  PID  USER   FD  TYPE DEVICE SIZE/OFF NODE NAME

mysqld  11967mysql   10u  IPv4 33961      0t0  TCP *:mysql (LISTEN)

设置MySQL服务开机自启动。

[root@web01 data]# chkconfig --add mysqld

[root@web01 data]# chkconfig  mysqld on

[root@web01 data]# chkconfig --list |grep mysqld

mysqld         0:off   1:off   2:on   3:on    4:on    5:on   6:off

配置mysql命令全局使用路径

[root@web01 data]# echo ‘exportPATH=/application/mysql/bin:PATH‘ >>/etc/profile

export PATH=/application/mysql/bin:PATH

[root@web01 data]# tail -1 /etc/profile

export PATH=/application/mysql/bin:PATH

[root@web01 data]# source /etc/profile

[root@web01 mysql]# echo $PATH

/application/mysql/bin:PATH

[root@web01 mysql]# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.5.53 MySQL Community Server (GPL)

 

Copyright (c) 2000, 2016, Oracle and/or itsaffiliates. All rights reserved.

 

Oracle is a registered trademark of OracleCorporation and/or its

affiliates. Other names may be trademarks of theirrespective

owners.

 

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clearthe current input statement.

 

mysql>

由全局路径配置不不导致的问题案例见文章:

http://oldboy.blog.51cto.com/2561410/1122867


谢谢恩师,老男孩老师的指导,以上自己做的总结。

 


本文出自 “pcjazz” 博客,请务必保留此出处http://520527.blog.51cto.com/510527/1881712

Mysql安装部署

标签:linux   mysql   数据库   二进制   用户组   

原文地址:http://520527.blog.51cto.com/510527/1881712

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!