linux安装mysql

  1. 安装Mysql

    • mysql yum 源下载

    • 使用wget下载,如centos7/mysql8.0

      wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
      
    • 使用命令本地安装

      sudo yum localinstall mysql80-community-release-el7-3.noarch.rpm
      
    • 查看本地允许安装的mysql版本

      yum repolist enabled | grep "mysql.*-community.*"
      
    • 查看可安装的

      yum repolist all | grep mysql
      
    • 选择允许安装的

      # vim /etc/yum.repos.d/mysql-community.repo
      
      [mysql-cluster-7.5-community]
      name=MySQL Cluster 7.5 Community
      baseurl=http://repo.mysql.com/yum/mysql-cluster-7.5-community/el/7/$basearch/
      # 这里
      enabled=0
      gpgcheck=1
      gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
      
    • 再次查看允许安装的。

      [root@localhost sed]# yum repolist enabled | grep mysql
      !mysql-connectors-community/x86_64       MySQL Connectors Community          153
      !mysql-tools-community/x86_64            MySQL Tools Community               110
      !mysql80-community/x86_64                MySQL 8.0 Community Server          177
      
    • 安装mysql

       sudo yum install mysql-community-server
      
    • 启动

      sudo service mysqld start
      sudo service mysqld status
      
  2. 配置Mysql

    • 第一次安装查看随机生成的密码

      sudo grep 'temporary password' /var/log/mysqld.log
      
    • 进入并修改密码

      mysql -uroot -p
      rename user 'root'@'localhost' to 'root'@'%';
      ALTER USER 'root'@'%' IDENTIFIED BY 'MyNewPass4!';
      
      • 密码默认是有限制的,即;包含英文大小写数字和特殊字符,不少于8位。
    • 修改启动绑定端口和ip

      vim /etc/my.conf
      [mysqld]
      port = 3306
      bind-address=0.0.0.0
      
    • 查看密码安全级别

      SHOW VARIABLES LIKE 'validate_password.%';
      # 修改值
      set @num=1;
      

你可能感兴趣的:(Linux系统)