mkdir ~/mysql
cd ~/mysql
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar
tar -xvf mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar
#输出
#mysql-community-embedded-devel-5.7.26-1.el7.x86_64.rpm
#mysql-community-libs-5.7.26-1.el7.x86_64.rpm
#mysql-community-embedded-5.7.26-1.el7.x86_64.rpm
#mysql-community-test-5.7.26-1.el7.x86_64.rpm
#mysql-community-embedded-compat-5.7.26-1.el7.x86_64.rpm
#mysql-community-common-5.7.26-1.el7.x86_64.rpm 核心安装
#mysql-community-devel-5.7.26-1.el7.x86_64.rpm
#mysql-community-client-5.7.26-1.el7.x86_64.rpm 核心安装
#mysql-community-server-5.7.26-1.el7.x86_64.rpm 核心安装
#mysql-community-libs-compat-5.7.26-1.el7.x86_64.rpm 核心安装
安装mysql
rpm -ivh mysql-community-common-5.7.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.26-1.el7.x86_64.rpm
可能会有报错,如有报错,则进行依赖安装即可,eg:
rpm -ivh mysql-community-libs-compat-5.7.26-1.el7.x86_64.rpm
# 输出
# warning: mysql-community-libs-compat-5.7.26-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
# error: Failed dependencies:
# mysql-community-libs(x86-64) >= 5.7.9 is needed by mysql-community-libs-compat-5.7.26-1.el7.x86_64
则需要进行依赖安装mysql-community-libs-compat-5.7.26-1.el7.x86_64。
sudo systemctl start mysqld.service
sudo systemctl status mysqld.service
# 输出
* mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2020-07-28 10:16:22 CST; 26s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 32418 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 32392 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 32421 (mysqld)
Tasks: 27
Memory: 297.0M
CGroup: /system.slice/mysqld.service
`-32421 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
Jul 28 10:16:16 VM_55_42_centos systemd[1]: Starting MySQL Server...
Jul 28 10:16:22 VM_55_42_centos systemd[1]: Started MySQL Server.
sudo systemctl stop mysqld.service
sudo systemctl restart mysqld.service
# 查看临时密码
sudo grep 'temporary password' /var/log/mysqld.log
# 链接mysql
mysql -uroot -p
mysql>alter user 'root'@'localhost' identified by 'youpassword';
mysql> flush privileges;
完成之后,exit推出mysql,使用root和密码,进行登录mysql即可。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。