centos7安装mysql5.7 rpm安装

第一步:安装mysql
首先确认虚拟机安装的是centos 7还是centos 6,安装方法是不同的,本手册是centos7的安装方法
cat /etc/redhat-release   --查看版本号确定是centos7系列,才确认一下操作
wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm  --下载mysql5.7rpm
ls -l  --查看确认是否成功
yum localinstall mysql57-community-release-el7-11.noarch.rpm  --安装 mysql源,安装中一直选择y,直到安装成功
yum repolist enabled | grep "mysql.*-community.*"  --出现如下显示,mysql源安装成功



yum install mysql-community-server --安装mysql服务
如果安装中出现如下报错:
 Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.56-2.el7 will be an update
---> Package mariadb-libs.x86_64 1:5.5.56-2.el7 will be an update
---> Package mariadb-server.x86_64 1:5.5.56-2.el7 will be an update
--> Processing Dependency: mariadb-server for package: akonadi-mysql-1.9.2-4.el7.x86_64
--> Finished Dependency Resolution
Error: Package: akonadi-mysql-1.9.2-4.el7.x86_64 (@anaconda)
           Requires: mariadb-server
           Removing: 1:mariadb-server-5.5.52-1.el7.x86_64 (@anaconda)
               mariadb-server = 1:5.5.52-1.el7
           Obsoleted By: mysql-community-server-5.6.38-2.el7.x86_64 (mysql56-community)
               Not found
           Updated By: 1:mariadb-server-5.5.56-2.el7.x86_64 (base)
               mariadb-server = 1:5.5.56-2.el7
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
报错原因:软件包依赖 mariadb组件
解决办法:yum -y remove mariadb-libs
再安装yum install mysql-community-server

第二步:启动mysql
安装mysql服务完成之后启动mysql服务
systemctl start mysqld--启动 mysql服务
systemctl status mysqld --查看mysql服务状态

如上显示,则mysql服务已经成功安装;

systemctl enable mysqld--设置为开机启动
systemctl daemon-reload

如果在启动mysql服务的时候出现 如下报错信息,则可能是系统权限的问题, shell > chown -r mysql:mysql /var/lib/mysql/  进行授权
Failed to issue method call: Unit mysql.service failed to load: No such file or directory. See system logs and 'systemctl status mysql.service' for details.
rpm -qa | grep -i mysql  --查看安装的mysql组件


grep 'temporary password' /var/log/mysqld.log  --查看mysql默认密码,并登陆的时候输入
登陆mysql:     mysql -u root -p  +密码
注意:mysql5.7默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements错误
如果需要修改密码规则:  show variables like '%password%'; 查看密码规则
可以在/etc/my.cnf文件添加validate_password_policy配置,指定密码策略,或直接禁用密码策略,添加 validate_password = off 重新启动( systemctl restart mysql ) mysql服务使配置生效。

第三步:修改用户密码
把所有数据库的所有表的管理权限赋值给root用户。
 grant all privileges on *.* to root@'%'identified by 'password';
或新建用户再给其赋予所有权限
grant all privileges on *.* to username@'%'identified by 'password' with grant option;
则可以用root或新用户进行远程连接。

详细地址:https://www.cnblogs.com/lightsrs/p/7836651.html


第四步:登陆mysql
mysql -u root -p +密码










猜你喜欢

转载自blog.csdn.net/qq_24726509/article/details/80790879