cmake安装:选一个环境适合的版本安装即可

cmake-2.8.12.2版本安装:
    wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz
    tar zxvf cmake-2.8.12.2.tar.gz
    cd cmake-2.8.12.2
    ./configure
    make
    make install

cmake-3.16.4版本安装:
    wget https://github.com/Kitware/CMake/releases/download/v3.16.4/cmake-3.16.4.tar.gz
    cd cmake-3.16.4
    ./configure
    gmake
    gmake install

查看版本:cmake --version

mysql安装

判断是否安装过mysql的rpm包:
        rpm -qa | grep mysql
        rpm -qa|grep mariadb

1. 官网:https://www.mysql.com/
2. 安装:
    下载社区版:https://dev.mysql.com/downloads/
    各归档社区版本:https://downloads.mysql.com/archives/community/
    官方5.7版本安装说明:http://dev.mysql.com/doc/refman/5.7/en/source-installation.html
    ncurses:https://invisible-island.net/ncurses/announce.html
        ftp://ftp.gnu.org/gnu/ncurses/
    boost: https://www.boost.org/users/download/
          http://sourceforge.net/projects/boost/files/

    mysql5.7.5开始依赖boost:
        wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
        tar -zxvf boost_1_59_0.tar.gz
        mv boost_1_59_0 /usr/local/boost
        cd /usr/local/boost
        #编译安装(可选):
        ./bootstrap.sh
        ./b2
        sudo ./b2 install
        #环境变量(可选):
        vim /etc/profile
            export BOOST_ROOT=/usr/local/boost
            export BOOST_LIB=/usr/local/boost/stage/lib
            export BOOST_INCLUDE=/usr/local/include/boost

        source /etc/profile

  mysql依赖ncurses: yum install -y ncurses ncurses-devel
  其它依赖等:yum install -y bison bison-devel

  开始安装mysql:
    groupadd mysql
    useradd mysql -g mysql -M -s /sbin/nologin
    cat /etc/passwd |grep mysql
    wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.26.tar.gz
    tar -zxvf mysql-5.7.26.tar.gz
    cd mysql-5.7.26
    mkdir bld
    # 默认安装在/usr/local/mysql
    cmake ../ -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost
    make -j `grep processor /proc/cpuinfo | wc -l`
    sudo make install
    至此安装完成,接下来进行配置和初始化。
    切换到安装好的目录:cd /usr/local/mysql
        chown mysql:mysql support-files
        chmod 750 support-files
        bin/mysqld --initialize --user=mysql
        bin/mysql_ssl_rsa_setup
        # 启动
        bin/mysqld_safe --user=mysql &

        cp support-files/mysql.server /etc/init.d/mysql.server
        chmod +x /etc/init.d/mysql.server
        chkconfig --add mysql.server
        chkconfig --level 345 mysql.server on
        chkconfig --list
        或 systemctl enable mysql.server

        #修改root密码
        ./bin/mysqladmin -uroot --password='旧密码,初始密码安装时自动生成的' password '新密码'
        ./bin/mysqladmin -uroot --password='2ZpC:wso8l=y' password '888888'

        #连接db,回车后输入密码
        ./bin/mysql -uroot -p
        或
        ./bin/mysql -uroot -S /tmp/mysql.sock -p
        或 ./bin/mysql -uroot -p888888

  备注:如果指定mysql安装位置示例
     mkdir -p /data/service/hds/mysql
     chown -R mysql.mysql /data/service/hds/mysql
     cmake ../ -DCMAKE_INSTALL_PREFIX=/data/service/hds/mysql \
        -DMYSQL_DATADIR=/data/service/hds/mysql/data \
        -DSYSCONFDIR=/etc \
        -DWITH_MYISAM_STORAGE_ENGINE=1 \
        -DWITH_INNOBASE_STORAGE_ENGINE=1 \
        -DWITH_MEMORY_STORAGE_ENGINE=1 \
        -DWITH_READLINE=1 \
        -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
        -DMYSQL_TCP_PORT=3306 \
        -DENABLED_LOCAL_INFILE=1 \
        -DWITH_PARTITION_STORAGE_ENGINE=1 \
        -DEXTRA_CHARSETS=all \
        -DDEFAULT_CHARSET=utf8 \
        -DDEFAULT_COLLATION=utf8_general_ci \
        -DWITH_BOOST=/usr/local/boost \
        -DDOWNLOAD_BOOST=1
     如果已经下载过boost则去掉-DDOWNLOAD_BOOST=1 选项
     这种方式查看版本:/data/service/hds/mysql/bin/mysql --version
    basedir=/data/service/hds/mysql
    bindir=/data/service/hds/mysql/bin
    datadir=/data/service/hds/mysql/data

3. mysql服务管理
    启动:/etc/init.d/mysql.server start
        service mysql.server start
        systemctl start mysql.server
        /usr/local/mysql/support-files/mysql.server start
    停止:/etc/init.d/mysql.server stop
        service mysql.server stop
        systemctl stop mysql.server
    重启:/etc/init.d/mysql.server restart
        service mysql.server restart
        systemctl restart mysql.server

4. 判断启动
    ps aux|grep mysqld
    ps aux| grep mysqld | grep -v grep
    lsof -i :3306

5. 账号及权限分配
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '123456' WITH GRANT OPTION;
    grant select on *.* to 'devreadonly'@'%' identified by 'ugH7+hsSmw1';
    GRANT ALL PRIVILEGES ON *.* TO 'devuser'@'%'IDENTIFIED BY '5ji&DjiUtu"2' WITH GRANT OPTION;
    flush privileges;

6. 查询权限
    SHOW GRANTS FOR '用户名'@'主机名';
    show grants for 'backup'@'%';
    show grants for 'backup';

备注:默认安装目录:/usr/local/mysql/
     默认数据目录:/usr/local/mysql/data/
     可执行文件目录:/usr/local/mysql/bin/

每天备份mysql

vi /data1/env/script/dev_mysqldump.sh
#!/bin/bash

DATE=`date +%F`
DUMP_LOG="/data1/logs/app"
DUMP_DIR="/data1/env/backup"
DUMP_CMD="mysqldump -uroot -phandeson.com -h localhost"
DUMP_LIST="db_cart_1 db_coupon_1 db_order_1 db_pay_1 db_user_1 db_finance_middle"

for db in $DUMP_LIST ;
do
#no data
$DUMP_CMD -d $db >$DUMP_DIR/table_${db}_${DATE}.sql

#no table
$DUMP_CMD -t $db >$DUMP_DIR/data_${db}_${DATE}.sql

#check
if [ $? == 0 ] ;then
    echo "`date +%F_%H:%M:%S` Dump ${db} success !" >>${DUMP_LOG}/dump_${DATE}.log
else
    echo "`date +%F_%H:%M:%S` Dump ${db} faild !" >>${DUMP_LOG}/dump_${DATE}.log
fi

#Tar
cd $DUMP_DIR
gzip table_${db}_${DATE}.sql.tar.gz table_${db}_${DATE}.sql
gzip data_${db}_${DATE}.sql.tar.gz data_${db}_${DATE}.sql

done

#delete old file 7 days ago
find $DUMP_DIR -type f -mtime +7 -name "*.gz" -delete


配置crontab:00 01 * * * /bin/bash /data1/env/script/dev_mysqldump.sh >/dev/null 2>&1

mac系统下各环境安装

linux、unix系列系统下常用安装方法总结

1. 源码编译方式安装: ./configure 、make、sudo make install
2. 使用包管理工具安装: 如yum、dnf、apt-get、dpkg、brew、port 等
3. 使用rpm命令安装: rpm -ivh  rpm包文件名