源码安装Mysql

2024-05-08 16:15:54 浏览数 (1)

1.安装mysql的依赖环境

安装ncurses-devel运行环境

[root@localhost ~]# yum -y install ncurses-devel

2.解压cmake和mysql软件包 [root@localhost ~]# tar -zxvf cmake-2.8.6.tar.gz -C /usr/src

[root@localhost ~]# tar -zxvf mysql-5.6.36.tar.gz -C /usr/src

3.安装cmake

[root@localhost ~]# cd /usr/src/cmake-2.8.6 [root@localhost cmake-2.8.6]# ./configure && gmake && gmake install

4.配置mysql安装环境 cd /usr/src/mysql-5.6.36

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all

选项说明: -DCMAKE_INSTALL_PREFIX=/usr/local/mysql #指定安装路径 -DSYSCONFDIR=/etc #指定配置文件路径 -DDEFAULT_CHARSET=utf8 #默认语言编码 -DDEFAULT_COLLATION=utf8_general_ci #默认字符集 -DWITH_EXTRA_CHARSETS=all #支持各种字符

make && make install

5.优化mysql启动脚本和命令路径

创建mysql 组 groupadd mysql 创建mysql用户 useradd -M -s /sbin/nologin -g mysql mysql

复制mysql配置文件到/etc目录: cp /usr/src/mysql-5.6.36/support-files/my-default.cnf /etc/my.cnf

复制mysql脚本文件到/etc/rc.d/init.d/目录中 cp /usr/src/mysql-5.6.36/support-files/mysql.server /etc/rc.d/init.d/mysqld

chmod a x /etc/rc.d/init.d/mysqld

添加mysqld服务到服务管理器 chkconfig --add mysqld chkconfig mysqld on

优化mysql命令路径

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

6.初始化mysql

安装perl运行组件和运行环境: yum -y install perl perl-devel perl-DBD*

初始化mysql: /usr/local/mysql/scripts/mysql_install_db --user=mysql --group=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

启动mysql服务

systemctl restart mysqld

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data - DSYSCONFDIR=/usr/local/mysql/etc -DWITH_INNOBASE_STORAGE_ENGINE=ON - DWITH_MYISAM_STORAGE_ENGINE=ON -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci - DENABLED_LOCAL_INFILE=ON -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/usr/local/mysql/tmp/mysql.sock - DWITH_INNODB_MEMCACHED=ON -DWITH_BOOST=boost/boost_1_59_0

0 人点赞