到官网https://dev.mysql.com/downloads/下载mysql
wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
yum -y install mysql80-community-release-el7-1.noarch.rpm
安装MySQL服务器
yum -y install mysql-community-server
安装完成之后启动MySQL服务
systemctl start mysqld.service
查看状态
systemctl status mysqld.service
获取初始密码
grep "password" /var/log/mysqld.log
输入初始密码,此时不能做任何事情,因为MySQL默认必须修改密码之后才能操作数据库;但是,因为MySQL有密码设置的规范,密码设置太过简单会报错,具体是与validate_password_policy的值有关;然后不修改密码就不能修改validate_password_policy,所以我在这里先将密码修改,改成一个满足要求的密码,然后在进行validate_password_policy的修改。
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Hadoop3!';
允许远程连接
CREATE USER 'admin'@'%' IDENTIFIED BY 'Hadoop3!';
grant all privileges on *.* to 'admin'@'%';
#mac下navicat连接不上,需要修改语句:
CREATE USER 'admin'@'%' IDENTIFIED WITH mysql_native_password BY 'Hadoop3!';
或者ALTER USER 'admin'@'%' IDENTIFIED WITH mysql_native_password BY 'Hadoop3!';
grant all privileges on *.* to 'admin'@'%';
flush privileges;