1. 先下载mysql
地址: mysql5.7-rpm.tar
2. 可以用Xshell中的Xftp把下载后的文件上传到centos上,然后解压:
tar -xvf mysql-5.7.22-1.el7.x86_64.rpm-bundle.tar -C /usr/local/mysql5.7
解压完成后
4. 安装依赖
yum -y install libaio-devel
yum -y install numactl-devel
yum -y install openssl-devel
3.然后安装
rpm -ivh mysql-community-common-5.7.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.22-1.el7.x86_64.rpm
##rpm -ivh mysql-community-libs-compat-5.7.22-1.el7.x86_64.rpm 不用安装
rpm -ivh mysql-community-client-5.7.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.22-1.el7.x86_64.rpm
##rpm -ivh mysql-community-server-minimal-5.7.22-1.el7.x86_64.rpm 不用安装
5. 初始化数据库
会在/var/log/中生成日志文件
sudo mysqld --initialize
查看密码
tail /var/log/mysqld.log
6. 修改mysql数据库目录所属用户及所属组,然后启动数据库
sudo chown mysql:mysql /var/lib/mysql -R
systemctl start mysqld.service
7.修改数据库密码
[root@localhost mysql5.7]# mysql_secure_installation
下面根据需求选择。
8.下面可以测试
安装完成。
可通过一下命令查找需要安装的依赖包:
yum search getopt
然后输出的包可能比较多,对比给出的依赖包的信息,选择相应的包安装
安装命令:yum -y install perl-Getopt-Long.noarch 0:2.40-3.el7
注意:这一步rpm -ivh mysql-community-server-5.7.19-1.el6.x86_64.rp可能遇到报错
多数情况是缺少安装依赖的包,可以通过#yum search 包名; 来查找相应的包,然后通过命令:#yum -y install 找到的包名;
安装mysql-community-server时报如下错误ERROR:
问题:缺少libnuma依赖包;
#查找libnuma的安装包: [root@VM_59_155_centos package]# yum -y search libnuma Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile ================================================= N/S matched: libnuma ================================================== numactl-libs.i686 : libnuma libraries numactl-libs.x86_64 : libnuma libraries Name and summary matches only, use "search all" for everything. #安装 [root@VM_59_155_centos package]# yum -y install numactl-libs.x86_64 #再重新安装:mysql-community-server rpm -ivh mysql-community-server-8.0.11-1.el7.x86_64.rpm