首页 > 技术文章 > mysql安装

welearn 2019-10-30 12:01 原文

mysql安装:(https://blog.csdn.net/itcats_cn/article/details/89148971)
1、卸载系统自带mariadb数据库
rpm -qa| grep mariadb
rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64
2、下载yum库
wget http://dev.MySQL.com/get/mysql57-community-release-el7-7.noarch.rpm
yum localinstall -y mysql57-community-release-el7-7.noarch.rpm
3、安装mysqlServer
yum install -y mysql-community-server
4启动mysql
systemctl start mysqld.service
5、设置开机启动
systemctl enable mysqld
systemctl daemon-reload
检查mysql服务状态
service mysqld status
6、修改root本地登录密码
由于mysql5.7会自动生成密码,密码文件存储在/var/log/mysqld.log 中搜索password关键字即可找到密码,登陆mysql
mysql -uroot -p
重置root用户密码
mysql > alter user 'root'@'localhost' identified by '密码';
(备注 mysql5.7默认密码策略要求密码必须是大小写字母数字特殊字母的组合,至少8位)(设置密码策略低)
mysql > set global validate_password_policy=LOW
重新以root用户和刚设置的密码进行登录即可。并授权用户root使用密码从任何主机连接到mysql服务器
mysql > grant all privileges on *.* to 'root'@'%' identifiedby '密码' with grant option;
mysql > flush privileges;
或允许用户root只能从ip为192.168.1.1的主机连接到mysql服务器
mysql > grant all privileges on *.* to 'root'@'192.168.1.1' identified by '密码' with grant option;
mysql > flush privileges;

推荐阅读