之前介绍了CentOS6.5安装MySQL5.6,这篇文章则在使用CentOS7.2的系统安装MySQL5.7

安装前提
纯净的CentOS7.2操作系统,不要安装Mariadb数据库,如果已经安装,请先卸载Mariadb服务
配置yum源
添加mysql镜像源
cat >/etc/yum.repos.d/mysql-community.repo <<EOF[mysqld]name=MySQL 5.7 Community Serverbaseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/enabled=1gpgcheck=0EOF

删除旧的yum缓存
yum clean all
新建yum缓存
yum makecache

检查所有可用的仓库列表中,是否包含mysql的源
yum repolist enabled | grep mysql
安装数据库服务
yum install mysql-community-server -y

启动mysql
启动数据库服务
systemctl start mysqld.service
查看数据库服务状态
systemctl status mysqld.service

关闭数据库
systemctl stop mysqld.service
重启数据库
systemctl restart mysqld.service
设置数据库开机自启动
systemctl enable mysqld.service
查看进程
ps -ef | grep mysqldss -lnatup | grep 3306

修改密码
查看数据库密码
grep 'temporary password' /var/log/mysqld.log

mysql -uroot -p#使用密码登录:ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';#退出mysql数据库\q

本地登录数据库
mysql -uroot -p使用密码登录:
授权普通用户
创建数据库
create database imoocc;
授权管理给到用户 注意,MySQL5.7对于密码的复杂度有一定的要求,请记得密码!!!
grant all on imoocc.* to imoocc@'%' identified by '123456!Aa';
刷新权限表
flush privileges;

普通用户远程登录
用户远程登录
mysql -h YourIP -uimooc -p

文章转载自anyux,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




