您的位置:首页 > 运维架构 > Linux

CentOS7安装Mysql

2019-05-02 21:16 94 查看
  1. 在MySQL官网中查看YUM源rpm安装包:http://dev.mysql.com/downloads/repo/yum/
  2. 下载mysql安装源:
    wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
  3. 安装mysql源:
    yum localinstall mysql80-community-release-el7-3.noarch.rpm
  4. 选择mysql版本,编辑文件:
    vi /etc/yum.repos.d/mysql-community.repo
    ,将要安装mysql版本的enable设为1,并将其他版本的enable设为0
  5. 安装mysql:
    yum install mysql-community-server -y
  6. 启动mysql:
    systemctl start mysqld
  7. 查看mysql状态:
    systemctl status mysqld
  8. 查看mysql root超级管理员密码:
    grep 'temporary password' /var/log/mysqld.log
  9. 登录mysql :
    mysql -u root -p
  10. 修改root密码:
    alter user 'root'@'localhost' identified by'YourNewPassword!'
  11. 禁用密码策略,编辑my.cnf文件
    vi /etc/my.cnf
    ,在[mysqld]下添加:
    validate_password = off
  12. 设置默认编码,编辑my.cnf文件
    vi /etc/my.cnf
    ,在[mysqld]下添加:
    character_set_server=utf8

    init_connect='SET NAMES utf8'
  13. 编辑完后,重启mysql:
    systemctl restart mysqld
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: