mysql官方(http://dev.mysql.com/downloads/repo/yum/)获取Yum Repository。
一、安装
1. wgethttp://repo.mysql.com/mysql57-community-release-el7-11.noarch.rpm
2. md5summysql57-community-release-el7-11.noarch.rpm ##md5校验
3. rpm -ivhmysql57-community-release-el7-11.noarch.rpm
4. yum -y install mysql-server
5. systemctl enable mysqld #设置开机启动
systemctldisable mysqld #关闭开机启动
6. systemctl startmysqld #启动Mysql数据库
在使用yum装完mysql5.7后,默认root是不允许进行本地登录,获取mysql的初始密码。
MySQL进程会自动在进程日志中打印root用户的初始密码,用grep过滤
#grep"paasword" /var/log/mysqld.log
修改root用户密码
#mysql -uroot-p (这块密码为上面过滤出来的随机密码)
进去之后会要求你先进行修改root密码,
alter user'root'@'localhost' identified by '123456';
报错:ERROR 1819 (HY000): Your password does not satisfy the currentpolicy requirements
原因:所要修改的密码必须包含有数字,大小写或者字母,特殊字符,若想简化,不要那么复杂的密码,需要修改两个全局参数
set globalvalidate_password_policy=0; ###基于密码长度
set globalvalidate_password_length=1; ###
修改这两参数,在修改密码即可。
1. vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables
2. 重启MySQL
systemctlrestart mysqld.service
3. 登陆修改root密码
输入命令:
mysql
进入mysql后输入:
USE mysql
update mysql.user setauthentication_string=password("123456") where user="root";
flush privileges ;
4. vi /etc/my.cnf
把skip-grant-tables去掉或者注释掉
5. 重启mysql