鲲鹏服务器、ARM架构Ubuntu18.04.3系统安装MySQL并修改数据目录

本文主要是介绍鲲鹏服务器、ARM架构Ubuntu18.04.3系统安装MySQL并修改数据目录,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

  • 第一次用Ubuntu安装MySQL 真是各种坑。。。。
  • Ubuntu系统安装MySQL 修改MySQL默认数据目录/var/lib/mysql
  1. 安装MySQL
apt-get update
apt-get install mysql-server -y
  1. 查看MySQL是否安装成功
#安装好以后默认是启动的
root@test-server02:/opt# systemctl status mysql
· mysql.service - MySQL Community ServerLoaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)Active: active (running) since Tue 2024-08-20 13:55:49 CST; 1min 34s agoMain PID: 10728 (mysqld)Tasks: 27 (limit: 4915)CGroup: /system.slice/mysql.service└─10728 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid
Aug 20 13:55:49 sdgs-server02 systemd[1]: Starting MySQL Community Server...
Aug 20 13:55:49 sdgs-server02 systemd[1]: Started MySQL Community Server.
#登录以后默认没有密码 这个就很坑 还以为和centos一样设置密码就行
root@test-server02:/opt# mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.42-0ubuntu0.18.04.1 (Ubuntu)
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
  1. 修改MySQL配置文件
vim /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address           = 127.0.0.1
#注释掉上面的配置、这个不注释根本连不上
max_connections=1000
#放开此参数,修改成1000 这个是研发需求
  1. 修改MySQL数据目录
#停掉MySQL
systemctl stop mysql
#移动MySQL默认数据目录:/var/lib/mysql
root@test-server02:~# cd /var/lib/
root@test-server02:/var/lib# mv mysql /opt/
#修改MySQL配置
vim /etc/mysql/mysql.conf.d/mysqld.cnf
datadir         = /opt/mysql
#修改上面配置
#授予权限
chown -R mysql.mysql /opt/mysql
修改apparmor配置
vim /etc/apparmor.d/usr.sbin.mysqld# Allow data dir access/opt/mysql/ r,/opt/mysql/** rwk,
#找到上面这两处进行修改#重启apparmor服务
systemctl restart apparmor
#启动MySQL
root@test-server02:/opt/mysql# systemctl restart mysql
root@test-server02:/opt/mysql# systemctl status mysql
· mysql.service - MySQL Community ServerLoaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)Active: active (running) since Tue 2024-08-20 15:07:41 CST; 8s agoProcess: 26099 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=0/SUCCESS)Process: 26080 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)Main PID: 26101 (mysqld)Tasks: 27 (limit: 4915)CGroup: /system.slice/mysql.service└─26101 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid
Aug 20 15:07:41 sdgs-server02 systemd[1]: Starting MySQL Community Server...
Aug 20 15:07:41 sdgs-server02 systemd[1]: Started MySQL Community Server.
root@sdgs-server02:/opt/mysql# mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.42-0ubuntu0.18.04.1 (Ubuntu)
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SHOW VARIABLES LIKE 'datadir';
+---------------+-------------+
| Variable_name | Value       |
+---------------+-------------+
| datadir       | /opt/mysql/ |
+---------------+-------------+
1 row in set (0.00 sec)
mysql>
  1. 修改MySQL密码&&赋予远程访问权限

这一块是最坑的,由于第一次安装不知道,修改密码的时候直接使用mysql命令即可、不要用mysql -uroot、这样改了以后不生效、更不要听网上的删掉root用户然后重新建更不行

root@test-server02:~# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.7.42-0ubuntu0.18.04.1 (Ubuntu)
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'sdgs123456';
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'sdgs123456';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@localhost IDENTIFIED BY 'sdgs123456';
#新开一个窗口测试

这篇关于鲲鹏服务器、ARM架构Ubuntu18.04.3系统安装MySQL并修改数据目录的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1094082

相关文章

Linux下MySQL数据库定时备份脚本与Crontab配置教学

《Linux下MySQL数据库定时备份脚本与Crontab配置教学》在生产环境中,数据库是核心资产之一,定期备份数据库可以有效防止意外数据丢失,本文将分享一份MySQL定时备份脚本,并讲解如何通过cr... 目录备份脚本详解脚本功能说明授权与可执行权限使用 Crontab 定时执行编辑 Crontab添加定

Vite 打包目录结构自定义配置小结

《Vite打包目录结构自定义配置小结》在Vite工程开发中,默认打包后的dist目录资源常集中在asset目录下,不利于资源管理,本文基于Rollup配置原理,本文就来介绍一下通过Vite配置自定义... 目录一、实现原理二、具体配置步骤1. 基础配置文件2. 配置说明(1)js 资源分离(2)非 JS 资

MyBatis-plus处理存储json数据过程

《MyBatis-plus处理存储json数据过程》文章介绍MyBatis-Plus3.4.21处理对象与集合的差异:对象可用内置Handler配合autoResultMap,集合需自定义处理器继承F... 目录1、如果是对象2、如果需要转换的是List集合总结对象和集合分两种情况处理,目前我用的MP的版本

MySQL中On duplicate key update的实现示例

《MySQL中Onduplicatekeyupdate的实现示例》ONDUPLICATEKEYUPDATE是一种MySQL的语法,它在插入新数据时,如果遇到唯一键冲突,则会执行更新操作,而不是抛... 目录1/ ON DUPLICATE KEY UPDATE的简介2/ ON DUPLICATE KEY UP

MySQL分库分表的实践示例

《MySQL分库分表的实践示例》MySQL分库分表适用于数据量大或并发压力高的场景,核心技术包括水平/垂直分片和分库,需应对分布式事务、跨库查询等挑战,通过中间件和解决方案实现,最佳实践为合理策略、备... 目录一、分库分表的触发条件1.1 数据量阈值1.2 并发压力二、分库分表的核心技术模块2.1 水平分

JWT + 拦截器实现无状态登录系统

《JWT+拦截器实现无状态登录系统》JWT(JSONWebToken)提供了一种无状态的解决方案:用户登录后,服务器返回一个Token,后续请求携带该Token即可完成身份验证,无需服务器存储会话... 目录✅ 引言 一、JWT 是什么? 二、技术选型 三、项目结构 四、核心代码实现4.1 添加依赖(pom

GSON框架下将百度天气JSON数据转JavaBean

《GSON框架下将百度天气JSON数据转JavaBean》这篇文章主要为大家详细介绍了如何在GSON框架下实现将百度天气JSON数据转JavaBean,文中的示例代码讲解详细,感兴趣的小伙伴可以了解下... 目录前言一、百度天气jsON1、请求参数2、返回参数3、属性映射二、GSON属性映射实战1、类对象映

RabbitMQ 延时队列插件安装与使用示例详解(基于 Delayed Message Plugin)

《RabbitMQ延时队列插件安装与使用示例详解(基于DelayedMessagePlugin)》本文详解RabbitMQ通过安装rabbitmq_delayed_message_exchan... 目录 一、什么是 RabbitMQ 延时队列? 二、安装前准备✅ RabbitMQ 环境要求 三、安装延时队

Python与MySQL实现数据库实时同步的详细步骤

《Python与MySQL实现数据库实时同步的详细步骤》在日常开发中,数据同步是一项常见的需求,本篇文章将使用Python和MySQL来实现数据库实时同步,我们将围绕数据变更捕获、数据处理和数据写入这... 目录前言摘要概述:数据同步方案1. 基本思路2. mysql Binlog 简介实现步骤与代码示例1

Web服务器-Nginx-高并发问题

《Web服务器-Nginx-高并发问题》Nginx通过事件驱动、I/O多路复用和异步非阻塞技术高效处理高并发,结合动静分离和限流策略,提升性能与稳定性... 目录前言一、架构1. 原生多进程架构2. 事件驱动模型3. IO多路复用4. 异步非阻塞 I/O5. Nginx高并发配置实战二、动静分离1. 职责2