如果想把mysql安装得好一些,则严重推荐使用压缩包来安装,不推荐使用rpm方式。

一般情况下,现在大部分的服务器都是x86-64,少数是arm架构的。

选择合适的版本,下载即可。

本文中,使用的是 mysql-8.0.22-el7-x86_64.tar.gz (这对centos7的)

为了便于管理,个人推荐的目录

/soft/mysql/program  --放myql程序文件

/soft/mysql/config     --放mysql的配置文件,配置文件可以随意命名,例如my.ini,my.cnf,my.config之类都无所谓

之所以这样,是因为个人的习惯--把一类或者一个东西放在一个目录下,这样更好找,也更容易管理!除此之外,就是拥有更多的灵活性!

当然也可以直接使用默认的/etc/my.cnf 路径

下面是大概的步骤:

1.解压文件

2.写好my.cnf

3.初始化

4.启动服务,修改root密码

5.把mysql配置为服务,以便自动启动

步骤1:前置准备

1)包括下载,创建用户等等基本工作

2)了解需要新的实例要支持什么业务,满足什么特性

步骤2:写my.cnf,重点几个:

1)字符集

2)数据目录

3)端口

4)是否使用root运行(很多时候,我们就用root执行了)

5)密码验证方式

6)是否忽略大小写

7)是否关比bin_log(如果不复制,这个可以节约时间)

8)日志目录

下面是my.cnf的配置例子:

[client]
port=3318 [mysql]
no-beep
default-character-set=UTF8MB4 [mysqld]
user=root
skip-log-bin
port=3318
#不区分大小写(linux设置,windows不设置。linux必须初始化的时候设置)
lower_case_table_names=1
# 程序路径
basedir="/soft/mysql-8.0.22-el7-x86_64" # 数据库实例根数据路径
datadir=/data/mysql # 创建数据库和表的默认字符集
character-set-server=UTF8MB4 # 默认存储引擎
default-storage-engine=INNODB # General and Slow logging.
log-output=FILE
slow-query-log=0
bulk_insert_buffer_size=32M # Error 日志
log-error="mysql.err" # 最大并发会话
max_connections=500 # 所有线程可以允许打开的表数量
table_open_cache=1200 # Maximum size for internal (in-memory) temporary tables. If a table
# grows larger than this value, it is automatically converted to disk
# based table This limitation is for a single table. There can be many
# of them.
# 内存临时表大小--如果有许多需要临时表的查询,而且这些临时表都挺大的,可以考虑设置大一些
# 当然前提,是您相对比较阔绰,可以有许多内存
tmp_table_size=32M # How many threads we should keep in a cache for reuse. When a client
# disconnects, the client's threads are put in the cache if there aren't
# more than thread_cache_size threads from before. This greatly reduces
# the amount of thread creations needed if you have a lot of new
# connections. (Normally this doesn't give a notable performance
# improvement if you have a good thread implementation.)
thread_cache_size=10 # Size of the buffer used for doing full table scans of MyISAM tables.
# Allocated per thread, if a full scan is needed.
read_buffer_size=0 read_rnd_buffer_size=0 #*** INNODB Specific options ***
# innodb_data_home_dir=0.0 # Use this option if you have a MySQL server with InnoDB support enabled
# but you do not plan to use it. This will save memory and disk space
# and speed up some things.
# skip-innodb # If set to 1, InnoDB will flush (fsync) the transaction logs to the
# disk at each commit, which offers full ACID behavior. If you are
# willing to compromise this safety, and you are running small
# transactions, you may set this to 0 or 2 to reduce disk I/O to the
# logs. Value 0 means that the log is only written to the log file and
# the log file flushed to disk approximately once per second. Value 2
# means the log is written to the log file at each commit, but the log
# file is only flushed to disk approximately once per second.
#谨慎修改这个参数
innodb_flush_log_at_trx_commit=1 # The size of the buffer InnoDB uses for buffering log data. As soon as
# it is full, InnoDB will have to flush it to disk. As it is flushed
# once per second anyway, it does not make sense to have it very large
# (even with long transactions).
innodb_log_buffer_size=128m #建议开启严谨模式
innodb_strict_mode=on #密码验证方式
default_authentication_plugin=mysql_native_password

步骤3:初始化

如果使用专有的mysql用户(用户未必叫这个,不过为了便于识别就叫mysql。如有个人爱好,喜欢叫msql,uglysql可以)启动配置(这是推荐的,前提是创建了对应用户)

bin/mysqld --defaults-file=/opt/mysql/mysql/etc/my.cnf  --initialize  --user=mysql

如果想用root且修改配置文件路径,则可以修改为

bin/mysqld --defaults-file=/data/mysql/config/my.cnf  --initialize  --user=root

步骤4:安装为服务

有时候不一定按照下面就可以安装为服务,要看系统的情况。

注意:如果修改了my.cnf的存储路径则必须修改mysql.server文件

mysql.server一般在support-files目录下

以下是一般需要修改的片段:

# If you change base dir, you must also change datadir. These may get
# overwritten by settings in the MySQL configuration files.

basedir=/soft/mysql-8.0.22-el7-x86_64
datadir=/data/mysql

复制启动文件  cp mysql.server /etc/init.d/mysqld

赋予可执行权限:# chmod +x /etc/init.d/mysqld

添加为服务:# chkconfig --add mysqld

之后可以使用 systemctl start/stop/status mysqld

也可以直接使用mysql.server start/stop等

注:使用upstart方式启动服务,并不是推荐的访问,远远不如systemd方式来得优雅。如果suport-files中没有可以参考的service,那么可以自己创建一个,

如果使用systemd的方式创建服务,网络上有很多!

这个方面redis做得比mysql好一些。

总结

一个开发环境的安装还是很容易的,前提是对于性能不需要特别优化的情况。

最后,申明下,以上的配置仅仅能够满足一般的开发,要想满足高性能的配置,远远不够。

作为一个mysql dba,必须掌握:

1)mysql 开发

2)  linux配置

3)  mysql 配置

4)  操作系统、网络

5)熟悉要优化的系统的业务

6)你的项目,你的团队的情况

如果认为会建立索引,会写一些复杂一点点的sql,也认为是优化,那还差太远太远了,只能贻笑大方!

mysql8.0.22在centos7.6下的简单安装的更多相关文章

  1. 在ConoHa上Centos7环境下源码安装部署LNMP

    本文记录了从源码,在Centos 7上手动部署LNMP环境的过程,为了方便以后对nginx和mariadb进行升级,这里采用yum的方式进行安装. 1.建立运行网站和数据库的用户和组 groupadd ...

  2. mysql 5.7.29 在centos7.6下超简单的本地yum源安装与配置

    目录 生成yum源元数据 从网易镜像站下载MySQL 5.7 的 bundle包 创建文件 mysql-local.repo 执行yum install命令 生成yum源元数据 createrepo ...

  3. sphinx在windows下的简单安装与使用

    1.下载地址 http://sphinxsearch.com/downloads/release/,我这里下的是“Win64 binaries w/MySQL+PgSQL+libstemmer+id6 ...

  4. MySQL8.0 zip压缩包版本 Windows下安装

    MySQL zip压缩包版本 Windows下安装 Download MySQL Community Server 解压到相应的目录 我的解压目录:D:\Program Files\mysql-8.0 ...

  5. CentOS7系统下GitLab的安装、汉化、修改默认端口、开启发送邮箱

    一.centos7.4 下安装及汉化 =============================================== 2017/11/12_第6次修改                  ...

  6. nginx在Centos7.5下源码安装和配置

    安装nginx 安装nginx依赖包 yum install -y pcre-devel zlib-devel openssl-devel wget gcc tree vim 进入目录/root/se ...

  7. CentOS下nginx简单安装

    说明:环境 系统:Centos 6 软件包:nginx-1.2.4 配置系统yum源 #/etc/yum.repos.d/ #rm -rf ./* vi localhost.repos.d [yumy ...

  8. Hyperledger fablic 0.6 在centos7环境下的安装与部署

    原文:http://blog.csdn.net/zhaoliang1131/article/details/54617274 Hyperledger Fabric超级账本 项目约定共同遵守的 基本原则 ...

  9. mysql5.7.22在centos7.5下的安装

    1.下载,解压 把下载的文件放到 /app/programs/目录下 tar -zxvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz 地址:https://d ...

  10. Mysql8.0.17忘记密码情况下重置密码

    1.以管理员身份打开命令窗口cmd,输入命令: net stop mysql 2.开启跳过密码验证登录的mysql服务,输入命令 mysqld --console --skip-grant-table ...

随机推荐

  1. dotnet C# 通过 Vortice 将 ID2D1CommandList 作为特效的输入源

    使用 Direct2D 过程中将可以使用到 Direct2D 强大的特效功能,比如给某些界面绘制内容添加特效支持.本文将告诉大家如何通过 Vortice 将 ID2D1CommandList 作为特效 ...

  2. 九、ODBC External Table Of Doris

    ODBC External Table Of Doris 提供了Doris通过数据库访问的标准接口(ODBC)来访问外部表 ODBC Driver的安装和配置: 要求所有的BE节点都安装上相同的Dri ...

  3. 为什么需要学习ITSM/ITIL

    假如你需要管理一个超过20人的IT服务组织,一般会面临以下问题: 人多事杂活重,每个人都很累,工作却还是一团糟糕, 用户方怨声载道,领导也颇有微词,同事间也经常互相甩锅埋坑, 工作只是救火或者混日子, ...

  4. C#库dll配置文件App.config数据库连接项connectionStrings

    原文地址:https://www.zhaimaojun.top/Note/5464967 网上一大堆的都是在说怎么修改项目文件,试过了不行,因为里面涉及到vs版本和安装目录等问题,不同的设备配置是不同 ...

  5. 更新Homebrew时候遇到的问题

    问题描述: 更新Homebrew时候遇到无法访问github的问题,判定原因为DNS污Ran. fatal: unable to access 'https://github.com/Homebrew ...

  6. golang计时器

    timer 计时器 用于在指定的Duration类型时间后调用函数或计算表达式. 如果只是想指定时间之后执行,使用time.Sleep() 使用NewTimer(),可以返回的Timer类型在计时器到 ...

  7. installshield 64位系统操作注册表遇到的问题

    最近在研究IS脚本设置jdk环境变量问题,在使用RegDBKeyExist判断注册表中项的时候一直找不到,翻找文档后发现64位的操作系统需要设置 REGDB_OPTIONS. "SOFTWA ...

  8. 现代农业|AIRIOT智慧农业管理解决方案

    ​ 智慧农业是现代化技术在农业领域的应用和成果,其中物联网技术在促生产.保产量和降本增效方面起到了至关重要的作用.运用传感技术和软件平台系统对农业生产进行智能化平台化管理,解决掉传统农业问题的诸多痛点 ...

  9. AIRIOT答疑第2期|如何使用物联网平台的数据采集与控制引擎?

    任性用!   作为AIRIOT物联网低代码平台的五大核心能力引擎之一,数据采集与控制引擎具备极强的系统集成能力,提供丰富的接口,具备海量工业设备驱动库,分布式采集,稳定性高,实现快速的设备接入.报警. ...

  10. VSCode + JTAG调试合宙ESP32C3的经历

    VSCode + JTAG调试合宙ESP32C3 环境 Windows10 VSCode + ESP-IDF 合宙ESP32C3(无串口芯片版本) 理论 想要直接使用内置JTAG,USB要求连接GPI ...