在CentOS中默认安装有MariaDB,这个是MySQL的分支,但为了需要,还是要在系统中安装MySQL,而且安装完成之后可以直接覆盖掉MariaDB。
下载并安装MySQL官方的 Yum Repository
[root@localhost ~]# wget -i -c https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
使用yum安装rpm
[root@localhost ~]# yum -y install mysql80-community-release-el7-1.noarch.rpm
使用yum安装MySQL服务
[root@localhost ~]# yum -y install mysql-community-server
mysql设置
启动MySQL
[root@localhost ~]# systemctl start mysqld.service
查看MySQL运行状态
[root@localhost ~]# systemctl status mysqld.service
查看MySQL root账户默认密码
[root@localhost ~]# grep "password" /var/log/mysqld.log
使用如下命令进入MySQL数据库
[root@localhost ~]# mysql -uroot -p
输入初始密码,修改默认密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
如果上面命令提示如下内容,说明密码强度不够,可以修改密码强度校验规则
修改密码强度校验规则
查看密码强度校验规则
mysql> SHOW VARIABLES LIKE 'validate_password%';
修改密码强度校验等级
mysql> set global validate_password.policy=0;
修改密码强度校验长度
mysql> set global validate_password.length=1;
卸载前面安装的yum repository仓库
[root@localhost ~]# yum -y remove mysql80-community-release-el7-1.noarch
安装正式完成
mysql启动关闭命令
systemctl start mysqld
systemctl start mysqld.service
service mysqld start
service mysqld.service start
四种方法都能启动服务
systemctl status mysqld
systemctl status mysqld.service
service mysqld status
service mysqld.service status
四种方法都能显服务状态
引用https://blog.csdn.net/sifanlook/article/details/101283809?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.essearch_pc_relevant&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.essearch_pc_relevant
引用https://www.cnblogs.com/CloudComputing-binbin/p/14458826.html
root账号修改密码问题处理:
引用https://blog.csdn.net/weixin_41238134/article/details/99707670
引用https://cloud.tencent.com/developer/article/1478072?from=14588
引用https://www.cnblogs.com/nuanyingzi/p/13432465.html