• Linux 安装 MySQL


    一、准备工作

    1. mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz,下载地址

    二、创建MySQL用户

    1. su – root
    2. 创建mysql用户
      %T_[}W}`_5@DTX86}W$S{3M
    3. 创建数据和日志目录
      J$IFZMRT8Y(E@1%J5PJATHA
    4. 目录赋予权限
      72`PG9]A{{ZYE2ABGBP~@5R

    三、解压安装包

    1. 通过xshell等工具将安装包上传到Linux中;
    2. 解压安装包;
      2(`1T}}WKY$0ANH75LLF`TA
    3. 修改目录权限
      )761O0W~UF6@IRTBSJ1991Q

    四、修改配置文件

      1. 复制my.cnf配置文件
        7CF@FBUX%L2`}G19)UV_LCW

        [client]
        port            = 3306
        socket          = /tmp/mysql3306.sock
        secure_auth     = false
        
        [mysqld]
        port            = 3306
        socket          = /tmp/mysql3306.sock
        datadir         = /home/mysql/mysql3306
        #read_only       = on
        
        #--- GLOBAL ---#
        character_set_server    = utf8
        lower_case_table_names  = 1
        log-output              = FILE
        log-error               = /home/mysql/logs/mysql-error.log
        #general_log
        general_log_file        = /home/mysql/logs/mysql.log
        pid-file                = /home/mysql/mysql.pid
        slow-query-log          = 1
        slow_query_log_file     = /home/mysql/logs/mysql-slow.log
        tmpdir                  = /tmp/
        long_query_time         = 2
        innodb_force_recovery   = 0
        #innodb_buffer_pool_dump_at_shutdown = 1
        #innodb_buffer_pool_load_at_startup = 1
        #--------------#
        
        #thread_concurrency      = 8  
        thread_cache_size       = 51  
        table_open_cache        = 16384
        open_files_limit        = 65535
        table_definition_cache  = 16384
        sort_buffer_size        = 2M
        join_buffer_size        = 2M
        read_buffer_size        = 2M
        read_rnd_buffer_size    = 8M
        key_buffer_size         = 32M
        bulk_insert_buffer_size = 16M
        myisam_sort_buffer_size = 64M
        tmp_table_size          = 32M
        max_heap_table_size     = 16M 
        query_cache_size       = 32MB
        
        #gtid_mode=on
        #log_slave_updates=1
        #enforce_gtid_consistency=1
        
        #--- NETWORK ---#
        back_log                = 103
        max-connections         = 512
        max_connect_errors    = 100000
        max_allowed_packet      = 32M
        interactive_timeout     = 600
        wait_timeout            = 600
        skip-external-locking
        #max_user_connections    = 0
        external-locking        = FALSE
        #skip-name-resolve
        
        #--- REPL ---#
        server-id               = 1103306
        sync_binlog             = 1
        log-bin                 = mysql-bin
        binlog_format           = row
        expire_logs_days        = 10
        relay-log               = relay-log
        replicate-ignore-db     = test
        log_slave_updates       =1
        #skip-slave-start
        binlog_cache_size       =4M
        max_binlog_cache_size   =8M
        max_binlog_size         =1024M
        
        
        
        #--- INNODB ---#
        default_storage_engine          = InnoDB
        innodb_data_file_path           = ibdata1:1024M:autoextend
        innodb_buffer_pool_size         = 1040M
        innodb_buffer_pool_instances    = 1
        innodb_additional_mem_pool_size = 16M
        innodb_log_files_in_group       = 2
        innodb_log_file_size            = 256MB
        innodb_log_buffer_size          = 16M
        innodb_flush_log_at_trx_commit  = 2
        innodb_lock_wait_timeout        = 30
        innodb_flush_method             = O_DIRECT
        innodb_max_dirty_pages_pct      = 75
        innodb_io_capacity              = 200
        innodb_thread_concurrency       = 32
        innodb_open_files               = 65535
        innodb_file_per_table           = 1
        transaction_isolation           = REPEATABLE-READ
        innodb_locks_unsafe_for_binlog  = 0
        #innodb_purge_thread            = 4
        skip_name_resolve               = 1
        [mysqldump]
        quick
        max_allowed_packet = 32M
        
        
        [mysql]
        auto-rehash
        # Remove the next comment character if you are not familiar with SQL
        #safe-updates
        default_character_set=utf8
        
        
        [mysqlhotcopy]
        interactive-timeout

        字段解释
    #字段解释#
    [mysqld]
        port   = 3306  mysql的启动的端口
        socket  = /tmp/mysql3306.sock  (在启动的时候mysqld会自动生成,以socket文件的通信性质,只能本地登录)
        datadir  = /home/mysql/mysql3306   (数据目录)
        log-error   = /home/mysql/logs/mysql-error.log
        (INFO WARN ERROR)
    
        server-id = 1103306(IP后两位+端口 192.168.1.10   3306)
        innodb_buffer_pool_size  = 512M
        (50%--75%)内存的总大小

    五、配置服务

    L@)LF7MMQWE6QV%X$G7RXAD

    vi /etc/init.d/mysqld
    修改两处位置:
    basedir=/usr/local/mysql
    datadir=/data/mysql_data

    六、初始化MySQL (只需要做一次)

    5}]1@0CLGR9M}TI~YK4~JJ9

    七、配置环境变量

      1. 添加MySQL到”/etc/profile”,并更新系统环境变量;
        UB`2F72T(_F87H](HK1WZNT
    #在"/etc/profile"中添加如下配置
    export MYSQL_HOME=/usr/local/mysql
    PATH=$PATH:$MYSQL_HOME/bin

    八、启动MySQL服务

      1. 删除系统中其他数据库客户端(若安装过其他数据库);
    rm -rf /usr/bin/mysql* 
    ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
    1. 启动MySQL服务
      F27D0ITRX]RB({E4N(_)WIF

    九、进入数据库

    1. 第一次进入数据库;
      /usr/local/mysql/bin/mysql -uroot -p -S /tmp/mysql3306.sock
      DBZYQ(UGV$Z]J`3X`E$_$9M

    2.通过用户名及密码登录数据库客户端(前提是配置了密码)
       mysql -uroot -p

    十、权限管理

    1. 查看用户信息;
      select user,host,password from mysql.user;
      DT_HVA_K_I2[D2RXIQV96(E
    2. 设置root本地权限及密码;
      grant all on *.* to root@'localhost' identified by 'root';
      V81)5QSR1LK)G_H2BEF490R
    3. 删除没有密码的用户,并创建jack用户;
      delete from mysql.user where password ='';
      O$B77F20VFWH$_2$(01N`R8

    十一、进入数据库流程

    1. 启动MySQL 服务;
      mysqld_safe --user=root &
    2. 登录数据库客户端;
      mysql -uroot -p
      69S]7({WTX%O8[PAGH$3WPT
  • 相关阅读:
    Struts2之Action基础与配置
    关于Struts2的类型转换详解
    Struts2自定义类型转换器
    MyEclipse 快捷键
    Struts2中的ActionContext
    struts2中的action访问web对象
    5.9每日一题题解
    5.8 每日一题题解
    5.7 每日一题题解
    5.6 每日一题题解
  • 原文地址:https://www.cnblogs.com/luomeng/p/10629755.html
Copyright © 2020-2023  润新知