189 8069 5689

CentOS6.9系统编译安装MySQL5.7.16教程

本文主要给大家介绍CentOS6.9系统编译安装MySQL5.7.16教程,其所涉及的东西,从理论知识来获悉,有很多书籍、文献可供大家参考,从现实意义角度出发,创新互联累计多年的实践经验可分享给大家。 

轵城ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为成都创新互联公司的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18982081108(备注:SSL证书合作)期待与您的合作!

CentOS6.9编译安装MySQL5.7.16

部署环境:

系统CentOS6.9,mysql5.7.16,boost库

系统为2G内存

1、安装依赖包,使用yum安装cmake,6.9默认yum源自带

    yum -y install gcc-c++ cmake bison-devel ncurses-devel

2、创建mysql的用户:

    useradd  -U -s /sbin/nologin mysql

3、创建必要的文件夹,并修改其目录用户所有者:

    mkdir -pv /usr/local/mysql/etc

    mkdir -pv /data/{boost/boost_1_59_0,mysql/{data,log}}

    chown -R mysql:mysql /usr/local/mysql/

    chown -R mysql:mysql /data/mysql/

4、将boots库拷贝到boost目录下

    cp /tmp/boost/boost_1_59_0/* /data/boost/boost_1_59_0

    chown -R mysql:mysql /data/boost/

5、编译安装mysql5.7

CentOS6.9系统编译安装MySQL5.7.16教程

    cd /tmp

    tar xf mysql-5.7.16.tar.gz

    cd mysql-5.7.16

    cmake \

    -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

    -DMYSQL_DATADIR=/data/mysql/data \

    -DSYSCONFDIR=/usr/local/mysql/etc \

    -DWITH_MYISAM_STORAGE_ENGINE=1 \

    -DWITH_INNOBASE_STORAGE_ENGINE=1 \

    -DWITH_MEMORY_STORAGE_ENGINE=1 \

    -DWITH_READLINE=1 \

    -DMYSQL_UNIX_ADDR=/data/mysql/log/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=/data/boost/boost_1_59_0

    make && make install

    时间比较长

    chown -R mysql:mysql /usr/local/mysql

6、配置文件my.cnf

    [client]

    port    = 3306

    socket  = /data/mysql/log/mysql.sock

    [mysql]

    default-character-set = utf8

    [mysqld]

    # file

    datadir =/data/mysql/data

    basedir = /usr/local/mysql

    pid-file =/data/mysql/log/mysqld.pid

    log_error = /data/mysql/log/mysql.err

    port = 3306

    socket=/data/mysql/mysql.sock

    user=mysql

    character_set_server = utf8

    character_set_server = utf8

    slow_query_log = 1

    slow_query_log_file = /data/mysql/log/slowq.log

    long_query_time = 1

    log-bin=/data/mysql/log/mysql-bin.log

    # temp

    max_tmp_tables = 64

    tmp_table_size = 512M

    slave_load_tmpdir = /data/mysql/log

    tmpdir = /data/mysql/log

    # session

    back_log = 512

    skip-name-resolve

    max_allowed_packet = 32M

    max_connections = 16000

    max_connect_errors = 10000

    wait_timeout = 28800

    table_open_cache = 216

    thread_cache_size = 128

    query_cache_type = 0

    query_cache_size = 0

    key_buffer_size = 128M

    myisam_sort_buffer_size = 16M

    read_buffer_size = 16M

    read_rnd_buffer_size = 16M

    sort_buffer_size = 16M

    join_buffer_size = 16M

    # innodb

    default_storage_engine = InnoDB

    innodb_data_home_dir = /data/mysql/data

    innodb_data_file_path = ibdata1:256M:autoextend

    innodb_log_group_home_dir = /data/mysql/log

    innodb_log_files_in_group = 4

    innodb_log_file_size = 256M

    innodb_log_buffer_size = 8M

    innodb_flush_log_at_trx_commit = 2

    innodb_flush_method = O_DIRECT

    innodb_lock_wait_timeout = 50

    #innodb_thread_concurrency = 24 16

    innodb_buffer_pool_size = 1G

    innodb_io_capacity = 1500

    innodb_use_native_aio = 1

    innodb_file_per_table = 1

    innodb_open_files = 3000

    # others

    memlock = 1

    performance_schema = 0

    # replication

    server-id = 150

    binlog_format = row

    expire_logs_days = 7

    relay_log = /data/mysql/log/relay-bin

    #replicate_ignore_db = mysql

    #slave_skip_errors = 1062

    log_slave_updates = 1

    skip-slave-start

    read_only = 0

    sync_binlog = 1

    [mysqldump]

    default-character-set = utf8

    [mysqld-5.7]

    innodb_buffer_pool_dump_pct = 40

    innodb_undo_log_truncate = 1

    innodb_undo_tablespaces = 3

    innodb_max_undo_log_size = 1G

    innodb_purge_rseg_truncate_frequency = 128

    binlog_gtid_simple_recovery=1

    log_timestamps=system

    show_compatibility_56=on

    sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

7、初始化数据库

    版本在5.7.6前用的是mysql_install_db

    版本5.7.6之后使用的mysqld --initialize

    #####################官网标注#####################################

    shell> bin/mysql_install_db --user=mysql    # MySQL 5.7.5

    shell> bin/mysqld --initialize --user=mysql # MySQL 5.7.6 and up

    shell> bin/mysql_ssl_rsa_setup              # MySQL 5.7.6 and up

    #####################官网标注#####################################

    /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/data/mysql/data --basedir=/usr/local/mysql

    可能会出现内存不够的报错,自己优化下调节一下buffer大小就行了

    /usr/local/mysql/bin/mysql_ssl_rsa_setup

    没有打印日志,临时密码不能用,只好破解了,后面有方法。

8、启动数据库

    vim /usr/local/mysql/support-files/mysql.server

    加上绝对路径

    basedir=/usr/local/mysql

    datadir=/data/mysql/data

    cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

    service mysqld start

9、配置环境变量

    vim /etc/profile

    export PATH=/usr/local/mysql/bin:$PATH

    source /etc/profile

10、查看mysql临时密码,这项我这不用了,不好使,直接破解了。

    cat /root/.mysql_secret

    mysql -uroot -p`cat /root/.mysql_secret`

    如果能进去,基本上到这就截止了,可以正常使用了。

    

**不能正常登录,使用临时密码无法登进去**

11、破解密码

    mysqld_safe --defaults-file=/usr/local/mysql/etc/my.cnf --skip-grant-tables --skip-networking&

    update mysql.user set authentication_string=password('123456') where user='root';

    11.1、查找进程号,杀掉mysql进程

        ps aux | grep mysql 

        kill -9 pid

        service mysqld start

    11.2、登录mysql

        mysql -u root -p 'password'

        提示修改密码:

        mysql> alter user root@localhost identified by '123456';

看了以上CentOS6.9系统编译安装MySQL5.7.16教程介绍,希望能给大家在实际运用中带来一定的帮助。本文由于篇幅有限,难免会有不足和需要补充的地方,大家可以继续关注创新互联行业资讯板块,会定期给大家更新行业新闻和知识,如有需要更加专业的解答,可在官网联系我们的24小时售前售后,随时帮您解答问题的。

 


新闻名称:CentOS6.9系统编译安装MySQL5.7.16教程
当前URL:http://cdxtjz.cn/article/gdooch.html

其他资讯