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

MySQL学习笔记3

MySQL的源码编译安装:

1、参考MySQL的源码安装官方文档:

2、源码安装定制选项:

3、源码安装三部曲:配置、编译、安装。

4、软件安装包:

mysql-boost-5.7.43.tar.gz

5、安装需求:

安装需求具体配置
安装目录basedir/mysql_3307
数据目录datadir/mysql_3307/data
端口号3307
socket文件位置$basedir/mysql.sock
字符集utf8mb4

主要安装目录、端口和socket套接字不一样,就可以在一台服务器上安装两个mysql。

6、了解配置选项:

源码安装,可定制性比较强。 

其中collation:

 核对、校验的意思。

ENABLED_LOCAL_INFILE:外部数据,导入的时候,需要开启该功能。

 

安装步骤:

1)安装依赖包:

[root@mysql-server ~]# yum -y install ncurses-devel cmake libaio-devel openssl-devel

 2)上传mysql源码包,并解压:

这个时候做一个拍照。

[root@mysql-server ~]# tar -zxvf mysql-boost-5.7.43.tar.gz

3)进入到解压目录里配置:

[root@mysql-server ~]# cd mysql-5.7.43

4)编写脚本进行配置 vim myconfig.sh:

cmake . \
-DCMAKE_INSTALL_PREFIX=/mysql_3307 \
-DMYSQL_DATADIR=/mysql_3307/data \
-DMYSQL_TCP_PORT=3307 \
-DMYSQL_UNIX_ADDR=/mysql_3307/mysql.sock \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DWITH_SSL=system \
-DWITH_BOOST=/mysql_3307/boost \
-DDOWNLOAD_BOOST=1

说明:在这个配置里,如果还需要安装别的数据库,只要修改几个地方:

 -DCMAKE_INSTALL_PREFIX

-DMYSQL_DATADIR

-DMYSQL_TCP_PORT

-DMYSQL_UNIX_ADDR

5)添加脚本执行权限,然后执行脚本。

[root@mysql-server mysql-5.7.43]# chmod +x mysqlconfig.sh
[root@mysql-server mysql-5.7.43]# ./mysqlconfig.sh

这个过程是一个配置的过程。 

6)编译和安装:

make && make install

 也可以写成:

make -j2 && make install

选项:

-j2:代表同时开启多个线程共同实现编译操作。

MySQL数据库的初始化工作:

1)进入到/mysql_3307

[root@mysql-server mysql-5.7.43]# cd /mysql_3307
[root@mysql-server mysql_3307]# pwd
/mysql_3307

2)创建mysql-files目录:

[root@mysql-server mysql_3307]# mkdir mysql-files
[root@mysql-server mysql_3307]# chown mysql:mysql mysql-files
[root@mysql-server mysql_3307]# chmod 750 mysql-files

3)初始化数据库:

[root@mysql-server mysql_3307]# bin/mysqld --initialize --user=mysql --basedir=/mysql_3307 --datadir=/mysql_3307/data
2023-09-22T16:03:38.325762Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2023-09-22T16:03:38.507868Z 0 [Warning] InnoDB: New log files created, LSN=45790
2023-09-22T16:03:38.532672Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2023-09-22T16:03:38.586904Z 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: 97a3f645-5961-11ee-8c2b-000c295cf01e.
2023-09-22T16:03:38.587416Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2023-09-22T16:03:38.703329Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2023-09-22T16:03:38.703383Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2023-09-22T16:03:38.703732Z 0 [Warning] CA certificate ca.pem is self signed.
2023-09-22T16:03:38.736069Z 1 [Note] A temporary password is generated for root@localhost: _uhi%b?us9Qr

里面创建了data目录,data目录里面有mysql目录。

4)启动数据库:

[root@mysql-server mysql_3307]# cp support-files/mysql.server /etc/init.d/mysql_3307
[root@mysql-server mysql_3307]# service mysql_3307 start

常见启动异常的解决方案:

 查看日志:

解决办法:很多问题跟权限有关,要理解权限、拥有者、所属组。

[root@mysql-server /]# chown -R mysql:mysql mysql_3307

也可以使用chmod命令更改权限,如果该了权限,可能不符合权限最小化的原则

安装完后续配置:

[root@mysql-server mysql_3307]# cat my.cnf
[mysqld]
basedir=/mysql_3307
datadir=/mysql_3307/data
socket=/mysql_3307/mysql.sock[root@mysql-server mysql_3307]# service mysql_3307 restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!

别忘了要将mysql_3307重启。

设置数据库管理root的密码:

bin/mysqladmin -uroot password '1q2w3e4r' -p

安全设置:

[root@mysql-server mysql_3307]# bin/mysql_secure_installationSecuring the MySQL server deployment.Enter password for user root:VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?Press y|Y for Yes, any other key for No: n
Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y- Dropping test database...
Success.- Removing privileges on test database...
Success.Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.All done!

添加mysql_3307的开机启动项:

[root@mysql-server ~]# chkconfig --add mysql_3307
[root@mysql-server ~]# chkconfig mysql_3307 on
[root@mysql-server ~]#
[root@mysql-server ~]# chkconfig --listNote: This output shows SysV services only and does not include nativesystemd services. SysV configuration data might be overridden by nativesystemd 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]'.mysql_3306      0:off   1:off   2:on    3:on    4:on    5:on    6:off
mysql_3307      0:off   1:off   2:on    3:on    4:on    5:on    6:off
netconsole      0:off   1:off   2:off   3:off   4:off   5:off   6:off
network         0:off   1:off   2:on    3:on    4:on    5:on    6:off

mysql常见问题解决方案:

1、如何访问不同的数据库?

方法一:直接使用==对应的客户==端软件访问:

访问5.7.31版本数据库:
[root@node1 ~]# /mysql_3306/bin/mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.31 MySQL Community Server (GPL)访问5.7.31版本数据库:
[root@node1 ~]# /mysql_3307/bin/mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.31 Source distribution

方法二:==定义别名==的方式访问

[root@node1 ~]# alias mysql_3306="/mysql_3306/bin/mysql"
[root@node1 ~]# alias mysql_3307="/mysql_3307/bin/mysql"
[root@node1 ~]# mysql_3306 -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.31 MySQL Community Server (GPL)[root@node1 ~]# mysql_3307 -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.7.31 Source distribution

方法三:==拷贝相应命令==到PATH可以识别的路径下==并重命名==

[root@node1 ~]# unalias mysql_3306
[root@node1 ~]# unalias mysql_3307
+++++++++++++++++++++我是华丽分隔符+++++++++++++++++++++++++++
[root@node1 ~]# cp /mysql_3306/bin/mysql /usr/bin/mysql_3306
[root@node1 ~]# cp /mysql_3307/bin/mysql /usr/bin/mysql_3307
[root@node1 ~]# which mysql_3306
/usr/bin/mysql_3306
[root@node1 ~]# which mysql_3307
/usr/bin/mysql_3307

我个人感觉还是倾向于第三种方法。

思考:我们之所以能够连接到数据库服务器的本质,就是套接字。

MySQL密码忘记了如何解决:

这个需要按照老师的步骤进行下联系。

[root@mysql-server ~]# ps aux |grep mysql
root        934  0.0  0.0 115544  1708 ?        S    13:08   0:00 /bin/sh /mysql_3307/bin/mysqld_safe --datadir=/mysql_3307/data --pid-file=/mysql_3307/data/mysql-server.lnmp.com.pid
mysql      1213  0.1  9.0 1144064 183968 ?      Sl   13:08   0:00 /mysql_3307/bin/mysqld --basedir=/mysql_3307 --datadir=/mysql_3307/data --plugin-dir=/mysql_3307/lib/plugin --user=mysql --log-error=mysql-server.lnmp.com.err --pid-file=/mysql_3307/data/mysql-server.lnmp.com.pid --socket=/mysql_3307/mysql.sock
root       1621  0.0  0.0  11824  1592 pts/0    S    13:13   0:00 /bin/sh /mysql_3306/bin/mysqld_safe --datadir=/mysql_3306/data --pid-file=/mysql_3306/data/mysql-server.lnmp.com.pid
mysql      1750  0.2  8.9 1121060 180816 pts/0  Sl   13:13   0:00 /mysql_3306/bin/mysqld --basedir=/mysql_3306 --datadir=/mysql_3306/data --plugin-dir=/mysql_3306/lib/plugin --user=mysql --log-error=mysql-server.lnmp.com.err --pid-file=/mysql_3306/data/mysql-server.lnmp.com.pid --socket=/tmp/mysql.sock
root       1887  0.0  0.0 112812   972 pts/0    S+   13:14   0:00 grep --color=auto mysql
[root@mysql-server ~]# service mysql_3306 restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
[root@mysql-server ~]# service mysql_3307 restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!

mysqladmin工具的使用:

关闭数据库
[root@node1 ~]# mysqladmin shutdown -p
默认修改数据库管理员root密码
[root@node1 ~]# mysqladmin password 'newpass' -p
[root@node1 ~]# mysqladmin password '123' -uroot -h localhost -p查看扩展信息,比如变量
[root@node1 ~]# mysqladmin proc extended-status -p
创建数据库
[root@node1 ~]# mysqladmin create db01 -p
删除数据库
[root@node1 ~]# mysqladmin drop db01 -p

相关文章:

MySQL学习笔记3

MySQL的源码编译安装: 1、参考MySQL的源码安装官方文档: 2、源码安装定制选项: 3、源码安装三部曲:配置、编译、安装。 4、软件安装包: mysql-boost-5.7.43.tar.gz 5、安装需求: 安装需求具体配置安装目…...

快速掌握ES6

什么是ES6 ES6(ECMAScript 6),也被称为ES2015,是JavaScript的第六个版本,于2015年发布。ES6引入了许多新的语法和功能,旨在提高JavaScript的开发效率和代码质量。 ES6的一些主要特性和改进包括&#xff1…...

电池厂提供excel电池曲线zcv到mtk电池曲线zcv转换

#encoding:utf8 #电池厂提供excel电池曲线zcv到mtk电池曲线zcv转换 import pandas as pd import openpyxl import math # 读取Excel文件 df pd.read_excel("a55-zcv.xlsx") for j in range(0,10): if(j<3): offset0 #T0~T2 if(j3): offset…...

重写和重载、抽象类和接口

文章目录 前言一、重载与重写1.重载&#xff08;Overload&#xff09;&#xff08;1&#xff09;条件&#xff08;2&#xff09;举例 2.重写&#xff08;Override)&#xff08;1&#xff09;规则&#xff08;2&#xff09;举例 3.重载和重写区别 二、抽象类与接口1.抽象类&…...

Untiy UDP局域网 异步发送图片

同步画面有问题&#xff0c;传图片吧 using System.Text; using System.Net.Sockets; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using System.Net; using System; using System.Threading.Tasks; using Sy…...

移动端H5封装一个 ScrollList 横向滚动列表组件,实现向左滑动

效果&#xff1a; 1.封装组件&#xff1a; <template><div class"scroll-list"><divclass"scroll-list-content":style"{ background, color, fontSize: size }"ref"scrollListContent"><div class"scroll…...

Docker一键安装和基本配置

一键安装脚本 注&#xff1a;该脚本需要root权限 curl -sSL https://get.docker.com/ | sh非root组用户赋权 sudo groupadd docker # 若使用一键安装脚本会自动创建这个组&#xff0c;提示已存在 sudo gpasswd -a ${USER} docker # 将当前用户添加到docker组&#xff0c;也…...

MVC设计思想理解和ASP.NET MVC理解

三层模式 三层模式包括:UI层,业务逻辑层,数据访问层,模型层 MVC设计思想和ASP.NET MVC理解 MVC设计思想: MVC的思想就是把我们的程序分为三个核心的模块,这三个模块的详细介绍如下: 模型(Model) :负责封装与引用程序的业务逻辑相关的数据以及对数据的处理方法。模型层有对…...

大模型应用选择对比

大模型应用选择对比 1、知识库对比&#xff1a;dify、fastgpt、langchatchat 2、agent构建器选择&#xff1a;flowise、langflow、bisheng 3、召回率提升方案...

c++STL概述

目录 STL基本概念 STL六大组件 STL的优点 STL三大组件 容器 算法 迭代器 普通的迭代器访问vector容器元素 算法for_each实现循环 迭代器指向的元素类型是自定义数据类型 迭代器指向容器 常用容器 string容器 string的基本概念 string容器的操作 string的构造函…...

利用容器技术优化DevOps流程

利用容器技术优化DevOps流程 随着云计算的快速发展&#xff0c;容器技术也日益流行。容器技术可以打包和分发应用程序&#xff0c;并实现快速部署和扩展。在DevOps流程中&#xff0c;容器技术可以大大优化开发、测试、部署和运维各个环节。本文将介绍如何利用容器技术优化DevO…...

91 # 实现 express 的优化处理

上一节实现 express 的请求处理&#xff0c;这一节来进行实现 express 的优化处理 让 layer 提供 match 方法去匹配 pathname&#xff0c;方便拓展让 layer 提供 handle_request 方法&#xff0c;方便拓展利用第三方库 methods 批量生成方法性能优化问题 进行路由懒加载&#…...

arcgis拓扑检查实现多个矢量数据之间消除重叠区域

目录 环境介绍&#xff1a; 操作任务&#xff1a; 步骤&#xff1a; 1、数据库和文件结构准备 2、建立拓扑规则 3、一直下一页默认参数后&#xff0c;进行拓扑检查 4、打开TP_CK_Topology&#xff0c;会自动带出拓扑要素&#xff0c;红色区域为拓扑错误的地方&#xff1…...

基于Vue+ELement搭建登陆注册页面实现后端交互

&#x1f389;&#x1f389;欢迎来到我的CSDN主页&#xff01;&#x1f389;&#x1f389; &#x1f3c5;我是Java方文山&#xff0c;一个在CSDN分享笔记的博主。&#x1f4da;&#x1f4da; &#x1f31f;推荐给大家我的专栏《ELement》。&#x1f3af;&#x1f3af; &#x1…...

JS获取经纬度, 并根据经纬度得到城市信息

在JavaScript中&#xff0c;获取经纬度通常需要使用定位服务&#xff0c;比如HTML5的Geolocation API。然而拿到坐标后&#xff0c;将经纬度转换为城市信息&#xff0c;则需要使用逆地理编码服务接口&#xff0c;比如百度或者高德的 API, 但是他们收费都很高, 我们可以使用一些…...

mac m1 docker安装nacos

文章目录 引言I m1安装docker1.1 Docker 下载1.2 终端Docker相关命令II docker安装nacos2.1 安装nacos2.2 镜像启动see alsoMac 查看进程端口引言 使用docker方式安装是最方便的 I m1安装docker 1.1 Docker 下载 https://docs.docker.com/docker-for-mac/apple-silicon/点击…...

位段 联合体 枚举

Hello好久不见&#xff0c;今天分享的是接上次结构体没有分享完的内容&#xff0c;这次我们讲讲位段 枚举和联合体的概念以及他们的用法。 2.1 什么是位段 位段的声明和结构是类似的&#xff0c;有两个不同&#xff1a; 1.位段的成员必须是 int、unsigned int 或signed int 。 …...

PHP循环获取Excel表头字母A-Z,当超过时输出AA,AB,AC,AD······

PHP循环获取Excel表头字母A-Z&#xff0c;当超过时输出AA,AB,AC,AD PHP循环生成Excel的列字母表 $count_num 26 * 27; $letter A; $arr []; while($count_num--){$arr[] $letter;$letter; }结果如下&#xff1a; 转为JSON更为直观&#xff1a; ["A","B&…...

识别准确率达 95%,华能东方电厂财务机器人实践探索

摘 要&#xff1a;基于华能集团公司大数据与人工智能构想理念&#xff0c;结合东方电厂实际工作需要&#xff0c;财务工作要向数字化、智能化纵深推进&#xff0c;随着财务数字化转型和升级加速&#xff0c;信息化水平不断提升&#xff0c;以及内部信息互联互通不断加深&#x…...

代码随想录算法训练营 单调栈part03

一、柱状图中最大的矩形 84. 柱状图中最大的矩形 - 力扣&#xff08;LeetCode&#xff09; 单调栈很重要的性质&#xff0c;就是单调栈里的顺序&#xff0c;是从小到大还是从大到小。 栈顶和栈顶的下一个元素以及要入栈的三个元素组成了我们要求最大面积的高度和宽度&#x…...

零门槛NAS搭建:WinNAS如何让普通电脑秒变私有云?

一、核心优势&#xff1a;专为Windows用户设计的极简NAS WinNAS由深圳耘想存储科技开发&#xff0c;是一款收费低廉但功能全面的Windows NAS工具&#xff0c;主打“无学习成本部署” 。与其他NAS软件相比&#xff0c;其优势在于&#xff1a; 无需硬件改造&#xff1a;将任意W…...

脑机新手指南(八):OpenBCI_GUI:从环境搭建到数据可视化(下)

一、数据处理与分析实战 &#xff08;一&#xff09;实时滤波与参数调整 基础滤波操作 60Hz 工频滤波&#xff1a;勾选界面右侧 “60Hz” 复选框&#xff0c;可有效抑制电网干扰&#xff08;适用于北美地区&#xff0c;欧洲用户可调整为 50Hz&#xff09;。 平滑处理&…...

聊聊 Pulsar:Producer 源码解析

一、前言 Apache Pulsar 是一个企业级的开源分布式消息传递平台&#xff0c;以其高性能、可扩展性和存储计算分离架构在消息队列和流处理领域独树一帜。在 Pulsar 的核心架构中&#xff0c;Producer&#xff08;生产者&#xff09; 是连接客户端应用与消息队列的第一步。生产者…...

高防服务器能够抵御哪些网络攻击呢?

高防服务器作为一种有着高度防御能力的服务器&#xff0c;可以帮助网站应对分布式拒绝服务攻击&#xff0c;有效识别和清理一些恶意的网络流量&#xff0c;为用户提供安全且稳定的网络环境&#xff0c;那么&#xff0c;高防服务器一般都可以抵御哪些网络攻击呢&#xff1f;下面…...

C++.OpenGL (20/64)混合(Blending)

混合(Blending) 透明效果核心原理 #mermaid-svg-SWG0UzVfJms7Sm3e {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-SWG0UzVfJms7Sm3e .error-icon{fill:#552222;}#mermaid-svg-SWG0UzVfJms7Sm3e .error-text{fill…...

mac 安装homebrew (nvm 及git)

mac 安装nvm 及git 万恶之源 mac 安装这些东西离不开Xcode。及homebrew 一、先说安装git步骤 通用&#xff1a; 方法一&#xff1a;使用 Homebrew 安装 Git&#xff08;推荐&#xff09; 步骤如下&#xff1a;打开终端&#xff08;Terminal.app&#xff09; 1.安装 Homebrew…...

【WebSocket】SpringBoot项目中使用WebSocket

1. 导入坐标 如果springboot父工程没有加入websocket的起步依赖&#xff0c;添加它的坐标的时候需要带上版本号。 <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-websocket</artifactId> </dep…...

算法250609 高精度

加法 #include<stdio.h> #include<iostream> #include<string.h> #include<math.h> #include<algorithm> using namespace std; char input1[205]; char input2[205]; int main(){while(scanf("%s%s",input1,input2)!EOF){int a[205]…...

Qwen系列之Qwen3解读:最强开源模型的细节拆解

文章目录 1.1分钟快览2.模型架构2.1.Dense模型2.2.MoE模型 3.预训练阶段3.1.数据3.2.训练3.3.评估 4.后训练阶段S1: 长链思维冷启动S2: 推理强化学习S3: 思考模式融合S4: 通用强化学习 5.全家桶中的小模型训练评估评估数据集评估细节评估效果弱智评估和民间Arena 分析展望 如果…...

数据挖掘是什么?数据挖掘技术有哪些?

目录 一、数据挖掘是什么 二、常见的数据挖掘技术 1. 关联规则挖掘 2. 分类算法 3. 聚类分析 4. 回归分析 三、数据挖掘的应用领域 1. 商业领域 2. 医疗领域 3. 金融领域 4. 其他领域 四、数据挖掘面临的挑战和未来趋势 1. 面临的挑战 2. 未来趋势 五、总结 数据…...