CentOS7 安装 MySQL 5.7(yum)

安装并启动

wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
yum localinstall mysql57-community-release-el7-8.noarch.rpm -y
yum repolist enabled | grep "mysql.*-community.*"
yum install mysql-community-server -y
systemctl start mysqld
systemctl status mysqld
systemctl enable mysqld

获取 mysql 初始密码

grep 'temporary password' /var/log/mysqld.log

2020/03/image-6169c204.png

进入 mysql

利用上一步获取的初始密码登录

mysql -uroot -p 

设置 mysql 新密码

set global validate_password_policy=0;
alter user 'root'@'localhost' identified by 'Aafsdfa24tg';
update mysql.user set host = '%' where user = 'root';
flush privileges;

创建数据库

create database hive character set utf8 ;
CREATE USER 'hive'@'%'IDENTIFIED BY 'Aafsdfa24tg';
GRANT ALL PRIVILEGES ON *.* TO 'hive'@'%';
FLUSH PRIVILEGES;
exit;

安装 mysql java 驱动

yum install mysql-connector-java -y

进入

mysql -uroot -pAafsdfa24tg