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

然后将以下所有代码复制到其中。

[En]

Then copy all the following code into it.

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/505208/

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

(0)

大家都在看

  • MySQL金额数字转为大写中文

    MySQL版本:5.7.34-log通过创建函数的方法,目前可以实现整数金额的转换,网上暂未找到MySQL版本的故自己参照其他数据库版本的改编了一下, 仅供参考!!!使用方法:se…

    数据库 2023年5月24日
    071
  • centos系统下mysql的配置

    配置文件路径 /etc/my.cnf Hole yor life get everything if you never give up. Original: https://ww…

    数据库 2023年6月9日
    069
  • MySQL查询性能优化七种武器之索引下推

    前面已经讲了MySQL的其他查询性能优化方式,没看过可以去了解一下: MySQL查询性能优化七种武器之索引潜水 MySQL查询性能优化七种武器之链路追踪 今天要讲的是MySQL的另…

    数据库 2023年5月24日
    097
  • 项目中所用到的mysql重复过滤

    问题:首先用户会本地上传一批号码(可能重复)到我们项目,通过解析文件,把号码入库(只验证是不是号码其他不做改动)到号码表,然后对号码进行去重操作. 表结构为:主键(id),号码(m…

    数据库 2023年6月11日
    076
  • Mysql8.0修改lower_case_table_names参数导致重启失败

    GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源。 GreatSQL是MySQL的国产分支版本,使用上与MySQL一致。 事件起因:在测试一个数据迁移工具…

    数据库 2023年5月24日
    0103
  • MySQL8.0 InnoDB并行执行

    概述 MySQL经过多年的发展已然成为最流行的数据库,广泛用于互联网行业,并逐步向各个传统行业渗透。之所以流行,一方面是其优秀的高并发事务处理的能力,另一方面也得益于MySQL丰富…

    数据库 2023年6月9日
    087
  • MySQL连接时报错MySQL 8.0 ERROR 3118 (HY000): Access denied for user ‘root‘@‘localhost‘. Account is locked

    502 Bad Gateway nginx Original: https://www.cnblogs.com/diaoyulin/p/16272895.htmlAuthor: y…

    数据库 2023年6月6日
    0182
  • MySQL函数学习(四)—–聚合函数

    注:笔记旨在记录 四、MySQL 聚合函数 \ 函 数 名 称 作 用 完 成 1 MAX 求最大值 勾 2 MIN 求最小值 勾 3 COUNT 求数量 勾 4 BIT_COUN…

    数据库 2023年6月16日
    079
  • Docker 部署前后端项目

    Docker 部署前后端项目 平生不会相思,才会相思,便害相思。 简介:都是被逼的,从零开始一个Docker 部署九个微服务和三个前端项目。其中,这些服务需要用到Nacos、MyS…

    数据库 2023年6月14日
    086
  • Mysql自序整理集

    mysql事务是用于处理操作量大、复杂性高的数据 原子性:确保每个事务都有已完成或未完成的操作,不能卡在中间;如果事务在执行过程中出现错误,将回滚到事务开始之前的状态。 [En] …

    数据库 2023年5月24日
    090
  • IO流学习笔记

    IO流就是以流的方式进行输入输出 IO 流 Input Output Stream(输入输出流):以流的方式进行输入输出与文件或数据交互的内容称为 IO 流,在 JDK 中 jav…

    数据库 2023年6月11日
    082
  • HA: FORENSICS靶机练习

    ubuntu拿到手,没有恢复模式,不好绕密码,仿真软件又会更改所有用户的密码,怕影响后续操作,先不采用,先试试用john跑一下看看能不能跑出一两个来。 刚好跑出来一个,用户 &lt…

    数据库 2023年6月11日
    087
  • RadonDB MySQL Kubernetes 2.2.1 发布!

    RadonDB MySQL Kubernetes[1] 于近日正式发布新版本 2.2.1[2]。该版本主要在用户管理、高可用组件等进行了优化,并修复一些问题。 感谢 @runkec…

    数据库 2023年5月24日
    072
  • 网络爬虫_Scrapy框架入门

    什么是Scrapy? (百度百科) Scrapy是适用于Python的一个快速、高层次的屏幕抓取和web抓取框架,用于抓取web站点并从页面中提取结构化的数据。Scrapy用途广泛…

    数据库 2023年6月11日
    095
  • git配置报错fatal: Authentication failed for ”问题解决

    如果在git配置中报错fatal: Authentication failed for ”,其实就是 凭证失败的意思 接着输入一下命令行没有出现要求输入用户名或密码,并…

    数据库 2023年6月11日
    0204
  • SQLZOO练习四–SUM and COUNT(聚合函数)

    4、count the big countries 计算有多少个国家,面积大于1000000 How many countries have an area of at least…

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