当前位置:   article > 正文

MacBook Pro Apple M2 Max安装MySQL-8.0.33_mysql8.0.33 mac

mysql8.0.33 mac

系统:macOS Ventura
芯片:M2
数据库:MySQL 8.0.33

下载安装程序

官网地址:https://www.mysql.com/
在这里插入图片描述
点击页签“DOWLOADS“后将页面拖到底部,点MySQL Community Server。
在这里插入图片描述
在这里插入图片描述

安装数据库

按照向导操作即可

配环境变量

cd /etc/paths.d
vim .bash_profile
  • 1
  • 2

输入下面的内容:

export PATH=$PATH:/usr/local/mysql/bin
export PATH=$PATH:/usr/local/mysql/support-files
  • 1
  • 2

然后执行配置文件使其生效:

source ./.bash_profile
  • 1

查看数据库状态

查看数据库的状态:

sudo mysql.server status
  • 1

会报错,提示 pid 文件找不到。

查看原因:
打开macbook pro 的系统偏好,在底部找到已经安装的数据库。
在这里插入图片描述

接着点击页签configuration,找到错误日志文件的路径。
在这里插入图片描述

查看日志文件:

sudo tail /usr/local/mysql/data/mysqld.local.err
  • 1

看文件末尾最新的日志,可以大致知道是因为变量 server_id的配置问题,而这个变量是在某个.cnf文件中配置的,我不知道默认的.cnf文件在哪个目录下,但是可以在 /etc/ 下面创建一个名为 my.cnf的文件来取代默认的,文件内容如下:

# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# 
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /usr/local/mysql/data/mysqld.local.pid
socket = /tmp/mysql.sock
port = 3306
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
tmpdir = /tmp
lc-messages-dir = /usr/local/mysql/share
log-error = /usr/local/mysql/data/mysqld.local.err
pid-file = /usr/local/mysql/data/mysqld.local.pid

# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

#
# * Character sets
#
collation-server = utf8mb4_unicode_ci
init-connect='SET NAMES utf8mb4'
character-set-server = utf8mb4

#
# * MyISAM
#
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched. On error, make copy and try a repair.
myisam_recover_options = BACKUP

#
# * NDB Cluster
#
# See /usr/local/mysql/bin/ndbd
# Note: ndbd init script requires this to include nodeid!
# datadir=/usr/local/mysql/data
# [MYSQL_CLUSTER]
# ndb-connectstring=127.0.0.1

[mysqld_safe]
log-error = /usr/local/mysql/data/mysqld.local.err
pid-file = /usr/local/mysql/data/mysqld.local.pid

#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /usr/local/mysql/data/.
# Read the manual for more InnoDB related options. There are many!
innodb_buffer_pool_size = 128M

[client]
port = 3306
socket = /tmp/mysql.sock
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68

其中的变量 log-error、pid-file、basedir、datadir的值可以从MySQL的配置界面中获得。

在这里插入图片描述
配置好之后,再启动数据库,具体参见这里:https://liaowenxiong.blog.csdn.net/article/details/121136723

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/266928?site
推荐阅读
相关标签
  

闽ICP备14008679号