可以到mysql官网也可以到开源镜像站下载安装文件
第一步:为增强mysql数据库空间拓展性,创建lv卷
[[email protected] pub]# pvcreate /dev/sdb{5,6}
[[email protected] pub]# vgcreate myvg /dev/sdb{5,6}
[[email protected] pub]# vgs
VG #PV #LV #SN Attr VSize VFree
myvg 2 0 0 wz--n- 200.01g 200.01g
[[email protected] pub]# lvcreate -L 50G -n mylv myvg
[[email protected] pub]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert
mylv myvg -wi-a----- 50.00g
[[email protected] pub]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb5 myvg lvm2 a-- 100.00g 50.00g
/dev/sdb6 myvg lvm2 a-- 100.00g 100.00g
\\关于逻辑卷管理请参考博主的LVM逻辑卷管理器篇
第二步:格式化并挂载到mydata目录下
[[email protected] pub]# mke2fs -t ext4 -L MYLV -b 4096 /dev/myvg/mylv
[[email protected] pub]# vim /etc/fstab
LABEL=MYLV /mydata ext4 defaults 0 0
[[email protected] pub]# mkdir /mydata
[[email protected] pub]# mount -a
[[email protected] pub]# mount
/dev/mapper/myvg-mylv on /mydata type ext4 (rw)
\\关于磁盘分区及格式化请参考博主的Linux分区挂载篇
第三步:创建mysql数据库目录,并修改属主属组
[[email protected] pub]# mkdir /mydata/data
[[email protected] pub]# chown mysql:mysql /mydata/data
[[email protected] pub]# ll /mydata/
total 20
drwxr-xr-x 2 mysql mysql 4096 Jul 1 21:13 data
第四步:解压mysql文件,并创建软链接到mysql目录
[[email protected] pub]# tar xf mysql-5.5.38-linux2.6-i686.tar.gz -C /usr/local
[[email protected] pub]# ss -tanl \\检查是否监听3306端口,如果有监听请关掉
[[email protected] pub]# cd /usr/local/
[[email protected] local]# ln -sv mysql-5.5.38-linux2.6-i686 mysql
`mysql‘ -> `mysql-5.5.38-linux2.6-i686‘
[[email protected] local]# ls
apache apr14 apr-util bin games lib mysql
第五步:修改/usr/local/mysql目录下所有文件属主属组
[[email protected] local]# cd mysql
[[email protected] mysql]# chown -R root:mysql /usr/local/mysql/*
第六步:修改配置文件,并加入启动服务
[[email protected] mysql]# cd support-files/
[[email protected] support-files]# cp my-large.cnf /etc/my.cnf 如果已经存在,备份,不要直接覆盖
[[email protected] support-files]# vim /etc/my.cnf
thread_concurrency = 2 修改CPU核心数
datadir=/mydata/data 添加data目录
[[email protected] support-files]# cp mysql.server /etc/rc.d/init.d/mysqld
[[email protected] support-files]# chkconfig --add mysqld
[[email protected] support-files]# chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
第七步:执行脚本初始化
[[email protected] mysql]# rm -rf /mydata/data/*
[[email protected] mysql]# scripts/mysql_install_db --user=mysql --datadir=/mydata/data/
第八步:启动并登录mysql
[[email protected] mysql]# service mysqld start
[[email protected] mysql]# vim /etc/profile.d/mysql.sh
export PATH=/usr/local/mysql/bin:$PATH 导出命令路径
:wq
[[email protected] mysql]# . /etc/profile.d/mysql.sh 执行脚本导入
[[email protected] mysql]# mysql
Welcome to the MySQL monitor.
第九步:查看man手册
[[email protected] mysql]# vim /etc/man.config
MANPATH /usr/local/mysql/man
[[email protected] mysql]# ln -sv /usr/local/mysql/include/ /usr/include/mysql 导出头文件
[[email protected] mysql]# vim /etc/ld.so.conf.d/mysql.conf 导出父文件
/usr/local/mysql/lib
[[email protected] mysql]# ldconfig -v |grep mysql 配置生效
mysql之通用二进制格式程序包安装