centos7 mysql源码安装

1. mysql源码包下载地址

https://downloads.mysql.com/archives/community/
centos7 mysql源码安装_第1张图片

2. 安装依赖环境

yum -y install gcc gcc-c++ cmake ncurses-devel bison  boost perl-Module-Install

3. 上传mysql源码包并解压

[root@host-136 ~]# ls
anaconda-ks.cfg  mysql-5.6.15.tar.gz
[root@host-136 ~]# tar xzf mysql-5.6.15.tar.gz 
[root@host-136 ~]# ls
anaconda-ks.cfg  mysql-5.6.15  mysql-5.6.15.tar.gz

4. 检测环境

[root@host-136 ~]# cd mysql-5.6.15
[root@host-136 mysql-5.6.15]# cmake .

5. 编译并安装

5.1 默认安装路径为 /usr/local/mysql

[root@host-136 mysql-5.6.15]# make && make install
可以使用 make -j2
-j 用来指定CPU核心数,可加快编译速度

6. 初始化mysql

6.1 添加mysql用户

useradd mysql

6.2 初始化参数

切换路径

cd /usr/local/mysql/

初始化参数

./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/

7. 配置

  cd /usr/local/mysql/
  cp support-files/my-default.cnf  /etc/my.cnf
  cp: overwrite ‘/etc/my.cnf’? y 
  cp support-files/mysql.server  /etc/init.d/mysqld

8. 给命令添加软链接

  ln -s /usr/local/mysql/bin/*  /usr/local/sbin/

9. 开启mysql测试

service mysqld start

10. 登录数据库测试

[root@host-136 mysql]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.15 Source distribution
Copyright (c) 2000, 2013, 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> 

你可能感兴趣的:(MySQL,mysql,linux,centos,源码安装)