赞
踩
网址 https://dev.mysql.com/downloads/mysql/5.7.html#downloads
Select Operating System 选择 Source Code
Select OS version 选择 All Operating Systems
推荐下载第二个带boost的mysql。如果您下载了第一个不带boost的mysql,则需要您自己手动安装boost。
点击Download下载,将包放到linux系统中。
这里我下载的是 mysql-boost-5.7.38.tar.gz
# 安装系统包 apt -y install make cmake gcc g++ perl bison libaio-dev libncurses5 libncurses5-dev libnuma-dev libssl-dev # 添加mysql用户 groupadd mysql useradd -r -g mysql mysql # 预制一些目录 rm -rf /opt/mysql mkdir -p /opt/mysql/download # 存放mysql-5.7.38.tar.gz等安装包 mkdir -p /opt/mysql/install # 存放安装后的软件 mkdir -p /opt/mysql/data # 存放数据 mkdir -p /opt/mysql/log # 存放日志 chown -R mysql:mysql /opt/mysql # 假设下载的mysql-boost-5.7.38.tar.gz放到了/root下 cp /root/mysql-boost-5.7.38.tar.gz /opt/mysql/download/mysql-boost-5.7.38.tar.gz cd /opt/mysql/download/ tar -zxf mysql-boost-5.7.38.tar.gz # 预编译 cd mysql-5.7.38/ cmake \ -DCMAKE_INSTALL_PREFIX=/opt/mysql/install \ -DMYSQL_UNIX_ADDR=/opt/mysql/install/mysql.sock \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DMYSQL_DATADIR=/opt/mysql/data \ -DMYSQL_TCP_PORT=3306 \ -DWITH_SSL=system \ -DWITH_BOOST=boost # 从cmake到这里是一行命令,复制的时候一起复制 echo $? 0 # 如果是0,预编译通过,其他数字,表示失败,自行排错 # 编译参数的参考文档:https://dev.mysql.com/doc/refman/5.7/en/source-configuration-options.html # 正式编译,1-2小时 make -j4 make install # 修改安装目录的所有者和所属组 chown -R mysql:mysql /opt/mysql chgrp -R mysql /opt/mysql # 初始化,生成一个临时的mysql root用户密码 /opt/mysql/install/bin/mysqld --initialize --user=mysql # A temporary password is generated for root@localhost: Br-)u/%:=2:9 # 这个密码也会写入 /root/.mysql_secret中 # 启动mysql,修改root密码为123456 /opt/mysql/install/support-files/mysql.server start # 启动后,按回车回到命令行 /opt/mysql/install/bin/mysql -u root -p Enter Password: # 这里输入刚才生成的密码 mysql> set password for root@localhost = password('123456'); # 目前不太方便,系统没有mysql这个命令,没有用设置开机启动。 # 先停止mysql /opt/mysql/install/support-files/mysql.server stop; # 启动mysql服务,注册成systemd服务 cp /opt/mysql/install/support-files/mysql.server /etc/init.d/mysqld /etc/init.d/mysqld start # 这一步自动注册成systemd服务了,可以使用systemctl管理mysql了 chmod +x /etc/init.d/mysqld systemctl stop mysqld systemctl start mysqld systemctl enable mysqld # 添加mysql、mysqldump、mysqlpump等一系列命令 vim /etc/profile # 文件末尾追加 PATH=$PATH:/opt/mysql/install/bin # 验证mysql命令 source /etc/profile mysql -u root -p Enter password: 123456 # 重启系统 reboot
# 安装系统包 apt -y install make cmake gcc g++ perl bison libaio-dev libncurses5 libncurses5-dev libnuma-dev libssl-dev # 预制一些目录 rm -rf /opt/mysql mkdir -p /opt/mysql/download # 存放mysql-5.7.38.tar.gz等安装包 mkdir -p /opt/mysql/install # 存放安装后的软件 mkdir -p /opt/mysql/data # 存放数据 mkdir -p /opt/mysql/log # 存放日志 # 下载 cd /opt/mysql/download wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.38.tar.gz wget https://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz # 上面这个boost下载太慢,可以用浏览器+迅雷下载,然后传进linux # 解压 tar -zxf mysql-5.7.38.tar.gz tar -zxf boost_1_59_0.tar.gz # 安装boost cd /opt/mysql/downloadboost_1_59_0 ./bootstrap.sh ./b2 install # 这一步时间很长,休息一下 # 安装mysql cd /opt/mysql/downloadmysql-5.7.38 # 预编译 cmake \ -DCMAKE_INSTALL_PREFIX=/opt/mysql/install \ -DMYSQL_UNIX_ADDR=/opt/mysql/install/mysql.sock \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DMYSQL_DATADIR=/opt/mysql/data \ -DMYSQL_TCP_PORT=3306 \ -DWITH_BOOST=boost # 从cmake到这里是一行命令,复制的时候一起复制 # 检查预编译是否成功 echo $? 0 # 如果返回1,则预编译失败了,自己排错 # 安装 make -j4 make install # 创建mysql用户和用户组 groupadd mysql useradd -g mysql mysql # 修改权限 chown -R mysql:mysql /opt/mysql chgrp -R mysql /opt/mysql # 初始化mysql,生成一个随机的root密码 /opt/mysql/install/bin/mysqld --initialize --user=mysql # 这里会生成一个随机密码,这个一定要记下来!!如下: # 2022-05-12T13:10:43.032564Z 1 [Note] A temporary password is generated for root@localhost: fpqL7fearl(/ # 开启ssl功能 /opt/mysql/software/bin/mysql_ssl_rsa_setup # 测试启动 /opt/mysql/software/bin/mysqld_safe --user=mysql # ctrl+Z停止 # 启动mysql,修改root密码为123456 /opt/mysql/software/support-files/mysql.server start # 启动后,按回车回到命令行 /opt/mysql/software/bin/mysql -u root -p Enter Password: # 这里输入刚才生成的密码 mysql> set password for root@localhost = password('123456'); # 目前不太方便,系统没有mysql这个命令,没有用设置开机启动。 # 先停止mysql /opt/mysql/software/support-files/mysql.server stop; # 启动mysql服务,注册成systemd服务 cp /opt/mysql/install/support-files/mysql.server /etc/init.d/mysqld /etc/init.d/mysqld start # 这一步会自动注册成systemd服务了,可以使用systemctl管理mysql了 chmod +x /etc/init.d/mysqld systemctl stop mysqld systemctl start mysqld systemctl enable mysqld # 添加mysql、mysqldump、mysqlpump等一系列命令 vim /etc/profile # 文件末尾追加 PATH=$PATH:/opt/mysql/install/bin # 验证mysql命令 source /etc/profile mysql -u root -p Enter password: 123456 # 重启系统 reboot
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。