zoukankan      html  css  js  c++  java
  • linux 安装Mysql

    一、查看版本,并卸载历史版本

    1、查看已有版本:rpm -qa|grep -i mysql
    2、卸载:yum -y remove mysql-libs-5.1.73-7.el6.x86_64 (或者:rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64 删除不检查依赖)

    二、下载与安装
    1、搜索mysql yum repository,获取下载地址。
    2、wget https://repo.mysql.com//mysql80-community-release-el7-4.noarch.rpm
    3、rpm -ivh mysql80-community-release-el7-4.noarch.rpm
    4、yum install mysql-community-server

    三、启动与密码设置
    1、启动mysql:service mysqld start //查看状态:service mysqld status
    2、查看初始随机密码:grep "password" /var/log/mysqld.log
    3、修改初始密码

     // 登录mysql root账户,初始密码为上面查询出的密码。
          >mysql -u root -p

    3.1、mysql 5.7
    (1)set global validate_password_policy=0;(注意:mysql 8.0第二个单词连接符是“.”,即*.policy)
    (2)set global validate_password_length=0;
    (3)alter user user() identified by 'Root@2021';
    (4)flush privileges;
    3.2、mysql 8.0
    (1)alter user user() identified by 'Root@2021';
    (2)set global validate_password.policy=0;(注意:mysql 5.7第二个单词连接符是“_”,即*_policy)
    (3)set global validate_password.length=1;
    (4)flush privileges;
    4、查看密码策略:show variables like 'validate_password%';(注意:mysql 8.0必须先修改密码,才能执行本语句)

    四、设置远程链接
    5.1、mysql 5.7
    (1)# mysql_secure_installation
    (2)GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "123456";
    (3)flush privileges;
    5.2、mysql 8.0
    (1)create user root@'%' identified by '123456';
    (2)grant all privileges on *.* to root@'%' with grant option;
    (3)flush privileges;

    //  注意:完成三、四部分设置后,本地root登录密码与远程root登录密码不同。本地root账户登录为Root@2021,远程root账户登录为123456。

    五、创建数据和用户
    1、create database testdb; // 删除:drop database testdb;
    2、create user'test'@'%' identified by '123456'; // 删除:drop user 'test'@'%';
    3、grant all privileges on testdb.* to 'test'@'%';
    4、flush privileges;

  • 相关阅读:
    抽签问题及优化
    P1020
    p1852ants
    1,三角形
    TG3
    如何看懂一篇题解
    Unsupported major.minor version 51.0 错误解决方案
    weblogic初学笔记2-在Linux上部署项目
    一块移动硬盘怎样兼容Mac和Windows系统,并且可以在time machine上使用
    org.hibernate.HibernateException: connnection proxy not usable after transaction completion
  • 原文地址:https://www.cnblogs.com/vvonline/p/15713420.html
Copyright © 2011-2022 走看看