-
下载安装包
下载地址:https://downloads.mysql.com/archives/community/
-
解压后上传到服务器(或者直接上传到服务器用tar -zxvf xxx.tar命令解压)
-
卸载mariadb
卸载命令:yum remove mariadb-server mariadb
检查是否还有未删除的包:
rpm -qa | grep mariadb
卸载:yum remove mariadb-connector-c-3.0.6-9.ky10.aarch64
执行命令:yum clean all
如果你还想删除MariaDB的数据目录和配置文件,你可以手动删除它们:
rm -rf /var/lib/mysql/
rm -rf /etc/my.cnf
-
安装过程中异常处理
执行命令:rpm -ivh *.rpm
遇到报错:perl(JSON) 被 mysql-community-test-8.0.28-1.el8.aarch64 需要
解决报错:yum install perl-JSON
-
继续安装
安装完perl-JSON依赖包后,继续执行rpm -ivh *.rpm命令安装mysql;
-
启动服务
安装完成,开始启动服务:systemctl start mysqld;
-
登录修改密码
查看数据库密码: grep 'temporary password' /var/log/mysqld.log
登录数据库:mysql -hlocalhost -uroot -p"Cv#+X.eu,48i"
修改root用户密码:ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';
设置允许远程连接:
use mysql; # 进入 MySQL 库
update `user` set Host = '%' where User = 'root' and Host = 'localhost'; # 修改远程连接
flush privileges; # 刷新
-
重启服务
systemctl restart mysqld
-
添加用户
use mysql;
CREATE USER 'admin'@'%' IDENTIFIED BY '密码';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION;
flush privileges;