安装 Mysql 新建目录
检查、卸载 1 2 3 4 5 6 7 8 rpm -qa | grep mysql rpm -e mysql rpm -e --nodeps mysql
下载安装 下载地址 。下载地址 2 需要根据 linux 版本来选择。
1 2 3 4 wget https://downloads.mysql.com/archives/get/p/23/file/mysql-community-server-5.7.44-1.el6.x86_64.rpm rpm -ivh mysql-community-release-el8-1.noarch.rpm yum update yum install mysql-server
权限设置 1 chown -R mysql:mysql /var/lib/mysql/
初始化
查看并记住初始密码 1 2 3 cat /var/log/mysqld.log | tail -n 10
启动 mysql
查看运行状态
问题 1、centos 应先卸载 mariadb
数据库 1 2 3 4 rpm -qa|grep mariadb rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
2、systemctl start mysqld
时报错 报错:Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
表示 mysql 文件夹权限不够。
1 2 3 4 5 6 7 8 9 cd /var/lib/mysqlchown -R mysql:mysql /var/lib/mysqlchmod -R 777 /var/lib/mysqlsystemctl start mysqld.service