• 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;

  • 相关阅读:
    企业级云数据库最佳实践
    NLP带来的“科幻感”超乎你的想象
    大咖来了:共话人工智能技术新生态
    2020年以后...软件开发人员趋势为何?
    云计算从入门到入行-专业培训认证课程限时0元领取
    linux 安装java jdk
    hadoop 配置信息记录
    hadoop 部署在centos 7 上
    centos 7 安装jdk
    Hadoop 集群ssh免密登录设置
  • 原文地址:https://www.cnblogs.com/cghhnty/p/8036048.html
Copyright © 2020-2023  润新知