Mysql安装部署
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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来安装。结合上面1和3的优点,即安装快速,可任意定制参数,但是也需要具有备更深能力的人员才行。 |
安装步骤介绍
1创建MySQL用户的账号
首先以root身份登录到Linux系统中,然后执行如下命令创建mysql组用户组账号:
[[email protected] ~]# groupadd mysql
提示:MySQL5.5产品系列和早期的MySQl5.0、5.1系列属于不同的产品线,因此,安装方式有所不同。
创建mysql用户
[[email protected] ~]# useradd -s /sbin/nologin -M mysql
创建存放安装包的目录
[[email protected] ~]# mkdir /home/oldboy/tools/ -p
[[email protected] ~]# cd /home/oldboy/tools/
[[email protected] ~]# mkdir /application/mysql/data/ -p
[[email protected] tools]# wget -q http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.53-linux2.6-x86_64.tar.gz
2、初始化
[[email protected] tools]# ls
mysql-5.5.53-linux2.6-x86_64.tar.gz nginx-1.6.3 nginx-1.6.3.tar.gz
[[email protected] tools]# tar xf mysql-5.5.53-linux2.6-x86_64.tar.gz
[[email protected] 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
[[email protected] tools]# mvmysql-5.5.53-linux2.6-x86_64/ mysql-5.5.53
[[email protected] tools]# ls
mysql-5.5.53 mysql-5.5.53.tar.gz nginx-1.6.3 nginx-1.6.3.tar.gz
[[email protected] tools]# cd mysql-5.5.53
[[email protected] application]# ln -s/application/mysql-5.5.53/ /application/mysql
[[email protected] 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
[[email protected] mysql]# \cpsupport-files/my-small.cnf /etc/my.cnf
[[email protected] 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/
[[email protected] mysql]# ls -ld /tmp
drwxrwxrwt. 3 root root 4096 12月 11 17:32 /tmp
[[email protected] mysql]# chmod -R 1777 /tmp/
设置MySQL启动脚本
[[email protected] mysql]#cpsupport-files/mysql.server /etc/init.d/mysqld
[[email protected] mysql]# chmod +x /etc/init.d/mysqld
[[email protected] mysql]# sed -i‘s#/usr/local/mysql#/application/mysql#g‘ /application/mysql/bin/mysqld_safe/etc/init.d/mysqld
[[email protected] mysql]# /etc/init.d/mysqld start
Starting MySQL.. SUCCESS!
查看MySQL服务有没有启动
[[email protected] mysql]# lsof -i :3306
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 11967mysql 10u IPv4 33961 0t0 TCP *:mysql (LISTEN)
设置MySQL服务开机自启动。
[[email protected] data]# chkconfig --add mysqld
[[email protected] data]# chkconfig mysqld on
[[email protected] data]# chkconfig --list |grep mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
配置mysql命令全局使用路径
[[email protected] data]# echo ‘exportPATH=/application/mysql/bin:PATH‘ >>/etc/profile
export PATH=/application/mysql/bin:PATH
[[email protected] data]# tail -1 /etc/profile
export PATH=/application/mysql/bin:PATH
[[email protected] data]# source /etc/profile
[[email protected] mysql]# echo $PATH
/application/mysql/bin:PATH
[[email protected] 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安装部署的主要内容,如果未能解决你的问题,请参考以下文章
源码安装部署MySQL数据库 二进制安装部署MySQL数据库 yum安装数据库