mysql5.7安装

1、下载

wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm 

2、安装

rpm -ivh mysql-community-release-el7-5.noarch.rpm 
yum install mysql-community-server

3、修改/etc/my.cnf

    [client]
    #password       = your_password
    port            = 3309
    socket          = /tmp/mysql.sock
    
    # Here follows entries for some specific programs
    
    # The MySQL server
    [mysqld]
    
    user = hc
    port            = 3309
    socket          = /tmp/mysql.sock
    pid-file		= /usr/local/mysql/mysqld.pid
    skip-external-locking
    slave-net-timeout = 60
    #log_slave_update = 1
    #skip-grant-tables
    
    sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
    key_buffer_size = 256M
    max_allowed_packet = 512M
    table_open_cache = 2048
    sort_buffer_size = 16M
    read_buffer_size = 16M
    read_rnd_buffer_size = 16M
    myisam_sort_buffer_size = 16M
    thread_cache_size = 64
    join_buffer_size = 16M
    #query_cache_type = 0
    query_cache_size = 16M
    
    innodb_buffer_pool_size = 4096M
    innodb_flush_log_at_trx_commit = 2
    innodb_file_per_table
    
    innodb_open_files = 3000
    #table_cache = 4096
    innodb_log_file_size = 256M
    
    # Try number of CPU's*2 for thread_concurrency
    #thread_concurrency = 2
    
    lower_case_table_names = 1
    skip-name-resolve
    character_set_server = utf8
    max_connections = 5000
    log-bin=mysql-bin
    expire_logs_days = 30
    
    # binary logging format - mixed recommended
    binlog_format = mixed
    #binlog_format = ROW
    
    # required unique id between 1 and 2^32 - 1
    # defaults to 1 if master-host is not set
    # but will not function as a master if omitted
    
    server-id       = 2
    #event_scheduler = 0
    

    #slow query
    slow_query_log = ON
    slow_query_log_file = /data/mysqldata/slow.log
    long_query_time = 1

    datadir = /data/mysqldata
    log-error = /data/logs/mysql/mysqld.log
    log-output = FILE
    log_bin_trust_function_creators = 1
    
    [mysqldump]
    quick
    max_allowed_packet = 512M
    
    [mysql]
    no-auto-rehash
    prompt=MySQL >
    # Remove the next comment character if you are not familiar with SQL
    #safe-updates
    
    [myisamchk]
    key_buffer_size = 128M
    sort_buffer_size = 128M
    read_buffer = 2M
    write_buffer = 2M
    
    [mysqlhotcopy]
    interactive-timeout

4、启动

service mysqld restart

5、加入启动项目

   

systemctl enable   mysqld

5、设置root密码

mysql -uroot 
mysql> set password for ‘root'@‘localhost' = password('mypasswd');

6、创建数据库并指定utf-8编码

mysql> CREATE DATABASE xxxx DEFAULT CHARSET utf8 COLLATE utf8_general_ci

7、导入数据库

    mysql>use 数据库 
    -- 然后使用source命令,后面参数为脚本文件(如这里用到的.sql) 
    mysql>source dbname.sql

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值