• mysql


    centos7:

    yum -y install gcc gcc-devel gcc-c++ gcc-c++-devel autoconf* automake* zlib* libxml*ncurses-devel ncurses libgcrypt* libtool* cmake openssl openssl-devel bisonbison-devel perl-Data-Dumper boost boost-doc boost-devel ncurses-devel

    groupadd mysql 
    useradd -g mysql -s /sbin/nologin mysql
    mkdir -p /data/mysql
    chown -R mysql:mysql /data/mysql
    tar zxf mysql-5.7.15.tar.gz && tar zxf boost_1_59_0.tar.gz
    cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1  -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_BOOST=/data/mysql/boost_1_59_0 -DMYSQL_TCP_PORT=3306
    make && make install

    #cp配置文件

    cp support-files/my-default.cnf /etc/my.cnf

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

    cp /usr/local/mysql/bin/* /usr/bin/

    chmod 755 /etc/init.d/mysqld

    初始化配置安装:

     cd /usr/local/mysql/bin

    ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql

    mkdir /data/mysql/log && chown -R mysql:mysql /data/mysql 

    配置文件 my.cnf

    [client]

    port = 3306

    socket = /data/mysql/mysql.sock

    [mysqld]

    binlog_format = mixed

    port = 3306

    socket = /data/mysql/mysql.sock

    basedir = /usr/local/mysql

    datadir = /data/mysql
    log-bin = mysql1-bin

    server-id = 5
    binlog-ignore-db = mysql

    binlog-ignore-db = information_schema

    binlog-ignore-db = sys

    binlog-ignore-db = performance_schema

    auto-increment-increment = 5

    auto-increment-offset = 1

    log-slave-updates = ON

    max_connections=3000

    log_timestamps=SYSTEM
    back_log=50

    max_user_connections=2000

    innodb_thread_concurrency=8

    default-storage-engine=InnoDB

    innodb_buffer_pool_size=8192M

    innodb_log_buffer_size=8M

    innodb_log_file_size=48M

    innodb_flush_log_at_trx_commit=2

    innodb_lock_wait_timeout=50

    long_query_time = 1

    slow_query_log=YES

    slow_query_log_file=/data/mysql/log/slow.log

    log-error=/data/mysql/log/error.log

    plugin-load=AUDIT=libaudit_plugin.so
    audit_json_file=1
    audit_json_file=ON
    audit_record_cmds=connect,Quit,show,select,insert,update,delete
    audit_whitelist_users=admintool,blacklist,blackselect,procdb,mysql1,gmetric,mysql.sys,{}

     
    查看mysql临时密码
    cat ~/.mysql_secret
    mysql修改密码
    格式:mysql> set password for 用户名@localhost = password('新密码'); 
     
    授权:grant replication slave,replication client on 库名.表名 to '用户名'@'IP地址' identified by '密码';
       flush privileges;
    复制:change master to master_host='192.168.1.102',master_user='rep',master_password='123456',master_log_file='mysql-bin.000002',master_log_pos=453;
     
     

    命令行下具体用法如下: 

    mysqldump -u用戶名 -p密码 -d 数据库名 表名 > 脚本名;

    mysql -u用戶名 -p密码 数据库名 < 脚本名

    导出整个数据库结构和数据

    mysqldump -h localhost -uroot -p123456 database > dump.sql

    导出单个数据表结构和数据

    mysqldump -h localhost -uroot -p123456  database table > dump.sql

    导出整个数据库结构(不包含数据)

    mysqldump -h localhost -uroot -p123456  -d database > dump.sql

    导出单个数据表结构(不包含数据)

    mysqldump -h localhost -uroot -p123456  -d database table > dump.sql

    导出存储过程

    mysqldump -u 数据库用户名 -p -n -t -d -R 数据库名 > 文件名  。再导入时如果报错ERROR 1235 (42000) at line **: This version of MySQL doesn't yet support ‘multiple triggers with the same action time and event for one table’,需要把trigger关闭

    mysqldump -u 数据库用户名 -p -n -t -d -R --triggers=false 数据库名 > 文件名  。 如果报错ErrorCode:1418This function has none of DETERMINISTIC, NOSQL, or READS SQL DATA inits declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)

    解决方法是,在/etc/my.cnf中找到[mysqld],在它下面添加这样一行:log-bin-trust-function-creators=1

    清理十天之前的binlog:PURGE MASTER LOGS BEFORE DATE_SUB(CURRENT_DATE, INTERVAL 10 DAY);

    清除MySQL-bin.010日志:PURGE MASTER LOGS TO 'MySQL-bin.010';

  • 相关阅读:
    使用expect实现ssh免密码登陆
    vim不小心ctrl+Z解决办法
    bash 自动补全
    PHP缓存技术
    windows下安装python的easy_install工具
    python中用lxml解析html
    python中用xpath和xml.dom解析html
    申请使用sourceforge免费空间几点注意事项
    创建.htaccess文件
    静态资源放置于独立域名之下
  • 原文地址:https://www.cnblogs.com/ywxbbbbb/p/9590533.html
Copyright © 2020-2023  润新知