MySQL练习

news2025/3/4 3:15:37

将安装包下载并上传

方法一

步骤

创建组与用户

[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd -r -g mysql -s /bin/false mysql

解压安装包

[root@localhost ~]# tar xf  mysql-8.0.36-linux-glibc2.28-x86_64.tar.xz -C /usr/local/

软连接

[root@localhost ~]# ln -sv mysql-8.0.36-linux-glibc2.28-x86_64 /usr/local/mysql
'/usr/local/mysql' -> 'mysql-8.0.36-linux-glibc2.28-x86_64'

初始化

[root@localhost ~]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data
2025-02-04T08:37:33.610736Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.36) initializing of server in progress as process 2086
2025-02-04T08:37:33.625049Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2025-02-04T08:37:34.296122Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2025-02-04T08:37:35.362477Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: wYiSf83tCu*2

配置文件

[root@localhost ~]# mkdir /var/log/mysql

[root@openEuler-1 ~]# vim /etc/my.cnf
 
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/
socket=/tmp/mysql.sock
log-error=/usr/local/mysql/data/mysqld.log
pid-file=/usr/local/mysql/data/mysqld.pid

增加权限

[root@localhost ~]# chown -R mysql.mysql /usr/local/mysql/*

添加系统服务

[root@localhost ~]# cd /usr/local/mysql/
[root@localhost mysql]# ls
bin  data  docs  include  lib  LICENSE  man  README  share  support-files
[root@localhost mysql]# cd support-files/
[root@localhost support-files]# ls
mysqld_multi.server  mysql-log-rotate  mysql.server
[root@localhost support-files]# vim mysql.server
[root@localhost support-files]# cp mysql.server /etc/init.d/mysqld
[root@localhost support-files]# ll /etc/rc.d/rc3.d/
total 0
[root@localhost support-files]# chkconfig --add mysqld
[root@localhost support-files]# ll /etc/rc.d/rc3.d/
total 0
lrwxrwxrwx 1 root root 16 Feb  4 16:57 S64mysqld -> ../init.d/mysqld
[root@localhost support-files]# chkconfig mysqld on
[root@localhost support-files]# chkconfig --list mysqld
 
Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.
 
      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.
 
mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off

启动服务

[root@localhost support-files]# systemctl start mysqld

登录MySQL

[root@localhost support-files]# /usr/local/mysql/bin/mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.36
 
Copyright (c) 2000, 2024, 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>

修改密码

mysql> alter user root@localhost identified by '123456';
Query OK, 0 rows affected (0.00 sec)

配置环境变量

[root@localhost support-files] vim /etc/profile.d/mysql.sh
 
export PATH=$PATH:/usr/local/mysql/bin
 
[root@localhost support-files] source /etc/profile.d/mysql.sh



[root@localhost support-files]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.36 MySQL Community Server - GPL
 
Copyright (c) 2000, 2024, 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>

删除系统服务

[root@localhost support-files]# chkconfig mysqld off
[root@localhost support-files]# chkconfig --list mysqld
 
Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.
 
      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.
 
mysqld          0:off   1:off   2:off   3:off   4:off   5:off   6:off

删除文件


[root@localhost support-files]# chkconfig --del mysqld
[root@localhost support-files]# ll /etc/init.d/
total 36
-rw-r--r--. 1 root root 18229 Aug 24  2022 functions
-rwxr-xr-x  1 root root 10576 Feb  4 16:55 mysqld
-rw-r--r--. 1 root root  1161 Jun 22  2024 README
[root@localhost support-files]# rm -f /etc/init.d/mysqld

方法二

配置文件

[root@localhost support-files]# vim /usr/lib/systemd/system/mysqld.service


Description=MySQL 8.0 database server
After=syslog.target
After=network.target
 
[Service]
Type=notify
User=mysql
Group=mysql
 
ExecStart=/usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
ExecStop=/usr/local/mysql/bin/mysqladmin -uroot shutdown
 
 
 
TimeoutSec=300
PrivateTmp=true
 
Restart=on-failure
 
RestartPreventExitStatus=1
LimitNOFILE = 10000
 
[Install]
WantedBy=muli-user.target

加载设置

[root@localhost support-files]# systemctl daemon-reload

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2309289.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【动手实验】TCP半连接队列、全连接队列实战分析

本文是对 从一次线上问题说起,详解 TCP 半连接队列、全连接队列 这篇文章的实验复现和总结,借此加深对 TCP 半连接队列、全连接队列的理解。 实验环境 两台腾讯云服务器 node2(172.19.0.12) 和 node3(172.19.0.15&am…

【六祎 - Note】SQL备忘录;DDL,DML,DQL,DCL

SQL备忘录 from to : 点击访问源地址

智能AI替代专家系统(ES)、决策支持系统(DSS)?

文章目录 前言一、专家系统(ES)是什么?二、决策支持系统(DSS)是什么?1.决策支持系统定义2.决策系统的功能与特点3.决策支持系统的组成 三、专家系统(ES)与决策支持系统(D…

比较Spring AOP和AspectJ

1. 介绍 当前有多个可用的AOP库,这些库必须能够回答许多问题: 它与我现有的或新的应用程序兼容吗?在哪里可以实施AOP?它与我的应用程序集成的速度有多快?性能开销是多少? 在本文中,我们将着眼…

现今大语言模型性能(准确率)比较

现今大语言模型性能(准确率)比较 表头信息:表的标题为“大语言模型性能比较结果”(英文:Table 1: Large Language Model Performance Comparison Results),表明该表是用于对比不同大语言模型的性能。列信息: 模型:列出参与比较的不同大语言模型名称,包括LLAMA3(70B)…

(十 五)趣学设计模式 之 命令模式!

目录 一、 啥是命令模式?二、 为什么要用命令模式?三、 策略模式的实现方式四、 命令模式的优缺点五、 命令模式的应用场景六、 总结 🌟我的其他文章也讲解的比较有趣😁,如果喜欢博主的讲解方式,可以多多支…

React低代码项目:问卷编辑器 I

问卷编辑器 Date: February 20, 2025 4:17 PM (GMT8) 目标 完成问卷编辑器的设计和开发完成复杂系统的 UI 组件拆分完成复杂系统的数据结构设计 内容 需求分析技术方案设计开发 注意事项: 需求指导设计,设计指导开发。前两步很重要页面复杂的话&…

信刻光盘安全隔离与信息交换系统让“数据摆渡”安全高效

随着数据传输、存储及信息技术的飞速发展,信息安全保护已成为重中之重。各安全领域对跨网数据交互的需求日益迫切,数据传输的安全可靠性成为不可忽视的关键。为满足业务需求并遵守保密规范,针对于涉及重要秘密信息,需做到安全的物…

【项目管理】基于 C 语言的 QQ 聊天室实现(TCP + 多线程 + SQLite3)

基于 C 语言的 QQ 聊天室(TCP + 多线程 + SQLite3) 项目功能基础功能: 登录、注册、添加好友、私聊、创建群聊、群聊扩展功能: 删除好友、注销账号、好友在线状态、群管理(拉人/踢人)、VIP 特权、邮件通知等 功能介绍:模拟QQ聊天客户端:登录界面:1、登录2、注册 //将用…

力扣27.移除元素(双指针)

题目看起来很乱&#xff0c;实际上意思是&#xff1a;把数组中值不等于val的元素放在下标为0,1,2,3......&#xff0c;并且返回数组中值不等于val的元素的个数 方法一&#xff1a;直接判断覆盖 class Solution { public:int removeElement(vector<int>& nums, int…

VADv2: 基于矢量表征和概率规划的E2E架构

1. 写在前面 今天分享一篇自动驾驶领域的论文VADv2(End-to-End Vectorized Autonomous Driving via Probabilistic Planning), 基于矢量表征和概率规划的E2E架构,2024年2月份华中科技大和地平线合作的一篇文章, 在经典的端到端模型架构上作出了基于概率规划去输出规划轨迹的…

机器学习:强化学习的epsilon贪心算法

强化学习&#xff08;Reinforcement Learning, RL&#xff09;是一种机器学习方法&#xff0c;旨在通过与环境交互&#xff0c;使智能体&#xff08;Agent&#xff09;学习如何采取最优行动&#xff0c;以最大化某种累积奖励。它与监督学习和无监督学习不同&#xff0c;强调试错…

计算机毕业设计SpringBoot+Vue.js基于JAVA语言的在线考试与学习交流网页平台(源码+文档+PPT+讲解)

温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 作者简介&#xff1a;Java领…

数据图表ScottPlot.WPF用法示例

目录 一、添加 NuGet 程序包&#xff08;5.0.47&#xff09; 二、MainWindow.xaml中添加引用 三、MainWindow.xaml.cs 具体使用代码 图表示例&#xff1a; 一、添加 NuGet 程序包&#xff08;5.0.47&#xff09; 二、MainWindow.xaml中添加引用 <Window x:Class"…

【第二十五周】:DeepPose:通过深度神经网络实现人体姿态估计

DeepPose 摘要Abstract文章信息引言DeepPose归一化网络结构初始网络&#xff08;粗略估计所有关节点位置&#xff09;精细化级联网络&#xff08;分别修正每个关节点的位置&#xff09; 疑问与解决代码实践总结 摘要 这篇博客介绍了DeepPose&#xff0c;这是首个基于深度神经网…

ARM Linux LCD上实时预览摄像头画面

文章目录 1、前言2、环境介绍3、步骤4、应用程序编写4.1、lcd初始化4.2、摄像头初始化4.3、jpeg解码4.4、开启摄像头4.5、完整的程序如下 5、测试5.1、编译应用程序5.2、运行应用程序 6、总结 1、前言 本次应用程序主要针对支持MJPEG格式输出的UVC摄像头。 2、环境介绍 rk35…

MacOS本地部署Deepseek,不联网也可以使用AI,保护隐私

苹果笔记本本地部署deepseek主要用到Ollama与open-webui 1. 安装Ollama “Ollama” 是一个轻量级的 AI 模型运行时环境&#xff08;runtime&#xff09;&#xff0c;旨在简化在本地部署和使用大语言模型&#xff08;LLM&#xff09;的过程。它由 Vicarious 公司开发&#xff…

Sqlserver安全篇之_启用TLS即配置SQL Server 数据库引擎以加密连接

官方文档 https://learn.microsoft.com/zh-cn/sql/database-engine/configure-windows/configure-sql-server-encryption?viewsql-server-ver16 https://learn.microsoft.com/zh-cn/sql/database-engine/configure-windows/manage-certificates?viewsql-server-ver15&pre…

创建一个MCP服务器,并在Cline中使用,增强自定义功能。

MCP介绍 MCP 是一个开放协议&#xff0c;它标准化了应用程序如何向LLMs提供上下文。可以将 MCP 视为 AI 应用程序的 USB-C 端口。正如 USB-C 提供了一种标准化的方法来将您的设备连接到各种外围设备和配件一样&#xff0c;MCP 提供了一种标准化的方法来将 AI 模型连接到不同的…

游戏引擎学习第131天

仓库:https://gitee.com/mrxiao_com/2d_game_3 运行游戏并识别我们的小问题 今天的工作重点是对游戏引擎进行架构优化&#xff0c;特别是针对渲染和多线程的部分。目前&#xff0c;我们的目标是让地面块在独立线程上进行渲染&#xff0c;以提高性能。在此过程中&#xff0c;我…