• MySql5.7


    1、安装依赖软件
    yum install -y gcc-c++ make cmake bison bison-devel ncurses-devel libaio-devel perl perl-Data-Dumper
     
    2、创建用户与用户组
    cat /etc/passwd | grep mysql
    cat /etc/group | grep mysql
    groupadd mysql
    useradd -r -g mysql mysql
     
    3、解压boost和mysql安装包
    tar xzf boost_1_59_0.tar.gz
    tar xzf mysql-boost-5.7.17.tar.gz
     
    4、创建MySQL数据目录
    mkdir -p /data/mysql
    cd mysql-5.7.17
     
    5、预编译
    cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mysql -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/data/software/mysql/boost_1_59_0
     
    6、编译安装
    make -j `grep processor /proc/cpuinfo | wc -l` #编译很消耗系统资源,小内存可能编译通不过
    make install
     
    7、设置开机自动开启
    /bin/cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
    chmod +x /etc/init.d/mysqld
    chkconfig --add mysqld
    chkconfig mysqld on
     
    8、修改/etc/my.cnf
    [client]
    port = 3306
    socket = /tmp/mysql.sock
    default-character-set = utf8
     
    [mysqld]
    port = 3306
    socket = /tmp/mysql.sock
     
    basedir = /usr/local/mysql
    datadir = /data/mysql
    pid-file = /data/mysql/mysql.pid
    user = mysql
    bind-address = 0.0.0.0
    server-id = 1
     
    init-connect = 'SET NAMES utf8'
    character-set-server = utf8
    log_bin_trust_function_creators=1
     
    #skip-name-resolve
    #skip-networking
    back_log = 300
     
    max_connections = 1000
    max_connect_errors = 6000
    open_files_limit = 65535
    table_open_cache = 128
    max_allowed_packet = 4M
    binlog_cache_size = 1M
    max_heap_table_size = 8M
    tmp_table_size = 16M
     
    read_buffer_size = 2M
    read_rnd_buffer_size = 8M
    sort_buffer_size = 8M
    join_buffer_size = 8M
    key_buffer_size = 4M
     
    thread_cache_size = 8
     
    query_cache_type = 1
    query_cache_size = 8M
    query_cache_limit = 2M
     
    ft_min_word_len = 4
     
    log_bin = mysql-bin
    binlog_format = mixed
    expire_logs_days = 30
     
    log_error = /data/mysql/mysql-error.log
    slow_query_log = 1
    long_query_time = 1
    slow_query_log_file = /data/mysql/mysql-slow.log
     
    performance_schema = 0
    explicit_defaults_for_timestamp
     
    lower_case_table_names = 1
    sql_mode='NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER'
     
     
    skip-external-locking
     
    default_storage_engine = InnoDB
    #default-storage-engine = MyISAM
    innodb_file_per_table = 1
    innodb_open_files = 500
    innodb_buffer_pool_size = 64M
    innodb_write_io_threads = 4
    innodb_read_io_threads = 4
    innodb_thread_concurrency = 0
    innodb_purge_threads = 1
    innodb_flush_log_at_trx_commit = 2
    innodb_log_buffer_size = 2M
    innodb_log_file_size = 32M
    innodb_log_files_in_group = 3
    innodb_max_dirty_pages_pct = 90
    innodb_lock_wait_timeout = 120
     
    bulk_insert_buffer_size = 8M
    myisam_sort_buffer_size = 8M
    myisam_max_sort_file_size = 10G
    myisam_repair_threads = 1
     
    interactive_timeout = 28800
    wait_timeout = 28800
     
    [mysqldump]
    quick
    max_allowed_packet = 16M
     
    [myisamchk]
    key_buffer_size = 8M
    sort_buffer_size = 8M
    read_buffer = 4M
    write_buffer = 4M
     
    9、初始化数据库
    /usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
     
    10、启动数据库
    service mysqld start
     
    11、设置数据库密码及授权
    dbrootpwd=Ces123456 #数据库root密码
    /usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by "$dbrootpwd" with grant option;"
    /usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by "$dbrootpwd" with grant option;"
     
    12、添加环境变量 vi /etc/profile
    export MYSQL_HOME=/usr/local/mysql
    export PATH=$PATH:$MYSQL_HOME/bin
     
    13、修改root密码和授权新用户
    mysql> set password=password('Ces123456');
    mysql> grant all on *.* to root@'%' identified by 'Ces123456';
    mysql> flush privileges;
    mysql> select user,host,authentication_string from mysql.user;
     
    14、开放3306端口号
    vi /etc/sysconfig/iptables
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
    service iptables restart
    在另一台web服务器上安装nc测试端口连通性
    yum install nc -y
    nc -z -w 1 192.168.1.247 3306
  • 相关阅读:
    PHP上传文件
    PHP文件系统操作常用函数
    利用ini_set()函数实现对php配置文件的修改
    文本文件合并(C++实现)
    手把手教你在新浪云上免费部署自己的网站--连接数据库
    手把手教你在新浪云上免费部署自己的网站---基础
    update2
    在Windows命令行中编译运行C/C++程序
    【转】CSS颜色代码大全
    (html4与html5分别实现)用一个表单向php界面提交不同的命令
  • 原文地址:https://www.cnblogs.com/emily1130/p/7505166.html
Copyright © 2020-2023  润新知