yum安装配置MySQL数据库

1.配置yum源

# 先安装wget
yum install wget -y
 
 

2.下载mysql源安装包

wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
 

3.安装数据库

yum localinstall mysql57-community-release-el7-8.noarch.rpm -y
 

4.检查mysql源是否安装成功

yum repolist enabled | grep "mysql.*-community.*"
yum install mysql-community-server -y
启动MySQL服务
systemctl start mysqld
查看MySQL的启动状态
systemctl status mysqld
 

5.设置开机启动

systemctl enable mysqld
systemctl daemon-reload    
 

6.修改数据库修改root默认密码

mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。
查看默认密码
grep 'temporary password' /var/log/mysqld.log
 
其中 jIDqgfoE-2KZ 就是我的默认密码
登陆数据库 
mysql -uroot -p
修改默认密码
mysql> SET PASSWORD = PASSWORD('Lenovo@123');
Lenvoo@123是你的新密码
如何解决ERROR 1819 (HY000): Your password does not satisfy the current policy requirements呢? 这里直接提供解决方案文末有详细的说明
必须修改两个全局参数:
首先,修改validate_password_policy参数的值
set global validate_password_policy=0;
再修改密码的长度
set global validate_password_length=1;
再次执行修改密码就可以了
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Lenovo@123';
***********允许root远程登陆**********
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Lenovo@123' WITH GRANT OPTION;
 
退出数据库
 
posted @ 2020-05-13 13:26  SRE运维博客  阅读(1613)  评论(0编辑  收藏  举报