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)

大家都在看

  • 数据火器库八卦系列之瑞士军刀随APP携带的SQLite

    来源:云数据库技术 数据库打工仔喃喃自语的八卦历史 为导弹巡洋舰设计,用在手机上的数据库 Small and Simple, and Better 如何看出是自己的娃:产品定位,特…

    数据库 2023年6月11日
    0109
  • Logback实现按业务输出到对应日志文件

    一、方案 由于需要按业务生成不同的日志文件,看到按业务来区分,我的第一感觉就是业务其实是可以按包名来区分的。所以其实我们只要实现不同的包下面的日志输出到不同的文件,就能实现需求了。…

    数据库 2023年6月6日
    0280
  • MySQL常用数据类型及细节

    类型 类型举例 整数类型 TINYINT、SMALLINT、MEDIUMINT、INT(或INTEGER)、BIGINT 浮点类型 FLOAT、DOUBLE 定点数类型 DECIM…

    数据库 2023年5月24日
    086
  • Redisson

    ​ Redisson是架设在Redis基础上的一个Java驻内存数据网格(In-Memory Data Grid)。充分的利用了Redis键值数据库提供的一系列优势,基于Java实…

    数据库 2023年6月6日
    092
  • 解决pycharm问题:module ‘pip’ has no attribute ‘main’

    Pycharm安装package出现如下报错: 找到安装目录下 helpers/packaging_tool.py文件,找到如下代码: 修改如下: Original: https:…

    数据库 2023年6月6日
    0278
  • SpringBoot下的文件上传

    ; 代码很简单。已经放到码云了,码云地址:https://gitee.com/zhang-zhixi/springboot-upload.git posted @2022-04-2…

    数据库 2023年6月14日
    081
  • Java学习-第一部分-第二阶段-第六节:泛型

    泛型 笔记目录:(https://www.cnblogs.com/wenjie2000/p/16378441.html) 泛型的理解和好处 看一个需求 请编写程序,在ArrayLi…

    数据库 2023年6月11日
    096
  • Linux 系统安装RocketMQ

    准备工作 1.去官网下载一个安装包 1.解压 unzip rocketmq-all-4.9.0-bin-release.zip -d /download/compress/ 2.进…

    数据库 2023年6月6日
    088
  • SQL的约束

    概念:约束是作用于表中字段上的规则,用于限制存储表中的数据; 常见的约束分类:约束 描述 关键字 非空约束 限制该字段的数据不能为null not null 唯一约束 保证该字段的…

    数据库 2023年6月16日
    093
  • 线程的生命周期

    线程的生命周期​ 线程具有生命周期,其中包含 5种状态(出生状态,就绪状态,运行状态、暂停状态、死亡状态)。 出生状态就是线程被创建时的状态:当线程对象调用 start()方法 后…

    数据库 2023年6月16日
    0117
  • 二手车价格预测 | 构建AI模型并部署Web应用 ⛵

    💡 作者:韩信子@ShowMeAI📘 数据分析实战系列:https://www.showmeai.tech/tutorials/40📘 机器学习实战系列:https://www.s…

    数据库 2023年6月14日
    084
  • JVM-虚拟机栈

    运行时数据区-虚拟机栈 JAVA技术交流群:737698533 java虚拟机在执行java程序过程中会把它所管理的内存划分为若干个不同的区域,这些区域各有各的作用,根据java虚…

    数据库 2023年6月16日
    0112
  • 局域网内访问子网服务(访问电脑虚拟机中的服务)

    局域网内访问子网服务 问题描述: 同一个路由器(172.18.0.0)下面有两台电脑A(172.18.40.45)和B (172.18.44.173) ,在B电脑上安装虚拟机 ,使…

    数据库 2023年6月9日
    098
  • 尤娜,我去面试了

    前情回顾 从前,有一个简单的通道系统叫尤娜…… 尤娜系统的第一次飞行中换引擎的架构垂直拆分改造 四种常用的微服务架构拆分方式 面试前几天 尤娜系统经过一次拆…

    数据库 2023年6月6日
    082
  • Maven的工作机制

    Maven是 Apache 软件基金会组织维护的一款专门为 Java 项目提供 构建和 依赖管理支持的工具。 ·首先, Maven核心程序:负责Maven的总体调度,具体操作使用的…

    数据库 2023年6月16日
    082
  • 项目主干分支的server.sh被“覆盖”了?一个配置,解除烦恼

    我司项目利用springboot搭建,应用在部署到各环境后,程序启动命令靠的是我们在工程里配置的 scripts/server.sh。这个server.sh里最重要的东西是程序启动…

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