• centos7安装mysql


    cd  /opt

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

    rpm -ivh mysql-community-release-el7-5.noarch.rpm

     yum install mysql-community-server

    成功安装之后重启mysql服务

    service mysqld restart  (实际运行Redirecting to /bin/systemctl restart  mysqld.service)

    初次安装mysql是root账户是没有密码的

    设置密码的方法

    mysql -uroot

    mysql> set password for 'root'@'localhost' = password('root');

    mysql> exit

    mysql -uroot -p

    创建msql账号用来远程登录:

    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;

    flush privileges;

     查看用户是否有远程登录权限(内置mysql的user表)

    SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;

    设置监控日志:

    vim etc/my.cnf

     找到[mysqlId],添加如下代码:

    log =/tmp/mysqls.log 
    log-slow-requeries = /tmp/mysqlslowquedery.log(如果需要监控慢查询)
    long_query_time = 1

    msql5.7以上版本改为

    general_log=ON
    general_log_file=/var/log/mysql/mysql.log
    slow_query_log = on
    slow-query-log-file = /var/log/mysql/mysql-slow.log
    long_query_time = 2

    service mysqld restart

    监控SQL语句
    tail -f  /var/log/mysql/mysql.log

    将mysql升级为5.7

    cd /opt
    rpm -qa|grep mysql
    rpm -e --nodeps mysql-community-common-5.6.37-2.el7.x86_64 ...
    wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
    rpm -ivh mysql57-community-release-el7-7.noarch.rpm
    yum install mysql-server
    mysql -V
    systemctl start mysqld
    修改密码
    mysql_secure_installation
    允许外部访问
    update user set host='%' where user='root';
    flush privileges;

    exit;

  • 相关阅读:
    推箱子
    为textarea增加maxlength属性(转)
    validate
    keypress
    Knockout
    & replace &
    银联参数
    chinapay
    model binding
    JSON.stringify
  • 原文地址:https://www.cnblogs.com/cghhnty/p/8036048.html
Copyright © 2020-2023  润新知