原因是 根据官方 mysql5.7 需求环境与工具 中
The Boost C++ libraries are required to build MySQL (but not to use it). Boost 1.59.0 must be installed. To obtain Boost and its installation instructions, visit the official site. After Boost is installed, tell the build system where the Boost files are located by defining the WITH_BOOST option when you invoke CMake. For example:
shell> cmake . -DWITH_BOOST=/usr/local/boost_1_59_0
Adjust the path as necessary to match your installation.(copy inmysql.com)
需要 Boost库
ps :Boost库是一个可移植、提供源代码的C++库,作为标准库的后备,是C++标准化进程的开发引擎之一。
解决办法 : 在上面的预编译命令上加上
-DDOWNLOAD_BOOST=1 \ -DWITH_BOOST=/root/local/mysql-5.7.22/boost #boost在mysql 解压目录
ps : 注意上面的下载截图上下载的 mysql 5.7.22 有两个版本 普通版本和Includes Boost Headers版本 ,Boost 是Includes Boost Headers才带的
[root@localhost mysql57]# make #接着是make [root@localhost mysql57]# make install
ps: 我make install这里还报了个错,原因是系统硬盘容量不足(虚拟机的),上面是系统扩容后执行成功的过程
[root@localhost mysql57]# cd /usr/local/es/mysql57 [root@localhost mysql57]# pwd /usr/local/es/mysql57 [root@localhost mysql57]# cp support-files/mysql.server /etc/init.d/mysqld #为了能在 service 上启动mysqld 服务 [root@localhost mysql57]# chkconfig --add mysqld # systemctl 里的服务 注册 [root@localhost mysql57]# chkconfig --level 35 mysqld on # 打开 [root@localhost mysql57]# mkdir mysql-files [root@localhost mysql57]# chown mysql:mysql mysql-files -R #确保 mysql 用户和mysql用户组已经创建 ,没有的要自行创建 [root@localhost mysql57]# chmod 750 mysql-files -R
修改my.cnf 配置文件
[root@localhost mysql57]# vi /etc/my.cnf [mysqld] # 修改到需要的目录,前提是mysql用户和组有权限,mysql-files是上面创建的文件夹,已赋予mysql用户权限 basedir = /usr/local/es/mysql57 datadir = /data/mysql socket = /tmp/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # Settings user and group are ignored when systemd is used. # If you need to run mysqld under a different user or group, # customize your systemd unit file for mariadb according to the # instructions in http://fedoraproject.org/wiki/Systemd [mysqld_safe] # mysqld_safe 启动报错修改这两个 # log-error=/usr/local/es/mysql57/mysql-files/logs/mariadb.log # pid-file=/usr/local/es/mysql57/mysql-files/logs/mariadb.pid # # include all files from the config directory # # !includedir /etc/my.cnf.d
初始化mysql
[root@localhost mysql57]# groupadd mysql [root@localhost mysql57]# useradd -g mysql -r mysql [root@localhost mysql57]# bin/mysqld --initialize --user=mysql --datadir=/data/mysql --basedir=/usr/local/es/mysql57 2018-05-15T12:03:38.914370Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2018-05-15T12:03:39.099197Z 0 [Warning] InnoDB: New log files created, LSN=45790 2018-05-15T12:03:39.178042Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2018-05-15T12:03:39.245722Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 00f7dd1a-5838-11e8-a364-000c29920633. 2018-05-15T12:03:39.247497Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2018-05-15T12:03:39.248853Z 1 [Note] A temporary password is generated for root@localhost: tJ!i/kOlu487 #生成的临时密码,记住
执行成功!准备启动mysqld服务
[root@localhost mysql57]# service mysqld start Starting MySQL.Logging to '/data/mysql/localhost.localdomain.err'. SUCCESS!
添加两个命令的软连接
[root@localhost mysql57]#ln -s /usr/local/es/mysql57/bin/mysql /usr/bin/ [root@localhost mysql57]#ln -s /usr/local/es/mysql57/bin/mysqld /usr/bin/ [root@localhost mysql57]#mysql -uroot -p'tJ!i/kOlu487' mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY '_Jimb55!'; # 换个更复习的密码 Query OK, 0 rows affected (0.07 sec) mysql> exit; Bye [root@localhost mysql57]# mysql -uroot -p'_Jimb55' mysql> ...
操作完成!

可能出现的错误

1 输入上面的密码时提示mysql: [Warning] Using a password on the command line interface can be insecure.
# mysql -uroot -p Enter password:
转换成如此输入即可
2 mysql client 登录时 报ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
# find / -name mysql.sock # 看看有没有输出和路径对上了没有,没输出表示mysqld.service根本没有启动成功 /var/lib/mysql/mysql.sock # 如我此处的路径就跟报错提示中的 /tmp/mysql.sock 不同,所以报错
只能修改配置文件
[client] port = 3306 socket = /var/lib/mysql/mysql.sock #此处修改为你find 出来的mysql.sock路径 [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock basedir = /usr/local/es/mysql57 # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # Settings user and group are ignored when systemd is used. # If you need to run mysqld under a different user or group, # customize your systemd unit file for mariadb according to the # instructions in http://fedoraproject.org/wiki/Systemd [mysqld_safe] #log-error=/var/log/mariadb/mariadb.log #pid-file=/var/run/mariadb/mariadb.pid # # include all files from the config directory # #!includedir /etc/my.cnf.d
再次链接应该没问题了

mysql55 编译安装

#wget http://down1.chinaunix.net/distfiles/mysql-5.5.20.tar.gz #tar -zxvf mysql-5.5.20.tar.gz #cd mysql-5.5.20 #yum install -y gcc c ncurses-devel cmake libaio bison gcc-c++ git ncurses #cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql55/ \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DMYSQL_DATADIR=/data/mysql \ -DSYSCONFDIR=/etc \ -DMYSQL_USER=mysql \ -DMYSQL_TCP_PORT=3306 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_EXTRA_CHARSETS=1 \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DEXTRA_CHARSETS=all \ -DWITH_BIG_TABLES=1 \ -DWITH_DEBUG=0 #make &&make install #cd /usr/local/mysql55/ #cp -f support-files/my-large.cnf /etc/my.cnf #cp -f support-files/mysql.server /etc/init.d/mysqld #chkconfig --add mysqld #chkconfig --level 35 mysqld on #mkdir -p /data/mysql #useradd mysql #/usr/local/mysql55/scripts/mysql_install_db --user=mysql --datadir=/data/mysql/ --basedir=/usr/local/mysql55/ #ln -s /usr/local/mysql55/bin/mysql /usr/bin/mysql #service mysqld restart #mysql -uroot -p'new-password' mysql> update mysql.user set password=password("_Jimb55!") where user="root"; mysql> flush privileges;
Dockerfile制作MySQL编译安装的镜像 文章目录Dockerfile制作MySQL编译安装的镜像Dockerfile制作mysql编译安装的镜像 Dockerfile制作mysql编译安装的镜像 创建mysql文件夹 mkdir mysql #创建mysql目录 进入mysql...
Dockerfile制作MySQL编译安装的镜像

文章目录

Dockerfile制作mysql编译安装的镜像

创建mysql文件夹mkdir mysql #创建mysql目录进入mysql的目录中cd mysql/ #进入mysql的目录中编写dockerfile文件vim Dockerfile #编写dockerfile文件 FROMcentos:7 #指定基础镜像 RUN yum -y update #更新yum源RUN yum -y install \ ncurses \ ncurses-devel \ bison \ cmake \ make \ gcc \ gcc-c++ #安装mysql依懒环境包 RUN useradd -s /sbin/nologin mysql #创建运行用户 ADD mysql-boost-5.7.20.tar.gz /usr/local/src #将压缩包添加到/usr/local/src目录下面 WORKDIR /usr/local/src/mysql-5.7.20/ #指定当前的工作路径 RUN cmake \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \ -DSYSCONFDIR=/etc \ -DSYSTEMD_PID_DIR=/usr/local/mysql \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \ -DMYSQL_DATADIR=/usr/local/mysql/data \ -DWITH_BOOST=boost \ -DWITH_SYSTEMD=1 && make && make install #cmake和编译 RUN chown -Rmysql:mysql /usr/local/mysql/ #给予/usr/local/mysql的属主和属组 RUN rm -rf /etc/my.cnf #删除原来的/etc/my.cnf文件 ADD my.cnf /etc #将宿主机的my.cnf文件添加到/etc/目录下面 RUN chownmysql:mysql /etc/my.cnf #设置权限 ENV PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH #设置mysql的环境 WORKDIR /usr/local/mysql/ #指定当前工作路径 RUN bin/mysqld \ --initialize-insecure \ --user=mysql \ --basedir=/usr/local/mysql \ --datadir=/usr/local/mysql/data #初始化数据库 RUN cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/ #将mysql的启动脚本复制到/usr/lib/systemd/system/目录下面,便于systemctl的管理 EXPOSE 3306 #开放容器的端口 RUN echo -e"#!/bin/bash \nsystemctl enable mysqld" > /run.sh #写mysql的启动脚本 RUN chmod 755 /run.sh #给予权限 RUN sh /run.sh #执行脚本 CMD ["init"] #容器启动时执行 #CMD ["mysql_safe"] vim my.cnf [root@localhost mysql-5.7.20]#vi /etc/my.cnf [client] port = 3306 default-character-set=utf8 socket = /usr/local/mysql/mysql.sock [mysql] port = 3306 default-character-set=utf8 socket = /usr/local/mysql/mysql.sock [mysqld] user = mysql basedir = /usr/local/mysql datadir = /usr/local/mysql/data port = 3306 character_set_server=utf8 pid-file = /usr/local/mysql/mysqld.pid socket = /usr/local/mysql/mysql.sock server-id = 1 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES #my.cnf启动脚本构建mysql:new的镜像docker build -tcentos:mysql .启动容器docker run --name=mysql_server -d -P --privilegedcentos:mysql提权docker exec -it 镜像ID /bin/bash grant all privileges on *.* to'root'@'%' identified by'abc123'; grant all privileges on *.* to'root'@'%' localhost identified by'abc123'; privileges on *.* to'root'@'%' identified by'abc123'; grant all privileges on *.* to'root'@'%' localhost identified by'abc123';
Ubuntu 下mysql编译安装 安装必备工具 编译安装需要其他安装程序支持,推荐采用编译安装各种所需包,此处为了方便,使用ubuntu提供的apt-get install方法安装所需工具 sudo apt-get install cmake libncurses5-dev...

安装必备工具

编译安装需要其他安装程序支持,推荐采用编译安装各种所需包,此处为了方便,使用ubuntu提供的apt-get install方法安装所需工具
sudo apt-get installcmakelibncurses5-devbisong++ build-essential chkconfig
在安装完成后,即可以开始mysql的编译安装过程;

添加用户组,并新建安装目录

添加mysql用户组
sudo groupadd mysql
创建用户mysql并加入到mysql组,不允许mysql用户直接登录系统
sudu useradd -r -g mysql mysql -s/bin/false
创建mysql安装目录,建议所有安装程序目录都在/usr/local/目录下,方便管理和今后维护
sudo mkdir -p /usr/local/mysql
创建mysql的data安装目录
sudo mkdir -p /usr/local/mysql/data
给mysql用户授予data目录及其目录下文件所有权限
sudochown-Rmysql:mysql/usr/local/mysql/data

编译安装mysql

去mysql官网下载最新安装包,本人下载的是mysql-5.6.16.tar.gz,最好将所有安装包都放在同一目录下,本人习惯放在/var/opt/目录下,当然最好直接放在/opt/目录下,进入目录,解压安装文件,
sudo tar -zxvf mysql-5.6.16.tar.gz
cd mysql-5.6.16
sudo cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql/data
开始编译安装
sudo make -j 8#-j 数字 表示以多核心运行,在单核状态下不加 -j 数字,本人i5处理器,可以用-j 8,加快编译过程 。
sudo make install
自此安装基本完成

配置mysql

sudo ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
sudo cp ./support-files/my-default.cnf /etc/my.cnf
sudo cp ./support-files/mysql.server /etc/init.d/mysqld #把Mysql加入系统启动
sudo chmod +x /etc/init.d/mysqld
sudo chkconfig mysqld on
初始化安装
sudo /usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
自此mysql安装完成

设置mysql登录密码

可以通过sudo /usr/local/mysql/bin/mysql启动mysql
如果不能启动,则重启服务器
设置密码,其中newpaassword为新设置的密码;
sudo /usr/local/mysql/bin/mysqladmin -u root password newpassword
测试mysql是否成功安装

将mysql加入环境变量

将mysql加入环境变量即可以直接通过在命令行中输入mysql进入数据库,
echo "export PATH=/usr/local/mysql/bin:$PATH" >>/etc/profile
mysql -u root -p
输入密码能成功进入,则说明已经成功安装mysql。
mysql编译安装过程,执行make命令时报错:c++: internal compiler error: Killed (program cc1plus) Please submit a full bug report, with preprocessed source if appropriate. See ...

mysql编译安装过程,执行make命令时报错:

c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
make[2]:* [sql/CMakeFiles/sql.dir/item_geofunc.cc.o] Error 4
make[1]:* [sql/CMakeFiles/sql.dir/all] Error 2
make:* [all] Error 2

原因解析:

内存不足,mysql5.9以上的版本,编译安装需要1G内存,而我的云主机刚好1G内存。

解决方案

内存不足当然加内存,加内存太贵?那就把硬盘当内存来用把
$ddif=/dev/zero of=/data/swap_add bs=1M count=2048$mkswap /data/swap_add $swapon /data/swap_add $swapon-s
cat /usr/local/mysql/bin/mysqlbug | grep CONFIGURE_LINEmysql编译参数安装MySQL 安装前确认以下包已经装好gcc gcc-c++ ncurses-devel/usr/sbin/groupadd mysql/usr/sbin/useradd -g mysql mysqltar zxvf mysql-...
mysql编译安装与编译参数添加mysql组和mysql用户[root@centosmysql]# groupaddmysql [root@centosmysql]# useradd -gmysqlmysql编译与安装tar -zxvfmysql-5.1.35.tar.gz./configure / --prefix=/u
Linux下mysql编译配置 1.开启mysql服务 以root身份运行:service mysqld start; 2. mysql/mysql.h: No such file or directory. 以root身份运行: yum install mysql-devel;(顾名思义,...
mysql编译错误:undefined reference to `dlclose' Linux 一、错误现象 在linux编译mysql代码,出现如下错误: //================================================================// /us
Linux下mysql编译安装教程
一、下载mysql 5.6.41 安装包 (版本过高 一定容量不足mysql8.0.12建议硬盘容量 30G+) 个人建议在官网下载 https://www.mysql.com	Download->Community-&...二、在linux编译安装mysql 前的...
————MySQL编译安装 一,软件包 MySQL-5.6.22-1.el7.src.rpm 二,编译安装MySQL (参考自mysql官方手册:http://dev.mysql.com/doc/refman/5.6/en/installing-source-distribution.html) 1.提取源码 cd
在阅读源代码的时候,如果能够...1:编译DEBUG版本,以便于GDB跟踪 ./configure –help 一列帮助信息,最后会有以下信息: Some influential environment variables: CCC compiler command CFLAGS
下载mysql 包http://dev.mysql.com/downloads/mysql/http://download.softagency.net/MySQL/Downloads/MySQL-5.5/创建mysql安装目录[root@dianzhui ~]# mkdir /usr/local/mysql5.5.12/创建mysql帐号[root@dianzhui...
#include"/usr/include/mysql/mysql.h"这样可以不用在编译选项中加-I/usr/include/mysql/ 直接#include"mysql.h",然后在编译选项中加入-I/usr/include/mysql/编译选项: #gcc-I/usr/include/mysql/-L...
http://www.myfaq.com.cn/2005September/2005-09-13/206409.html