鲲鹏麒麟安装离线版MySQL5.7

server/2024/12/2 20:11:24/

最近有项目需求,需要在鲲鹏ARM服务器上安装数据库MySQL5.7,服务器为鲲鹏920,操作系统Kylin Linux Advanced Server release V10 (Tercel)

安装包

下载地址:https://cloud.189.cn/t/JRVnmeEvMRZ3(访问码:tf69)
下载后文件为mysql-5.7.27-aarch64.zip

部署

1、拷贝文件到/usr/local目录下

2、解压文件,执行:
unzip ./mysql-5.7.27-aarch64.zip -d ./

3、将得到的文件夹重命名为mysql,执行
mv ./mysql-5.7.27-aarch64 ./mysql

4、创建数据目录和日志目录
mkdir /usr/local/mysql/logs
mkdir /usr/local/mysql/data

5、创建mysql用户并授权
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
chown -R mysql:mysql mysql
chmod 777 ./mysql/bin/*

6、安装mysql服务
cd /usr/local/mysql
cp support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
修改配置vi /etc/init.d/mysql,找到basedir和datadir,并修改为如下配置

7、初始化数据库,执行
./bin/mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data

8、将MySQL服务添加到系统服务
chkconfig --add mysql
chkconfig mysql on

9、修改my.cnf配置,将mysql目录下的my.cnf拷贝到/etc/my.cnf目录下,my.cnf内容如下:

[client]
port = 3306
socket = /dev/shm/mysql.sock[mysqld]
skip-grant-tables
port = 3306
socket = /dev/shm/mysql.sock
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
pid-file = /usr/local/mysql/data/mysql.pid
user = mysql
bind-address = 0.0.0.0
server-id = 101
init-connect = 'SET NAMES utf8mb4'
character-set-server = utf8mb4
#skip-name-resolve
#skip-networking
back_log = 300
max_connections = 1000
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 4M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 4M
thread_cache_size = 8
query_cache_type = 1
query_cache_size = 8M
query_cache_limit = 2M
ft_min_word_len = 4
log_bin = mysql-bin
binlog_format = mixed
expire_logs_days = 30
log_error = /usr/local/mysql/logs/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /usr/local/mysql/logs/mysql-slow.log
performance_schema = 0
explicit_defaults_for_timestamp
#lower_case_table_names = 1
skip-external-locking
default_storage_engine = InnoDB
#default-storage-engine = MyISAM
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 64M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
interactive_timeout = 28800
wait_timeout = 28800[mysqldump]
quick
max_allowed_packet = 16M[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M

注意检查几个路径相关的以及相关的端口,不要出错。在这里重点说一下初始密码,执行./bin/mysqld --initialize会在日志文件中生产root密码

[root@test mysql]# cat ./logs/mysql-error.log 
2024-12-01T01:19:58.734422Z 0 [Warning] InnoDB: New log files created, LSN=45790
2024-12-01T01:19:58.764046Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2024-12-01T01:19:58.822054Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 6180e241-af82-11ef-b67b-fa163e637a8c.
2024-12-01T01:19:58.823376Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2024-12-01T01:19:58.825016Z 1 [Note] A temporary password is generated for root@localhost: <:tf4rZT8gaJ
[root@test mysql]# 

root@localhost冒号后的就是密码,一般生成的密码比较复杂,不便于记忆,因此为方便修改密码,在配置文件中配置初始登录无需密码,然后再修改默认密码,注意
[mysqld]
skip-grant-tables

10、启动mysql,执行service mysql start

[root@test mysql]# service mysql start
Starting MySQL.. SUCCESS! 
[root@test mysql]# netstat -lnp | grep 3306
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      2444566/mysqld  

至此MySQL已经成功启动

11、修改默认密码,执行mysql -uroot进入

[root@test mysql]# mysql -uroot
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.27-log Source distributionCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MySQL [(none)]> update mysql.user set authentication_string=password('root') where user='root' and Host = 'localhost';
Query OK, 1 row affected, 1 warning (0.002 sec)
Rows matched: 1  Changed: 1  Warnings: 1MySQL [(none)]> SELECT user, host, password_expired FROM mysql.user WHERE user = 'root';
+------+-----------+------------------+
| user | host      | password_expired |
+------+-----------+------------------+
| root | localhost | Y                |
+------+-----------+------------------+
1 row in set (0.000 sec)MySQL [(none)]> update mysql.user set password_expired='N' WHERE user = 'root';
Query OK, 1 row affected (0.002 sec)
Rows matched: 1  Changed: 1  Warnings: 0MySQL [(none)]> flush privileges;
Query OK, 0 rows affected (0.002 sec)MySQL [(none)]> exit
Bye
[root@test mysql]# service mysql stop
Shutting down MySQL.. SUCCESS! 
[root@test mysql]# 
[root@test mysql]# service mysql start
Starting MySQL.. SUCCESS!

在这里将root密码修改为root,实际使用过程中,可以使用更安全的密码,注意重启之前将my.cnf中的配置skip-grant-tables注释掉,只需前面加一个#即可。

此时如果再次使用mysql -uroot,就会出现如下错误:

[root@test mysql]# mysql -uroot
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

至此数据库已经安装好了。

其他配置

1、授权远程访问权限
CREATE USER ‘root’@‘%’ IDENTIFIED BY ‘root’;
GRANT ALL ON . TO ‘root’@‘%’;
ALTER USER ‘root’@‘%’ IDENTIFIED WITH mysql_native_password BY ‘root’;
更新权限
FLUSH PRIVILEGES;

2、开放端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent && firewall-cmd --reload

3、如果要配置主从,注意一定要修改/etc/init.d/mysql文件,启动时加上server-id,尝试过在my.cnf中增加server-id,但是无效。

case "$mode" in'start')# Start daemon# Safeguard (relative paths, core dumps..)cd $basedirecho $echo_n "Starting MySQL"if test -x $bindir/mysqld_safethen# Give extra arguments to mysqld with the my.cnf file. This script# may be overwritten at next upgrade.$bindir/mysqld_safe --server-id=101 --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null &wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$?# Make lock for RedHat / SuSEif test -w "$lockdir"thentouch "$lock_file_path"fiexit $return_valueelselog_failure_msg "Couldn't find MySQL server ($bindir/mysqld_safe)"fi;;

注意:$bindir/mysqld_safe --server-id=101


http://www.ppmy.cn/server/146823.html

相关文章

抽卡代码(简陋) C#

简单写了一个抽卡代码&#xff0c;没有修饰&#xff0c;用起来其实还挺难受的。抽10连的时候按0可以跳过抽取过程。 using System; using System.Collections.Generic; using System.Threading;class Program {static void Main(){//随机数初始化Random random new Random();…

【Linux】-操作系统

&#x1f511;&#x1f511;博客主页&#xff1a;阿客不是客 &#x1f353;&#x1f353;系列专栏&#xff1a;深入代码世界&#xff0c;了解掌握 Linux 欢迎来到泊舟小课堂 &#x1f618;博客制作不易欢迎各位&#x1f44d;点赞⭐收藏➕关注 ​​ 一、冯•诺依曼架构&#xff…

Maven、JAVAWeb、Servlet

知识点目标 1、MavenMaven是什么Maven项目的目录结构Maven的Pom文件Maven的命令Maven依赖管理Maven仓库JavaWeb项目 2.网络基础知识 3、ServletMaven Maven是什么 Maven是Java的项目管理工具&#xff0c;可以构建&#xff0c;打包&#xff0c;部署项目&#xff0c;还可以管理…

【逐行注释】自适应观测协方差R的AUKF(自适应无迹卡尔曼滤波,MATLAB语言编写),附下载链接

文章目录 自适应R的UKF逐行注释的说明运行结果部分代码各模块解释 自适应R的UKF 自适应无迹卡尔曼滤波&#xff08;Adaptive Unscented Kalman Filter&#xff0c;AUKF&#xff09;是一种用于状态估计的滤波算法。它是基于无迹卡尔曼滤波&#xff08;Unscented Kalman Filter&…

【机器学习】梯度消失和梯度爆炸问题

梯度消失&#xff08;Vanishing Gradient&#xff09;和梯度爆炸&#xff08;Exploding Gradient&#xff09;是深度学习训练过程中常见的两种问题&#xff0c;尤其是在使用深层神经网络&#xff08;如深度卷积神经网络或循环神经网络&#xff09;时。这两种问题都会对网络的训…

Java基础常用类库全解析

一、引言 Java 基础常用类库是 Java 编程的重要基石&#xff0c;本文将深入解析这些类库&#xff0c;帮助读者更好地理解和运用 Java 语言。 在 Java 编程中&#xff0c;基础常用类库为开发者提供了丰富的工具和功能&#xff0c;极大地提高了开发效率。这些类库涵盖了多个方面&…

【MySQL — 数据库基础】MySQL的安装与配置 & 数据库简单介绍

数据库基础 本节目标 掌握关系型数据库&#xff0c;数据库的作用掌握在Windows和Linux系统下安装MySQL数据库了解客户端工具的基本使用和SQL分类了解MySQL架构和存储引擎 1. 数据库的安装与配置 1.1 确认MYSQL版本 处理无法在 cmd 中使用 mysql 命令的情况&a…

实时数据开发|Flink实现数据输出--DataSinks操作

哇哦&#xff0c;又是快乐周五&#xff01;今天主管又又又请我们喝奶茶了&#xff0c;是乐乐茶的草莓新品。甜甜的草莓配上糯叽叽的麻薯&#xff0c;喝完好满足。这应该不是什么加班信号吧哈哈哈&#xff0c;不加不加周五要回家。 前几天被不同的bug缠身&#xff0c;今天终于正…