centos7在线安装mysql5.7

    技术2025-09-11  68

    1、下载mysql yum源

    wget https://mirrors.ustc.edu.cn/mysql-repo/mysql57-community-release-el7-9.noarch.rpm

    2、安装mysql yum源

    yum localinstall mysql57-community-release-el7-9.noarch.rpm

    3、安装mysql

    yum install mysql-community-server -y

    4、启动mysql服务并设置开机启动

    service mysqld start #设置mysql开机启动 chkconfig mysqld on

    5、获取临时密码

    grep 'temporary password' /var/log/mysqld.log

    6、使用临时密码登录

    mysql -uroot -p 输入临时密码

    7、设置密码

    set global validate_password_policy=0; set global validate_password_length=1; ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';

    8、修改远程访问权限,不然用工具连接不上

    grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option; flush privileges;

    9、设置字符集

    vim /etc/my.cnf #在[mysqld]部分添加: character-set-server=utf8 #在文件末尾新增[client]段,并在[client]段添加: [client] default-character-set=utf8
    Processed: 0.010, SQL: 9