• linux安装mysql


    1.首先通过 find / -name mysql  找到之前残余的mysql,通过 rm -rf  删除干净

    2.通过wget下载

     wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz 

    3.解压到 /usr/local 目录下

    4.重命名为mysql

     mv mysql-5.7.25-linux-glibc2.12-x86_64 mysql 

    5.添加系统mysql组和mysql用户

     groupadd mysql 

     useradd -r -g mysql mysql      #useradd -r参数表示mysql用户是系统用户,不可用于登录系统

    6.在mysql目录创建data目录

     mkdir data 

    7.将所有者及所属组改为mysql

     chown -R mysql.mysql /usr/local/mysql 

    8.在/usr/local/mysql/support-files目录下创建my_default.cnf

     vim my_default.cnf  

    [mysqld]
    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
    
    basedir = /usr/local/mysql
    datadir = /usr/local/mysql/data
    port = 3306
    socket = /tmp/mysql.sock
    character-set-server=utf8
    
    log-error = /usr/local/mysql/data/mysqld.log
    pid-file = /usr/local/mysql/data/mysqld.pid

    9.拷贝

     cp my_default.cnf /etc/my.cnf 

    10.在bin目录下初始化mysqld

     ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data 

    11.初始化完成之后,查看日志

     /usr/local/mysql/data/mysqld.log 

    12.可以看到临时密码

     2021-04-08T06:14:29.790033Z 1 [Note] A temporary password is generated for root@localhost: a8?DQir=T+k+ 

    13.把启动脚本放到开机初始化目录

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

    14.启动mysql服务

     service mysql start 

    15.登录mysql,bin目录下

     ./mysql -u root -p 

    16.修改密码

     set password=password('root'); 

    8.0版本:

     ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码' 

    17.授权

     grant all privileges on *.* to root@'%' identified by 'root'; 

    18.刷新权限

     flush privileges; 

    19. 重新启动

     service mysql restart 

  • 相关阅读:
    zabbix--5.0.2部署手册
    ssh远程连接出现WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
    centos7自带python2.7.5安装pip
    Nginx代理kibana方法2
    安洵杯Laravel反序列化非预期+POP链挖掘
    vue笔记:vue组件的生命周期
    通用测试用例编写
    Vue笔记:Vue中使用mockjs
    Python map、reduce、filter函数用法
    Python如何实现异步IO
  • 原文地址:https://www.cnblogs.com/coderxiaobai/p/12846782.html
Copyright © 2020-2023  润新知