Centios7 下安装 Mysql 5.7
- 在删除之前先清空本机上的 Mysql
rpm -qa | grep mysql
rpm -e -nodeps + 名称
强制卸载
再清楚与mysql相关的目录
find / -name mysql
rm -rf + 目录名
yum list | grep mysql
查看有没有相应的yum源
有的话可以直接安装,这里是没有的,所以需要配置 yum 源
下载源安装包
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
安装 Mysql 源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
检测是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
修改 默认安装的 Mysql 版本
vim /etc/yum.repos.d/mysql-community.repo
将5.7源的 enabled=0 改为 endaled=1
安装 Mysql
yum install mysql-community-server
启动 Mysql 服务
systemctl start mysqld
查看启动是否成功
ps -ef | grep mysqld | grep -v grep
查看状态
systemctl status mysql
设置开机启
systemctl enable mysqld
systemctl daemon-reload
修改 root 登陆密码
mysql 安装完成后,在 /var/log/mysql.log 文件中给 root 生成了一个默认密码
grep 'temporary password' /var/log/mysqld.log
root@localhost: 后面就是默认初始密码
mysql -u root -p + 默认密码 登陆
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';
如果想设置密码为空,则会出现
you have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the right syntax to use near ‘indentified by ”’ at line 1
的错误,这是与 Mysql 的密码强度检查等级相关的
我们可以直接修改 mysql 参数配置
vim /etc/my.conf
添加
validate_password = off
重启服务
systemctl restart mysqld
此时就可以设置简单密码了
配置文件:/etc/my.cnf
日志文件:/var/log//var/log/mysqld.log
服务启动脚本:/usr/lib/systemd/system/mysqld.service
socket文件:/var/run/mysqld/mysqld.pid