CentOS 7安装mysql5.7
2018-03-04 本文已影响47人
雨果是程序员
1、mariadb和mysql
CentOS 7 已经放弃mysql安装,而是安装mariadb。(可能是版权问题)
所以,安装centos 7安装mysql不能直接用yum install mysql命令。
需用用如下的操作进行安装。
2、下载mysql源安装包
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
3.安装mysql源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
4、安装mysql
yum install mysql-community-server
5、启动mysql服务
systemctl start mysqld
6.查看mysql的启动状态
systemctl status mysqld
7.设置开机启动
systemctl enable mysqld
systemctl daemon-reload
8.修改密码
需要先查看默认建立的密码:
grep 'temporary password' /var/log/mysqld.log
结果可知:
A temporary password is generated for root@localhost: HrtC<+uh>2o1
mysql登录:
mysql -u root -p
HrtC<+uh>2o1
修改密码:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'HrtC<+uh>2o1';
mysql> set password for 'root'@'localhost'=password('自己的密码');
注意:mysql5.7的密码策略是:大小写字母+符号
否则会报错:
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
9.查看密码策略
mysql>show variables like ‘%password%’
10.添加允许远程登录用户
grant all privileges on *.* to root@"%" identified by "自己的密码";
11.常用技巧
清屏:
方式一:Ctrl+L
方式二:\! clear