centos7安装mysql
1.下载mysql
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.28-1.el7.x86_64.rpm-bundle.tar
2.解压
tar -vxf mysql-8.0.28-1.el7.x86_64.rpm-bundle.tar
3.删除mariadb
查询rpm -qa |grep mariadb
没有就不需要删除
删除rpm -e --nodeps mariadb-libs
4.安装mysql
要按循序,包之间又依赖关系
- rpm -ivh mysql-community-common-8.0.28-1.el7.x86_64.rpm
- rpm -ivh mysql-community-client-plugins-8.0.28-1.el7.x86_64.rpm
- rpm -ivh mysql-community-libs-8.0.28-1.el7.x86_64.rpm
- rpm -ivh mysql-community-client-8.0.28-1.el7.x86_64.rpm
- rpm -ivh mysql-community-icu-data-files-8.0.28-1.el7.x86_64.rpm
- rpm -ivh mysql-community-server-8.0.28-1.el7.x86_64.rpm
5.初始化mysql
初始化命令:mysqld --initialize --console
启动mysql:systemctl start mysql
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
启动失败添加权限 chown -R mysql:mysql /var/lib/mysql
查看初始化密码:cat /var/log/mysqld.log|grep localhost
进入mysql:mysql -uroot -p,输入密码