下载MYSQL安装包
华为开源镜像站_软件开发服务_华为云
上面的选择一个下载
或者用命令下载
wget https://repo.huaweicloud.com/kunpeng/yum/el/7/aarch64/Packages/database/mysql-5.7.27-1.el7.aarch64.rpm
检查是否已经安装MySQL
rpm -qa | grep mysql
将包卸载掉
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
开始安装
rpm -ivh mysql-5.7.27-1.el7.aarch64.rpm
找到my.cnf
find / -name "my.cnf"
查看my.cnf
cat /etc/my.cnf
修改my.cnf
修改后的my.cnf 如下:
[mysqld]
# mysql 安装目录
basedir=/usr/local/mysql
# msyql 数据存放目录
datadir=/usr/local/mysql/data
# 设置端口
port = 3306
socket=/tmp/mysql.socksymbolic-links=0
log-error=/var/log/mysqld.log
# pid-file=/tmp/mysqld/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=1000init_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目录
cd /usr/local/mysq
没有msyql 数据存放目录
datadir=/usr/local/mysql/data
创建data目录
mkdir data
添加mysql用户组和mysql用户
groupadd -r mysql && useradd -r -g mysql -s /sbin/nologin -M mysql
提示已经存在不需要创建
授权mysql文件
chown -R mysql /usr/local/mysql/
添加环境变量
vim /etc/profile
添加下面内容:
export MYSQL_HOME=/usr/local/mysqlexport PATH=$PATH:$MYSQL_HOME/bin
使环境变量生效
source /etc/profile
查看mysql是否启动
ps -ef | grep mysql
启动mysql
service mysql start
报错了解决问题吧
Starting MySQL... ERROR! The server quit without updating PID file (/usr/local/mysql/data/KylinV10SP3.pid).
缺失了pid-file配置
在vim /etc/my.cnf增加相关配置
pid-file=/usr/local/mysql/mysqld.pid
创建 mysqld.pid文件
touch mysqld.pid