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)

大家都在看

  • 2022-8-15 数据库 mysql 第一天

    Mysql数据库 数据库 数据库[根据数据结构组织、存储和管理数据的仓库]。它是有组织的、可共享的、统一管理的大量数据的集合,这些数据长期存储在计算机中。 [En] Databas…

    数据库 2023年5月24日
    066
  • kafka详解(一)–kafka是什么及怎么用

    kafka是什么 在回答这个问题之前,我们需要先了解另一个东西–event streaming。 什么是event streaming 我觉得, event strea…

    数据库 2023年6月6日
    084
  • 记一次MySql唯一索引在left join连表查询没走索引的问题

    在新建一张账单结算信息表bill_settlement_info的时候,建立的唯一索引uk_bill_no(bill_no,tenant_id)。由于列表查询用到该表的字段。所以在…

    数据库 2023年6月16日
    076
  • CentOS7源码安装MySQL

    CentOS7源码安装MySQL 1:安装依赖包 执行:yum -y install ncurses-devel gcc- bzip2- bison 2:升级cmake工具(我用的…

    数据库 2023年6月6日
    083
  • linux-centos常用命令

    01-centos-常用命令 1.centos防火墙 关闭 systemctl stop firewalld 禁止开机启动防火墙 systemctl disable firewal…

    数据库 2023年6月11日
    0100
  • 总结:弹性伸缩的五个条件与六个教训

    前言弹性伸缩是云计算时代给我们带来的一项核心技术红利,但是 IT 的世界中,没有一个系统功能可以不假思索的应用到所有的场景中。这篇文章,我们将应用企业级分布式应用服务-EDAS 的…

    数据库 2023年6月15日
    0130
  • leetcode 669. Trim a Binary Search Tree 修剪二叉搜索树 (简单)

    一、题目大意 给你二叉搜索树的根节点 root ,同时给定最小边界low 和最大边界 high。通过修剪二叉搜索树,使得所有节点的值在[low, high]中。修剪树 不应该 改变…

    数据库 2023年6月16日
    088
  • Java面向对象(上)

    Java面向对象(上) 一、面向对象的思想 1、面向过程: 面向过程就是分析出解决问题所需要的步骤,然后用函数把这些步骤逐一实现,使用的时候依次调用就可以了。 2、面向对象: 面向…

    数据库 2023年6月11日
    0100
  • Java 多线程共享模型之管程(下)

    共享模型之管程 wait、notify wait、notify 原理 Owner 线程发现条件不满足,调用 wait 方法,即可进入 WaitSet 变为 WAITING 状态 B…

    数据库 2023年6月16日
    0116
  • DELL误删raid后恢复方法

    DELL误删raid后恢复方法 一台有RAID1信息的硬盘A,一块误删的硬盘B 1.插入硬盘A和B,启动,再按Ctrl+R键,进入raid管理 发现没有硬盘信息,按F2键 选择Fo…

    数据库 2023年6月9日
    0101
  • Socket 编码入门

    很多同行朋友大概率学过 socket 通信相关知识, send, recv, listen, connect, accept 等等组合, 变幻 无穷 … 相关的介绍书籍…

    数据库 2023年6月9日
    070
  • MySQL索引

    一、索引介绍 索引(index)是帮助MySQL 高效获取数据的数据结构(有序)。在数据之外,数据库系统还维护着满足特定查找算法的数据结构,这些数据结构以某种方式引用(指向)数据,…

    数据库 2023年5月24日
    081
  • Vue 2.0 基础

    知识点 1.是一个MVVM框架 由MVC架构衍生,分为View(视图层)、ViewModel(数据视图层)、Model(数据层),MVVM 最标志性的特性就是 数据绑定,实现数据驱…

    数据库 2023年6月11日
    0104
  • MySQL 基础

    MySQL 基础 SQL 介绍 SQL (Structured Query Language:结构化查询语言) 是用于管理关系数据库管理系统(RDBMS)。 SQL 的范围包括数据…

    数据库 2023年5月24日
    093
  • DM-DM之间的DBLINK

    1 创建外部链接 创建一个外部链接。 语法格式 CREATE [OR REPLACE] [PUBLIC] LINK STANDBY FIRST | PRIMARY ONLY | S…

    数据库 2023年6月11日
    078
  • MySQL 服务无法启动。服务没有报告任何错误。

    版本8.0.25,今天启动发现抱错,网上搜索一下发现这样可行 启动MySQL报错: 搜索了一下,按照这样步骤解决了 1.配置一下my.ini [mysqld] basedir =&…

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