安装环境 centos x86_64
最小化安装
安装 “development tools" "server platform development"
"desktop platform development" 组件
二进制包安装
一 准备数据存放的文件系统
新建逻辑卷 挂载到 /mydata ,然后新建目录 /my
data/data作为数据库存放目录
1 安装LVM
[root@www ~]# rpm -ql lvm [root@www ~]# yum install lvm2
2 新增一块硬盘,划分分区,查看磁盘分区
[root@www ~]# fdisk -l /dev/sdb Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x47e9e58b Device Boot Start End Blocks Id System /dev/sdb1 1 1306 10490413+ 83 Linux /dev/sdb2 1307 2610 10474380 5 Extended /dev/sdb5 1307 2610 10474348+ 83 Linux
3 创建逻辑分区
修改分区ID 号
fdisk /dev/sdb WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): p Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x47e9e58b Device Boot Start End Blocks Id System /dev/sdb1 1 1306 10490413+ 8e Linux LVM /dev/sdb2 1307 2610 10474380 5 Extended /dev/sdb5 1307 2610 10474348+ 8e Linux LVM
[root@www ~]# pvcreate /dev/sdb1 Physical volume "/dev/sdb1" successfully created [root@www ~]# pvcreate /dev/sdb5 Physical volume "/dev/sdb5" successfully created
[root@www ~]# vgcreate myvg /dev/sdb1 /dev/sdb5 Volume group "myvg" successfully created [root@www ~]# lvcreate -n mydata -L 10G myvg Logical volume "mydata" created [root@www ~]# mke2fs -t ext4 /dev/myvg/mydata [root@www ~# mkdir mydata [root@www ~]# mount /dev/myvg/mydata /mydata/ [root@www ~]# vim /etc/fstab /dev/myvg/mydata/mydata ext4 defaults 0 0 [root@www ~]# mount -a [root@www ~]# mount
4 在/mydata下创建子目录,作为mysql数据库目录
[root@www ~]# mkdir /mydata/data/
二 创建mysql 用户 修改权限
[root@www ~]# useradd mysql
[root@www ~]# chown -R mysql:mysql /mydata/data/
三 安装mysql
1 解压缩到/usr/local/ 更改权限
[root@www ~]# tar xf mysql-5.5.37-linux2.6-x86_64.tar.gz -C /usr/local/
[root@www local]# ln -sv mysql-5.5.37-linux2.6-x86_64 mysql
[root@www local]# chown -R mysql:mysql mysql
2 配置my.cnf
[root@www mysql]# cd support-files/ [root@www support-files]# cp my-large.cnf /etc/my.cnf [root@www mysql]# vim /etc/my.cnf 添加datadir=/mydata/data thread_cache_size=4 (物理核心的一到二倍)
3 服务脚本
[root@www support-files]# cp mysql.server /etc/rc.d/init.d/mysqld [root@www mysql]# chkconfig mysqld on
4 初始化脚本
[root@www mysql]#scripts/mysql_install_db --user=mysql --datadir=/mydata/data/ Installing MySQL system tables.... /bin/mysqld : error whileloading shared libraries [root@www mysql]# yum install libaio
[root@www mysql]# ls /mydata/data/
5 修改PATH变量
[root@www mysql]# vim /etc/profile.d/mysql.sh 添加exportPATH=/usr/local/mysql/bin:$PATH [root@www mysql]# source /etc/profile.d/mysql.sh
6 输出mysql头文件至系统头文件路径
[root@www mysql]# ln -sv /usr/local/mysql/include/ /usr/include/mysql
7 输出mysql库文件至系统库文件查找路径
[root@www mysql]# vim /etc/ld.so.conf.d/mysql.conf 添加/usr/local/mysql/lib [root@www mysql]# ldconfig -v
8 输出mysql man 手册至man命令查找路径
[root@www mysql# vim /etc/man.config 添加MANPATH/usr/local/mysql/man
9测试连接
[root@www ~]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.5.37-log MySQL Community Server (GPL) Copyright (c) 2000, 2014, 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>