一.mysql5.5.38下载地址:http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.38.tar.gz
二.原出处:http://1567045.blog.51cto.com/1557045/841064
三.简单回顾:
0.准备磁盘,存放mysql的data文件
安装如果磁盘大于2t,需要安装parted,yum search parted yum install xx
- fdisk –l 先查看分区,确定要分的盘符 比如dev/sda
- 进入parted
- makde label
parted /dev/sda
(parted) mklabel gpt
Warning: The existing disk label on /dev/sda will be destroyed and all data onthis disk
will be lost. Do you want to continue?
Yes/No? yes
- make part
(parted) mkpart
Partition name? []? dp1
File system type? [ext2]? ext3
Start? 0
End? 500GB
或者0% 100%
- 查看
(parted) print
- 删除
rm 1 #rm后面使用分区的号码
- 格式化
quit 退出parted
使用系统的
mkfs.ext3 /dev/hdd1
- 挂载
# mount /dev/hdd2 /dp2 dp2需要新建文件夹 makedir -pv /dp2
- 开机自动挂载的设置,上一个设置,重启电脑后,会取消挂载
vim /etc/fstab
最后一行加入
类似这种
/dev/sdb2 /media/Bak2 ext4 defaults 0 0
1.安装所需依赖:
yum -y install ntp vim-enhanced gcc gcc-c++ flex bison autoconf automake bzip2-devel ncurses-devel zlib-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel libXpm-devel gettext-devel pam-devel libtool libtool-ltdl openssl openssl-devel fontconfig-devel libxml2-devel curl-devel libicu libicu-devel libmcrypt libmcrypt-devel libmhash libmhash-devel
2.安装cmake
#下载Cmake的源码包
wget http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz
#编译安装
tar zxvf cmake-2.8.7.tar.gz
cd cmake-2.8.7
./configure
make && make install
3.创建 data文件夹,及创建mysql用户
#创建所需目录
mkdir -pv /usr/local/mysql/data#创建mysql用户和mysql组
groupadd mysql
useradd -g mysql -s /usr/sbin/nologin mysql
#解压源码包
tar zxvf mysql-5.5.22.tar.gz
cd mysql-5.5.22
#cmake编译
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_unicode_ci -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_DEBUG=0
#安装
make && make install
#复制配置文件
cp support-files/my-medium.cnf /etc/my.cnf
#设置权限
chmod +x /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/data
#配置开机自动启动
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
#修改配置文件
vim /etc/my.cnf
#在[mysqld]中添加:
datadir = /usr/local/mysql/data
log-error = /usr/local/mysql/data/error.log
pid-file = /usr/local/mysql/data/mysql.pid
user = mysql
tmpdir = /tmp
#保存退出
#初始化数据库
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
#手动启动MySQL
service mysqld start
#测试MySQL是否启动
#查看是否有mysql进程
ps -ef | grep mysql
#查看是否有mysql端口
netstat -tnlp | grep 3306
#添加mysql的软链接可以使用用户直接使用
ln -sv /usr/local/mysql/bin/mysql mysql
ln -sv /usr/local/mysql/bin/mysqladmin mysqladmin
ln -sv /usr/local/mysql/bin/mysqldump mysqldump
或者编辑/etc/profile在以PATH开头的上一行添加
PATH=$PATH:/usr/local/mysql/bin
#重读/etc/profile文件
. /etc/profile
#测试mysql,mysqladmin,mysqldump命令是否能正常使用
#读取MySQL的版本信息
mysqladmin version