官网:https://dev.mysql.com/downloads/mysql/
rpm -qa | grep mysql
rpm -qa | grep mariadb
例如:安装过MySQL
使用如下命令卸载
rpm -e mysql-community-libs-8.1.0-1.el8.x86_64 --nodeps
解压
tar xvf mysql-8.1.0-1.el7.x86_64.rpm-bundle.tar
安装
rpm -ivh mysql-community-common-8.1.0-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.1.0-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.1.0-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.1.0-1.el7.x86_64.rpm
rpm -ivh mysql-community-icu-data-files-8.1.0-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.1.0-1.el7.x86_64.rpm --nodeps
显示需要依赖的,直接用–nodeps参数
启动
systemctl start mysqld
systemctl enable mysqld
获取密码
cat /var/log/mysqld.log | grep password
登录
mysql -u root -p
修改密码
alter user 'root'@'localhost' identified with mysql_native_password by 'Ljh@new2024';
刷新权限
flush privileges;
配置远程登录
use mysql;
select host, user from user;
update user set host = '%' where user = 'root';
select host, user from user;
flush privileges;