CentOS 7 安装mysql5.7

一、下载mysql

下载mysql源安装包

wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

安装mysql源

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

(可跳过)查看mysql源是否安装成功

yum repolist enabled | grep "mysql.*-community.*"

 

二、安装mysql

安装mysql

yum install mysql-community-server

 若提示公钥未安装,则跳过检测

yum install mysql-community-server --nogpgcheck

 

三、启动mysql

启动

systemctl start mysqld

查看mysql状态

systemctl status mysqld

开机自启动

systemctl enable mysqld
systemctl daemon-reload

 

四、登录mysql

查看默认密码,mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。
grep 'temporary password' /var/log/mysqld.log

登录mysql

mysql -u root -p (再提示后输入密码)

关闭密码策略

set global validate_password_policy=0;
set global validate_password_length=1;

修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'root123';  (root123为新密码)

 允许root账号远程访问

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

重启

service mysqld restart 

 

posted @ 2022-01-15 12:34  幻月hah  阅读(49)  评论(0编辑  收藏  举报