下载MYSQL安装包
上面的选择一个下载
或者用命令下载
bash
wget https://repo.huaweicloud.com/kunpeng/yum/el/7/aarch64/Packages/database/mysql-5.7.27-1.el7.aarch64.rpm
检查是否已经安装MySQL
bash
rpm -qa | grep mysql

将包卸载掉
bash
rpm -e --nodeps python2-mysqlclient-1.3.12-8.ky10.aarch64
rpm -e --nodeps qt5-qtbase-mysql-5.11.1-13.p01.ky10.aarch64
rpm -e --nodeps pcp-pmda-mysql-4.1.3-13.p04.ky10.aarch64

开始安装
bash
rpm -ivh mysql-5.7.27-1.el7.aarch64.rpm

找到my.cnf
bash
find / -name "my.cnf"

查看my.cnf
bash
cat /etc/my.cnf

修改my.cnf
修改后的my.cnf 如下:
bash
[mysqld]
# mysql 安装目录
basedir=/usr/local/mysql
# msyql 数据存放目录
datadir=/usr/local/mysql/data
# 设置端口
port = 3306
socket=/tmp/mysql.sock
symbolic-links=0
log-error=/var/log/mysqld.log
# pid-file=/tmp/mysqld/mysqld.pid
pid-file=/usr/local/mysql/mysqld.pid
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
[client]
default-character-set=utf8
[mysql]
# 默认字符集
default-character-set=utf8
[mysqld]
log-bin=mysql-bin
binlog-format=ROW
expire_logs_days = 3
server_id=1
# 最大连接数
max_connections=1000
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
进入mysql目录
bash
cd /usr/local/mysq

没有msyql 数据存放目录
datadir=/usr/local/mysql/data
创建data目录
bash
mkdir data

创建 mysqld.pid文件
bash
touch mysqld.pid

添加mysql用户组和mysql用户
bash
groupadd -r mysql && useradd -r -g mysql -s /sbin/nologin -M mysql

提示已经存在不需要创建
授权mysql文件
bash
chown -R mysql:mysql /usr/local/mysql/

添加环境变量
bash
vim /etc/profile
添加下面内容:
bash
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin

使环境变量生效
bash
source /etc/profile

查看mysql是否启动
bash
ps -ef | grep mysql

初始化mysql
bash
mysqld --initialize
启动mysql
bash
service mysql start

登录mysql
bash
mysql -u root -h 127.0.0.1 -p

设置密码
bash
use mysql;

bash
update user set authentication_string=password("123456") where user="root";

bash
flush privileges;

设置远程连接
bash
grant all privileges on *.* to root@'%' identified by "123456";

bash
flush privileges;

退出:quit

远程访问一下
