- 检查是否已经安装过mysql,执行命令:
rpm -qa | grep mysql
2. 从官网下载是用于Linux的Mysql安装包:
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
- 执行就可以直接yum安装了:
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server
- 启动mysql:
systemctl start mysqld.service
- 查看MySQL运行状态,运行状态如图
systemctl status mysqld.service
- 通过如下命令可以在日志文件中找出密码
grep "password" /var/log/mysqld.log
7. 修改密码:
mysql -uroot -p # 回车后会提示输入密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';