mac(m1)配置my.cnf[亲测有效]

mac(m1)配置my.cnf[亲测有效]今天开始学习了数据库,在安装MySQL之后启动一直报错,然后在网上找了很多解决方法,最后用以下方法解决 对于习惯了windows的小伙伴来说,直接去安装目录里边修改my.ini就可以,对于习惯了Lin

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
————————————————
 

然后按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

原文地址:https://www.cnblogs.com/twq46/archive/2022/07/16/16484537.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
转载请注明出处: https://daima100.com/5002.html

(0)
上一篇 2023-05-27
下一篇 2023-05-27

相关推荐

  • Python实现SOCKS5代理服务器

    Python实现SOCKS5代理服务器在今天的互联网世界中,网络安全问题比以往任何时候都更受人们关注。在此背景下,代理服务器成为网民保护隐私和信息安全的重要工具之一。代理服务器即在客户端和目标服务器之间充当中间人的角色,使得客户端能够间接地访问目标服务器,从而实现隐藏真实IP地址,以及加密等功能的实现。在这种情况下,我们需要一个高效的、安全的、可靠的代理服务器来满足用户的需求。Python是一种高效的编程语言,在网络通信领域也有很好的应用。在这篇文章中,我们将学习如何使用Python来实现一个SOCKS5代理服务器。

    2024-08-25
    26
  • 将列表反转,Python实现

    将列表反转,Python实现Python内置的列表对象提供了reverse方法,可以将列表进行反转。

    2024-02-28
    107
  • 利用Python求解最高点

    利用Python求解最高点地球上最高的峰是珠穆朗玛峰,被广泛认为是登山家的终极挑战。对于普通人而言,珠峰可能是一个不可到达的梦想,但是我们可以通过计算机技术探索珠峰的高度和它周围的地形。

    2023-12-12
    106
  • mysql 慢查询_电脑变慢怎么解决

    mysql 慢查询_电脑变慢怎么解决目的 根据发现的问题,找到原因,然后对症下药 借鉴资料: 没用过慢查询日志,别说自己做过数据库优化 慢查询日志概念 记住七个字搞定索引失效问题 发现问题(主动/被动) 问题点:数据库查询过程中速度过慢

    2023-05-06
    138
  • 什么是mysql慢查询_mysql数据库查询慢

    什么是mysql慢查询_mysql数据库查询慢一、

    2023-03-18
    148
  • SQL Server 2000_td数据

    SQL Server 2000_td数据腾讯云数据库TDSQL与中国人民大学最新联合研究成果被SIGMOD 2022接收并将通过长文形式发表。SIGMOD是国际数据管理与数据库领域顶尖的学术会议之一,腾讯云数据库TDSQL论文已连续多年入选

    2023-05-22
    189
  • VMware workstation16 中Centos7下MySQL8.0安装过程+Navicat远程连接[亲测有效]

    VMware workstation16 中Centos7下MySQL8.0安装过程+Navicat远程连接[亲测有效]1.MySQL yum源安装 2.安装后,首次登录mysql以及密码配置3.远程登录问题(Navicat15为例) 一、CentOS7+MySQL8.0,yum源安装1.安装mysql前应卸载原有my

    2023-04-21
    150
  • Python数值处理:快速高效地进行数字计算

    Python数值处理:快速高效地进行数字计算Python作为一种高级编程语言,在数据科学领域表现出了强大的计算能力。Python作为一种动态的解释型语言,有很多便于快速开发的库可供使用,例如NumPy、SciPy和Pandas等。这些库用Python编写,主要用于进行快速的矢量化计算,以及对大规模数据进行高效处理。

    2024-04-04
    77

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注