Mysql学习总结之安装配置

版本:
    mysql  Ver 14.14 Distrib 5.7.19, for linux-glibc2.12 (x86_64) using  EditLine wrapper
安装包:
    mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
解压:
    [root@rhel6 mysql]#tar -zxvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
文件夹改名(方便):
    [root@rhel6 mysql]#mv mysql-5.7.19-linux-glibc2.12-x86_64 mysql
再新建mysql的用户和用户组:
    [root@rhel6 mysql]# groupadd mysql
    [root@rhel6 mysql]# useradd -r -g mysql mysql
创建配置文件:
    vim /etc/my.cnf
    [client]
    port = 3306
    socket = /tmp/mysql.sock
    [mysqld]
    character_set_server=utf8
    init_connect='SET NAMES utf8'
    basedir=/u01/mysql
    datadir=/u01/mysql/data
    socket=/tmp/mysql.sock
    log-error=/u01/mysql/log/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid
    lower_case_table_names = 1
    sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
    max_connections=5000
    default-time_zone = '+8:00'
    log-bin=/u01/mysql/log/mysql-bin
    server-id=10241
修改权限:
    [root@rhel6 u01]# chown -R mysql:mysql mysql
初始化:
    [root@rhel6 u01]# mysqld --initialize --user=mysql --basedir=/u01/mysql --datadir=/u01/mysql/data --lc_messages_dir=/u01/mysql/share --lc_messages=en_US
    2018-12-26T21:51:58.320354Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2018-12-26T21:51:58.914975Z 0 [Warning] InnoDB: New log files created, LSN=45790
    2018-12-26T21:51:59.004806Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
    2018-12-26T21:51:59.092588Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 7842c967-0958-11e9-9f6c-000c296ee978.
    2018-12-26T21:51:59.095301Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
    2018-12-26T21:51:59.096011Z 1 [Note] A temporary password is generated for root@localhost:     
创建文件mysqld.pid,mysqld.log:
    [root@rhel6 mysqld]# vim mysqld.pid
    [root@rhel6 mysqld]#chmod 777 mysqld.pid
    [root@rhel6 mysqld]#chown mysql:mysql mysqld.pid
启动服务并登陆:
    /usr/local/mysql/support-files/mysql.server start
    /usr/local/mysql/bin/mysql -uroot -p你在上面看到的初始密码
加入到系统服务中:
    [root@rhel6 support-files]#cp mysql.server /etc/init.d/mysqld
    [root@rhel6 support-files]#chkconfig --add mysqld
    [root@rhel6 support-files]#chkconfig mysqld on
    [root@rhel6 support-files]#service mysqld restart
重置密码:
    [root@rhel6 support-files]# mysql -uroot -p
    mysql> set password=password('Cqmyg14dss');
    mysql> flush privileges;
开启binlog:
    my.cnf中添加配置
    log-bin=/u01/mysql/log/mysql-bin
    server-id=10241

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值