rpm方式安装mysql

检查环境

  • 查看系统是否有自带的mysql
#检查已安装的mariadb
>rpm -qa | grep mariadb
  mariadb-connector-c-3.0.6-6.ky10.aarch64
  mariadb-common-10.3.9-8.ky10.aarch64
  mariadb-10.3.9-8.ky10.aarch64
#如果上面命令有结果,要逐个删除对应的rpm,否则下面安装可能会不能成功
>rpm -e --nodeps mariadb-10.3.9-8.ky10.aarch64
>rpm -e --nodeps mariadb-common-10.3.9-8.ky10.aarch64
>rpm -e --nodeps mariadb-connector-c-3.0.6-6.ky10.aarch64
  • 检查当前操作系统

系统环境uname -a ,/etc/下的release文件等确认当前系统环境。下载对应的rpm安装包。这里是麒麟系统ARM架构的系统,下面下载的是aarch64版本的rpm包

rpm下载网易的镜像地址http://mirrors.163.com/mysql/Downloads/

安装

rpm -ivh mysql-community-common-8.0.28-1.el7.aarch64.rpm
rpm -ivh mysql-community-client-plugins-8.0.28-1.el7.aarch64.rpm
#!!!先安装compat-openss
rpm -ivh mysql-community-libs-8.0.28-1.el7.aarch64.rpm
rpm -ivh mysql-community-client-8.0.28-1.el7.aarch64.rpm
rpm -ivh mysql-community-icu-data-files-8.0.28-1.el7.aarch64.rpm
rpm -ivh mysql-community-server-8.0.28-1.el7.aarch64.rpm

安装mysql-community-libs时可能会出现缺少依赖

# rpm -ivh mysql-community-libs-8.0.28-1.el7.aarch64.rpm
error: Failed dependencies:
	libcrypto.so.10()(64bit) is needed by mysql-community-libs-8.0.28-1.el7.aarch64
	libcrypto.so.10(libcrypto.so.10)(64bit) is needed by mysql-community-libs-8.0.28-1.el7.aarch64
	libssl.so.10()(64bit) is needed by mysql-community-libs-8.0.28-1.el7.aarch64
	libssl.so.10(libssl.so.10)(64bit) is needed by mysql-community-libs-8.0.28-1.el7.aarch64

需要安装

npm -i compat-openssl10-1.0.2o-3.el8.aarch64.rpm

下载地址:https://centos.pkgs.org/8-stream/centos-appstream-aarch64/compat-openssl10-1.0.2o-3.el8.aarch64.rpm.html

配置mysql

  • 默认服务端配置

配置文件位置:/etc/my.cnf可以修改

[mysqld]
#数据文件位置
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

  • 初始化mysql:
>mysqld --initialize --user=mysql --console

具体可配置参数见官方文档:https://dev.mysql.com/doc/refman/8.0/en/server-options.html

查看初始密码,在/var/log/mysqld.log文件中

  • 启动服务:
#启动
service mysqld start
#查看运行状态
systemctl status mysqld.service
#若有防火墙需要配端口
  • 配置用户远程连接
#root登录
mysql -uroot -p 登录mysql
#切换数据库
use mysql;
#修改root密码
alter user 'root'@'localhost' identified by '新密码';
#开启远程登录
grant all privileges on *.* to 'root'@'%' identified by '密码';
flush privileges;

下面就可以用工具本地连接数据库测试了。

posted @ 2023-04-17 09:05  朋羽  阅读(1122)  评论(0编辑  收藏  举报