Skip to content

通过知识获得解放,通过技术获得自由

Menu
  • 专题目录
  • 液压相关
    • 液压技术
    • 液压相邻技术
    • 液压应用
  • 计算机相关
    • 计算机和软件
    • 网络和网站技术
  • 哲学
  • 关于本站
Menu

源码安装mysql5.6[0]

Posted on 2023年11月14日 by

系统centos7,安装mysql5.6

源码安装mysql有太多的坑,网文无数,都是缺东缺西,一直也无法完成源码安装mysql。mysql的源码分为两种,一种是含有boost的,一种不带boost。两种区别在数据备份。

源码安装mysql的难点:mysql采用cmake编译,而不同版本的mysql对于cmake的要求并不相同。centos7 的cmake一直在升级,采用yum安装cmake极有可能最新版的cmake在一些语法上和特定版本的mysql存在兼容问题,因此需要安装和mysql兼容的cmake版本,建议也采用源码安装。

  • 前提
#关闭防火墙
systemctl stop firewalld
#安装必要的基础环境
yum install -y apr* autoconf automake bison bzip2 bzip2* compat* cpp curl curl-devel fontconfig fontconfig-devel freetype freetype* freetype-devel gcc gcc-c++ gd gettext gettext-devel glibc kernel kernel-headers keyutils keyutils-libs-devel krb5-devel libcom_err-devel libpng libpng-devel libjpeg* libsepol-devel libselinux-devel libstdc++-devel libtool* libgomp libxml2 libxml2-devel libXpm* libtiff libtiff* make mpfr ncurses* ntp openssl openssl-devel patch pcre-devel perl php-common php-gd policycoreutils telnet t1lib t1lib* nasm nasm* wget zlib-devel
#添加mysql的用户和用户组
useradd mysql -s /sbin/nologin
  • 安装cmake下载源码
cd /usr/local/src 
wget https://www.linuxprobe.com/Software/cmake-2.8.11.2.tar.gz 
tar xzvf cmake-2.8.11.2.tar.gz 
cd cmake-2.8.11.2/ 
./configure 
make make install
  • 创建mysql数据文件夹和设置权限
mkdir -p /usr/local/mysql/var
chown -Rf mysql:mysql /usr/local/mysq
  • 编译mysql
cd /usr/local/src 
wget https://www.linuxprobe.com/Software/mysql-5.6.19.tar.gz 
#或者
wget https://distfiles.macports.org/mysql56/mysql-5.6.19.tar.gz 
tar xzvf mysql-5.6.19.tar.gz 
cd mysql-5.6.19/ 
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/var -DSYSCONFDIR=/etc 
make 
make install
  • mysql配置填坑

1)删除默认的my.cnf

rm -rf /etc/my.cnf

2)生成新的配置文件

cd /usr/local/mysql 
./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var 
ln -s my.cnf /etc/my.cnf

3)添加mysql的系统服务

cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
nano /etc/rc.d/init.d/mysqld

添加以下内容:

 basedir=/usr/local/mysql
 datadir=/usr/local/mysql/var

4)启动系统服务

service mysqld start
chkconfig mysqld on

5)修改系统的环境变量

nano /etc/profile

添加以下内容:export PATH=$PATH:/usr/local/mysql/bin

更新系统环境变量

source /etc/profile

6)配置mysql的函数和程序

mkdir /var/lib/mysql
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
ln -s /usr/local/mysql/include/mysql /usr/include/mysql

7)mysql初始化

mysql_secure_installation

8)检查mysqld服务

systemctl status mysqld

systemctl restart mysqld
systemctl status mysqld

  • 最终
由于mysql的安装后信息:
安装位置:/usr/local/mysql
配置文件:/etc/my.cnf
sock位置:/var/lib/mysql/mysql.sock
systemctl restart mysqld

 

补充说明:

  1. mysql常用语法和设置,用于检验mysql的服务。
  2. MySQL5.6与MySQL5.7安装的区别

参考资料:

  1. https://www.linuxprobe.com/chapter-20.html
  2. https://www.linuxidc.com/Linux/2016-07/133688.htm

欢迎回来

希望本站对你有所帮助!

如有疑问请联系info@fanlog.org
2023 年 11 月
一二三四五六日
 12345
6789101112
13141516171819
20212223242526
27282930 
« 6 月    

AI辅助 (17)

© 2025 | Powered by Superbs Personal Blog theme
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT