美文网首页
MySql数据库--Liunx安装(二)

MySql数据库--Liunx安装(二)

作者: 无剑_君 | 来源:发表于2020-06-29 17:07 被阅读0次

    一、下载安装

    # 下载rpm 文件 
    [root@localhost ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
    [root@localhost ~]# yum -y localinstall mysql80-community-release-el7-3.noarch.rpm
    # 安装mysql
    [root@localhost ~]# yum -y install mysql-community-server
    

    二、启动

    # 启动mysql
    [root@localhost ~]# systemctl start mysqld
    # 端口查看
    [root@localhost ~]# netstat -tnal|grep 3306
    tcp6       0      0 :::3306                 :::*                    LISTEN     
    tcp6       0      0 :::33060                :::*                    LISTEN     
    # 设置开机启动
    [root@localhost ~]# systemctl enable mysqld
    [root@localhost ~]# systemctl daemon-reload
    # 重启命令
    [root@localhost ~]# systemctl restart mysqld
    

    三、用户设置

    # mysql初次启动会生成默认密码,需要到日志文件搜索
    [root@localhost ~]# grep "A temporary password is generated for root@localhost" /var/log/mysqld.log
    2020-01-22T08:59:00.825035Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 0jTSLvaCbc,A
    # 登录mysql
    [root@localhost ~]# mysql -uroot -p
    # 修改root密码 随机密码生成地址:https://suijimimashengcheng.51240.com/
    ALTER USER 'root'@'localhost' IDENTIFIED BY 'Root233!@#';
    # 创建可远程登录用户
    CREATE USER 'mysql'@'%' IDENTIFIED BY 'Mysql233!@#';
    # 用户授权
    GRANT ALL ON *.* TO 'mysql'@'%';
    # 下面修改密码策略,否则会登录失败
    use mysql;
    ALTER USER 'mysql'@'%' IDENTIFIED BY 'Mysql233!@#' PASSWORD EXPIRE NEVER;
    ALTER USER 'mysql'@'%' IDENTIFIED WITH mysql_native_password BY 'Mysql233!@#';
    FLUSH PRIVILEGES;
    

    相关文章

      网友评论

          本文标题:MySql数据库--Liunx安装(二)

          本文链接:https://www.haomeiwen.com/subject/fhpvsctx.html