• linux基础服务补充-mysql5.7版本二进制包安装


    1、创建用户和组

    [root@localhost ~]# groupadd mysql
    [root@localhost ~]# useradd -g mysql mysql -s /sbin/nologin

    2、创建数据库安装相关目录、并授权

    [root@localhost ~]# mkdir /mysql/{data,log} -p

    [root@localhost ~]# chown -R mysql:mysql /mysql

    3、解压文件,并移动到/usr/local目录下,并授权

    [root@localhost src]# tar -zxvf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz

    [root@localhost src]# mv mysql-5.7.25-linux-glibc2.12-x86_64 /usr/local/mysql

    [root@localhost src]# chown -R mysql:mysql /usr/local/mysql

    4、初始化数据库

    [root@localhost mysql]# ./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/mysql/data --innodb_undo_tablespaces=3 --explicit_defaults_for_timestamp

    注意:这里完成之后记住最后有一个root账号的密码

    5、编辑配置文件

    [client]
    port = 3306
    socket = /tmp/mysql.sock
    [mysqld]
    server_id=10
    port = 3306
    user = mysql
    character-set-server = utf8mb4
    default_storage_engine = innodb
    log_timestamps = SYSTEM
    socket = /tmp/mysql.sock
    basedir = /usr/local/mysql
    datadir = /mysql/data
    pid-file = /mysql/data/mysql.pid
    max_connections = 1000
    max_connect_errors = 1000
    table_open_cache = 1024
    max_allowed_packet = 128M
    open_files_limit = 65535
    #####====================================[innodb]==============================
    innodb_buffer_pool_size = 1024M
    innodb_file_per_table = 1
    innodb_write_io_threads = 4
    innodb_read_io_threads = 4
    innodb_purge_threads = 2
    innodb_flush_log_at_trx_commit = 1
    innodb_log_file_size = 512M
    innodb_log_files_in_group = 2
    innodb_log_buffer_size = 16M
    innodb_max_dirty_pages_pct = 80
    innodb_lock_wait_timeout = 30
    innodb_data_file_path=ibdata1:1024M:autoextend
    innodb_undo_tablespaces=3
    ######====================================[log]==============================
    log_error = /mysql/log/mysql-error.log
    slow_query_log = 1
    long_query_time = 1
    slow_query_log_file = /mysql/log/mysql-slow.log
    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

    6、配置启动文件

    [root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld

    [root@localhost mysql]# chmod a+x /etc/init.d/mysqld

    [root@localhost mysql]# service mysqld start

    7、配置环境变量

    [root@localhost mysql]# vim /etc/profile

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

    [root@localhost mysql]# source /etc/profile

    8、修改root用户密码

    [root@localhost data]# mysqladmin -uroot -p7Ve_S0iKgtB+ password 123456

    9、mysql安全设置,根据自己的情况来设置

    [root@localhost data]# mysql_secure_installation

  • 相关阅读:
    辅助性的“比较操作符”
    辅助性的“比较操作符”
    浙江一乘客没赶上火车退票不成把票撕了 结果"悲剧"了
    美国超震撼短片-梦想
    在HTML文件中加入空格
    揭秘人造肉
    不能发布网站简讯
    KMPlayer
    文件四处盖章签字等
    冬天到了如何御寒
  • 原文地址:https://www.cnblogs.com/hackerlin/p/11314300.html
Copyright © 2020-2023  润新知