CenterOS7安装Mysql 5.7

yum -y install mysql-community-server
# 提示错误
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
No package mysql-community-server available.
Error: Nothing to do
# 下载需要的依赖
cd /usr/local/src/
wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
# 安装依赖
rpm -ivh mysql57-community-release-el7-11.noarch.rpm
# 安装mysql服务
yum install mysql-community-server -y
# 启动mysql
systemctl start mysqld
# 添加开机启动
systemctl enable mysqld

查看root默认密码

# 查找A temporary password is generated for root@localhost: 默认密码
more /var/log/mysqld.log 

登录mysql

mysql -u root -p

修改密码

#登录后 输入命令会提示你修改密码
#ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

alter user user() identified by '密码';
#提示 说明密码格式没有达到要求
#ERROR 1819 (HY000): Your password does not satisfy the current policy requirements 

添加远程链接

#查看用户
select Host,User from mysql.user;
#添加用户
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%'IDENTIFIED BY 'admin' WITH GRANT OPTION;
# *.* 代表 所有库.所有表
# 第一个admin为账户 第二个admin为密码

#设置立即生效
flush privileges;

你可能感兴趣的:(CenterOS7安装Mysql 5.7)