centos 上mysql5.7安装及配置

1.下载和安装mysql源

(1)下载 mysql源安装包

wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

注:

  如果提示 wget: command not found

  安装wget

yum -y install wget

(2)安装mysql源

rpm -ivh mysql57-community-release-el7-9.noarch.rpm

2.安装mysql

yum -y install mysql-server

启动

systemctl start mysqld

重启

systemctl restart mysqld

设置开机启动

systemctl enable mysqld
systemctl daemon-reload

3.修改密码及配置

在/var/log/mysqld.log文件中给root生成了一个临时的默认密码

进入mysql

 mysql -u root -p 

输入密码

#e*uP8Cf)%U5

修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';

远程登录

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

配置默认编码为utf8

vi /etc/my.cnf

[mysqld] 
character_set_server=utf8 

新建用户

create user 'baby'@'%' identified by '123456';

将数据库test的全部权限给baby

grant all privileges on `test`.* to 'baby'@'%' ;

修改密码遇到

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

posted @ 2020-01-21 13:26  慕尘  阅读(356)  评论(0编辑  收藏  举报