赞
踩
第一步:安装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 install 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%'; 查看密码规则
default_password_lifetime ----默认密码生存期
disconnect_on_expired_password ----断开密码的连接
log_builtin_as_identified_by_password ----密码识别日志
mysql_native_password_proxy_users ----MySQL _ native _ password _代理_用户
old_passwords ----旧密码
report_password ----报告密码
sha256_password_proxy_users ----sha 256 _密码_代理_用户
validate_password_check_user_name ----验证密码检查用户名
validate_password_dictionary_file ----指定密码验证的文件路径
validate_password_length ----密码最小长度
validate_password_mixed_case_count ----密码至少要包含的小写字母个数和大写字母个数
validate_password_number_count ----密码至少要包含的数字个数
---------------------------------------------------------------------------------------------------------------------
validate_password_policy ----密码强度检查等级,对应等级为:0/LOW 1/MEDIUM 2/STRONG,默认为1注意:
0/LOW:只检查长度;
1/MEDIUM:检查长度、数字、大小写、特殊字符;
2/STRONG:检查长度、数字、大小写、特殊字符字典文件;
---------------------------------------------------------------------------------------------------------------------
validate_password_special_char_count ----密码至少要包含的特殊字符数
设置更改参数方法:
比如:设置密码强度检查等级:set global validate_password_policy=0;
也可以选择配置禁用密码策略
在/etc/my.cnf文件添加validate_password_policy配置,指定密码策略,或直接禁用密码策略,添加 validate_password = off重新启动(systemctl restart mysql) mysql服务使配置生效。
————————————————————————————————————————————————————————
如何设置mysql超过登陆次数锁住用户:
select * from user;---找到需要限制的用户,
update user set password_lifetime=3,account_locked='Y' where `Host`='localhost' and user='macxiao';--超过3次锁住
flush PRIVILEGES; --更新完必须刷新权限
----用户锁住解锁:
在一个大的权限里:update user set password_lifetime=NULL,account_locked='N' where `Host`='localhost' and user='macxiao';
flush PRIVILEGES;
__________________________________________________________________________________________________
第三步:修改用户密码
把所有数据库的所有表的管理权限赋值给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 +密码
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。