- 安装yum mysql数据源命令
yum localinstall https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
- 安装mysql服务
yum install mysql-community-server
- 启动mysql服务
# 启动成功没有提示
systemctl start mysqld
- 获取初始化密码
cat /var/log/mysqld.log | grep password
- 登陆mysql
# 输入上面刚刚那个密码
mysql -u root -p
- 修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Mysql8.0';
如果爆出 ERROR 1819 (HY000): Your password does not satisfy the current policy requirements 错误,原因是你的密码不安全,要包含大小写,数字和字符
到了这一步,MySQL已经安装完成了:
- 设置远程连接
# 首先先登录
# 使用mysql 数据库
use mysql;
# 特定用户的host 修改
update user set host='%' where user='root';
# 允许所有 ip 远程访问(危险! 自己玩的服务器不影响 就像吸烟有害健康一样)
grant all privileges on *.* to 'root'@'%' with grant option;
# 刷新数据库
FLUSH PRIVILEGES;
- navicat链接时报 2059 错误,执行下面命令
alter user 'root'@'%' identified with mysql_native_password by 'yourPassword';
- 阿里云安全组开放端口 这里我用的是阿里云
- 常用命令
启动mysql服务
systemctl start mysqld.service
停止mysql服务
systemctl stop mysqld.service
重启mysql服务
systemctl restart mysqld.service
查看mysql服务当前状态
systemctl status mysqld.service
设置mysql服务开机自启动
systemctl enable mysqld.service
停止mysql服务开机自启动
systemctl disable mysqld.service
注:主页有各种JAVA开发工具安装包下载