Mysql5.7 安装
CentOS7 yum方式安装MySQL5.7:
参考:https://www.cnblogs.com/luohanguo/p/9045391.html
下载MySQL官方的 Yum Repository
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
开始安装MySQL服务器
yum -y install mysql-community-server
启动MySQL
systemctl start mysqld.service
查看MySQL运行状态
systemctl status mysqld.service
找出此时root用户的密码:
grep "password" /var/log/mysqld.log
进入数据库,输入初始密码:
mysql -u root -p
解决新密码设置的时候如果设置的过于简单会报错:
mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1;
更改mysql密码:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'passwd';
此时还有一个问题,因为安装了Yum Repository,以后每次yum操作都会自动更新,需要把这个卸载掉:
yum -y remove mysql57-community-release-el7-10.noarch
rpm安装(有点问题):
安装依赖:
yum -y install make gcc-c++ cmake bison-devel ncurses-devel libaio libaio-devel net-tools
检查系统是否存在mysql、mariadb 命令rpm -qa | grep mysql
# rpm -qa | grep mariadb
mariadb-5.5.44-2.el7.centos.x86_64
mariadb-server-5.5.44-2.el7.centos.x86_64
mariadb-devel-5.5.44-2.el7.centos.x86_64
mariadb-libs-5.5.44-2.el7.centos.x86_64
# rpm -qa | grep mysql
akonadi-mysql-1.9.2-4.el7.x86_64
pcp-pmda-mysql-3.10.6-2.el7.x86_64
qt-mysql-4.8.5-11.el7.x86_64
卸载 mysql、mariadb
yun -y romove akonadi-mysql-1.9.2-4.el7.x86_64
yun -y romove pcp-pmda-mysql-3.10.6-2.el7.x86_64
yun -y romove qt-mysql-4.8.5-11.el7.x86_64
yum -y remove mariadb-5.5.44-2.el7.centos.x86_64
yum -y remove mariadb-server-5.5.44-2.el7.centos.x86_64
yum -y remove mariadb-devel-5.5.44-2.el7.centos.x86_64
yum -y remove qt-mysql-4.8.5-11.el7.x86_64
再次检查:
# rpm -qa | grep mariadb
# rpm -qa | grep mysql
创建mysql目录:
mkdir /usr/local/src/mysql
解压缩:
tar -xvf mysql-5.7.19-1.el7.x86_64.rpm-bundle.tar -C /usr/local/src/mysql
安装mysql的 server、client、common、libs、lib-compat:
#rpm -ivh mysql-community-common-5.7.19-1.el7.x86_64.rpm
#rpm -ivh mysql-community-libs-5.7.19-1.el7.x86_64.rpm
#rpm -ivh mysql-community-libs-compat-5.7.19-1.el7.x86_64.rpm
#rpm -ivh mysql-community-client-5.7.19-1.el7.x86_64.rpm
#rpm -ivh mysql-community-server-5.7.19-1.el7.x86_64.rpm
查看mysql的服务是否启动
#systemctl status mysqld
Active: inactive (dead)
启动mysql的服务
#systemctl start mysqld
Failed to start mysqld.service: Unit not found 解决方法如下:
首先需要安装mariadb-server
yum install -y mariadb-server
启动服务
systemctl start mariadb.service
添加到开机启动
systemctl enable mariadb.service
再次检查mysql的服务是否启动
#systemctl status mysqld
Active: active (running) since 三 2019-11-13 10:15:26 CST; 32s ago