当前位置: 首页 > article >正文

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

最近有项目需求,需要在鲲鹏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 distribution

Copyright (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: 1

MySQL [(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: 0

MySQL [(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 $basedir

    echo $echo_n "Starting MySQL"
    if test -x $bindir/mysqld_safe
    then
      # 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 / SuSE
      if test -w "$lockdir"
      then
        touch "$lock_file_path"
      fi

      exit $return_value
    else
      log_failure_msg "Couldn't find MySQL server ($bindir/mysqld_safe)"
    fi
    ;;

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


http://www.kler.cn/a/418329.html

相关文章:

  • 龙蜥 Linux 安装 JDK
  • smb cifs samba smbpasswd 笔记241127
  • 搭建业务的性能优化指南
  • 如何讲json数据转换为二维数据后导出为excel文件
  • SpringMVC-08-json
  • APM32使用I2C驱动OLED
  • 吉客云数据集成技巧:智能实现MySQL物料信息查询
  • 栈-数组描述(C++)
  • mysql查询语句执行全流程
  • 10x 性能提升,ProtonBase 为教育行业提供统一的数据库和数仓体验
  • 【C#设计模式(16)——解释器模式(Interpreter Pattern)】
  • 搭建业务的性能优化指南
  • [C/C++]排序算法1、冒泡排序
  • 汽车座舱系统名词
  • 【开源免费】基于Vue和SpringBoot的校园资料分享平台(附论文)
  • 七牛智能CDN视频优化方案,展现企业长期价值
  • android shader gl_Position是几个分量
  • 【竞技宝】CS2-上海major:MongoLZ成为亚洲之光
  • C# 中的事件:对象间通信的利器
  • macos下brew安装redis
  • 每日十题八股-2024年11月30日
  • 依托 SpringBoot 的新冠密接者跟踪系统:技术创新驱动疫情防控效能提升
  • wordpress仿社交软件SOUL 动态标签星球- 为你的博客注入灵魂
  • <项目代码>YOLOv8 红绿灯识别<目标检测>
  • Git push
  • 行列式与线性方程组解的关系