mac(m1)配置my.cnf

今天开始学习了数据库,在安装MySQL之后启动一直报错,然后在网上找了很多解决方法,最后用以下方法解决

对于习惯了windows的小伙伴来说,直接去安装目录里边修改my.ini就可以,对于习惯了Linux的小伙伴来说,直接修改mysql默认的/etc/my.cnf配置文件就可以,可是Mac端MySQL是默认没有配置文件的,需要自己手动创建。

1.新建etc文件

一般要在 先在/usr/local下新建一个etc 文件,注意etc为配置文件需要以管理员的身份新建 进入/usr/local目录下中,然后输入以下命令

sudo mkdir etc

然后回车即可创建etc文件

2.新建my.cnf文件

然后进入etc目录下,输入以下命令

sudo vi my.cnf

然后将以下代码全部复制进去即可

Example MySQL config file for medium systems.

  #
  # This is for a system with little memory (32M - 64M) where MySQL plays
  # an important part, or systems up to 128M where MySQL is used together with
  # other programs (such as a web server)
  #
  # MySQL programs look for option files in a set of
  # locations which depend on the deployment platform.

  # You can copy this option file to one of those
  # locations. For information about these locations, see:
  # http://dev.mysql.com/doc/mysql/en/option-files.html
  #
  # In this file, you can use all long options that a program supports.

  # If you want to know which options a program supports, run the program
  # with the "--help" option.

  # The following options will be passed to all MySQL clients
  [client]
  default-character-set=utf8
  #password   = your_password
  port        = 3306
  socket      = /tmp/mysql.sock
  # Here follows entries for some specific programs
  # The MySQL server
  [mysqld]
  character-set-server=utf8
  init_connect='SET NAMES utf8'
  port        = 3306
  socket      = /tmp/mysql.sock
  skip-external-locking
  key_buffer_size = 16M
  max_allowed_packet = 1M
  table_open_cache = 64
  sort_buffer_size = 512K
  net_buffer_length = 8K
  read_buffer_size = 256K
  read_rnd_buffer_size = 512K
  myisam_sort_buffer_size = 8M
Don't listen on a TCP/IP port at all. This can be a security enhancement,
if all processes that need to connect to mysqld run on the same host.

All interaction with mysqld must be made via Unix sockets or named pipes.

Note that using this option without enabling named pipes on Windows
(via the "enable-named-pipe" option) will render mysqld useless!

#
#skip-networking

  # Replication Master Server (default)
  # binary logging is required for replication
  log-bin=mysql-bin

    # binary logging format - mixed recommended
    binlog_format=mixed

      # required unique id between 1 and 2^32 - 1
      # defaults to 1 if master-host is not set
      # but will not function as a master if omitted
      server-id   = 1

    # Replication Slave (comment out master section to use this)
    #
    # To configure this host as a replication slave, you can choose between
    # two methods :
    #
    # 1) Use the CHANGE MASTER TO command (fully described in our manual) -
    #    the syntax is:
    #
    #    CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
    #    MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
    #
    #    where you replace <host>, <user>, <password> by quoted strings and
    #    <port> by the master's port number (3306 by default).

    #
    #    Example:
    #
    #    CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
    #    MASTER_USER='joe', MASTER_PASSWORD='secret';
    #
    # OR
    #
    # 2) Set the variables below. However, in case you choose this method, then
    #    start replication for the first time (even unsuccessfully, for example
    #    if you mistyped the password in master-password and the slave fails to
    #    connect), the slave will create a master.info file, and any later
    #    change in this file to the variables' values below will be ignored and
    #    overridden by the content of the master.info file, unless you shutdown
    #    the slave server, delete master.info and restart the slaver server.

    #    For that reason, you may want to leave the lines below untouched
    #    (commented) and instead use CHANGE MASTER TO (see above)
    #
    # required unique id between 2 and 2^32 - 1
    # (and different from the master)
    # defaults to 2 if master-host is set
    # but will not function as a slave if omitted
    #server-id       = 2
    #
    # The replication master for this slave - required
    #master-host     =   <hostname>
    #
    # The username the slave will use for authentication when connecting
    # to the master - required
    #master-user     =   <username>
    #
    # The password the slave will authenticate with when connecting to
    # the master - required
    #master-password =   <password>
    #
    # The port the master is listening on.

    # optional - defaults to 3306
    #master-port     =  <port>
    #
    # binary logging - not required for slaves, but recommended
    #log-bin=mysql-bin

      # Uncomment the following if you are using InnoDB tables
      #innodb_data_home_dir = /usr/local/mysql/data
      #innodb_data_file_path = ibdata1:10M:autoextend
      #innodb_log_group_home_dir = /usr/local/mysql/data
      # You can set .._buffer_pool_size up to 50 - 80 %
      # of RAM but beware of setting memory usage too high
      #innodb_buffer_pool_size = 16M
      #innodb_additional_mem_pool_size = 2M
      # Set .._log_file_size to 25 % of buffer pool size
      #innodb_log_file_size = 5M
      #innodb_log_buffer_size = 8M
      #innodb_flush_log_at_trx_commit = 1
      #innodb_lock_wait_timeout = 50

        [mysqldump]
        quick
        max_allowed_packet = 16M

          [mysql]
          no-auto-rehash
          # Remove the next comment character if you are not familiar with SQL
          #safe-updates
          default-character-set=utf8

        [myisamchk]
        key_buffer_size = 20M
        sort_buffer_size = 20M
        read_buffer = 2M
        write_buffer = 2M

          [mysqlhotcopy]
          interactive-timeout
&#x2014;&#x2014;&#x2014;&#x2014;&#x2014;&#x2014;&#x2014;&#x2014;&#x2014;&#x2014;&#x2014;&#x2014;&#x2014;&#x2014;&#x2014;&#x2014;

</port></password></username></hostname></port></password></user></host></password></user></port></host>

然后按esc并输入:wq保存即可

3.设置my.cnf文件的权限

执行下面代码,否则mysql并不会读取my.cnf这个配置文件,执行下面一行命令前查看自己当前的目录,我当前是在etc目录里面的

mac(m1)配置my.cnf
sudo chmod 664 my.cnf

最后输入以下命令 即可启动MySQL

sudo /usr/local/mysql/support-files/mysql.server start

Original: https://www.cnblogs.com/twq46/p/16484537.html
Author: 剑断青丝ii
Title: mac(m1)配置my.cnf

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/620808/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

  • 记一次stormOOM异常的产生与解决

    最近这段时间开始了一个新项目,项目使用rabbitMQ存储采集数据,通过storm对rabbitMQ中的数据进行实时计算,将结果存入到rabbitMQ的另一个队列中,再由另外一个s…

    数据库 2023年6月6日
    067
  • Docker 完整版教程

    Docker 安装 一、安装前必读 在安装 Docker 之前,先说一下配置,我这里是Centos7 Linux 内核:官方建议 3.10 以上,3.8以上貌似也可。 注意:本文的…

    数据库 2023年6月14日
    069
  • 【Java代码之美】 — 通过Value获取Map中的键值Key的四种方法

    1.简介 最近在项目中遇到一个EasyExcel中需要取invokeHeadMap中headMap里面的具体列名的集合Index,就遇到了需要从Map从反向通过Value取对应的K…

    数据库 2023年6月6日
    0110
  • 配置 Windows Terminal 步骤

    配置 Windows Terminal 的步骤 前提:在微软商店下载两个软件 Windows Terminal PowerShell oh-my-posh 配置 oh my pos…

    数据库 2023年6月6日
    0117
  • JavaWeb核心篇(2)——Request和Response

    JavaWeb核心篇(2)——Request和Response 上篇文章中提及到了Servlet,在Servlet中我们主要继承了HTTPServlet类,在HTTPServlet…

    数据库 2023年6月14日
    097
  • 23种设计模式之迭代器模式

    文章目录 概述 迭代器模式的优缺点 迭代器模式的结构和实现 * 模式结构 模式实现 总结 ; 概述 迭代器模式就是顺序访问聚集中的对象,一般来说,集合中非常常见,如果对集合类比较熟…

    数据库 2023年6月6日
    058
  • 希望腿上的伤快点好

    明天去星巴克泡一会儿想把一些课程关联到的课程学习一下 Original: https://www.cnblogs.com/ukzq/p/16747859.htmlAuthor: D…

    数据库 2023年6月11日
    078
  • Mybatis-Plus使用 ORDER BY FIELD

    一、Mybatis-Plus使用 ORDER BY FIELD 如图所示 两张仅有一个字段关联的表,商品表想用活动商品表查出来的顺序去查商品可以使用以下方法(不想去XML写Sql的…

    数据库 2023年6月6日
    073
  • 生产数据库主键超出限制解决方案

    不说那种建表的时候 设置好主键格式 的 解决方案. 事后诸葛啊. 谁都会 不靠谱方案1改主键表结构. 费时! 主键已经超长了.说明 数据量相当大. 改表结构的时间成本你能等得起吗方…

    数据库 2023年6月14日
    077
  • 深入浅出分析 HashMap

    作者:炸鸡可乐原文出处:www.pzblog.cn 一、摘要 在集合系列的第一章,咱们了解到,Map的实现类有HashMap、LinkedHashMap、TreeMap、Ident…

    数据库 2023年6月14日
    065
  • index_merge引发的死锁排查

    前几天排查了一个死锁问题,最开始百思不得其解,因为发生死锁的两个事务是单语句事务,语句类型相同(where属性列相同,仅值不同),而且语句都走了相同的索引,但最终确实发生了死锁。通…

    数据库 2023年6月9日
    086
  • Java Script 循环,数组,对象,判断,阶乘,查找-综合运用合集

    输出100个hello world. for (var i = 1; i console.log("hello world");} 创建一个包含1~100的数组…

    数据库 2023年6月11日
    082
  • git本地分支推送至远程分支

    1、本地任意盘→新建文件夹,例:我新建文件夹名称是:E:\git 2、打开git文件夹,文件夹内鼠标右击选择 Git Bash Here 3、克隆远程分支到本地分支【远程分支移动到…

    数据库 2023年6月14日
    0144
  • Linux进程管理

    进程管理 基本概念介绍 进程和线程 进程: 一个在内存中运行的应用程序,每一个进程都有自己独立的一块内存空间,并被分配一个ID号(PID),在Windows下可以打开任务管理器查看…

    数据库 2023年6月16日
    0100
  • SQL Archery 代码说明及优化(一)

    1.字段加密–django-mirage-field 一个django模型字段,在保存到数据库时对数据进行加密,在从数据库获取数据时进行解密。它使数据库中的数据始终加密…

    数据库 2023年6月16日
    092
  • 看看你离世界一流大厂有多远?3道Google最新SQL面试题 ⛵

    💡 作者:韩信子@ShowMeAI📘 数据分析◉技能提升系列:https://www.showmeai.tech/tutorials/33📘 AI 面试题库系列:https://w…

    数据库 2023年6月14日
    066
亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球