当前位置:   article > 正文

mac安装MySQL-very easy

mac安装MySQL-very easy


方法:直接用Homebrew安装


1.命令:

brew install mysql
  • 1

2.安装过程

zhangjingyideMacBook-Pro:~ zhangjingyi$ brew install mysql
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
anime-downloader                         k3d
antibody                                 k6
appstream-glib                           kim-api
atlantis                                 libevhtp
catch2                                   libzt
cjson                                    lizard
clojure-lsp                              mariadb@10.3
clzip                                    molten-vk
contentful-cli                           netlify-cli
csvq                                     newman
cxxopts                                  openkim-models
cypher-shell                             pipx
dbmate                                   pprint
deno                                     procs
devspace                                 proteinortho
docker-machine-driver-vmware             scala@2.12
drone-cli                                scdoc
dust                                     scws
erlang@21                                spice-gtk
gatsby-cli                               spirv-tools
gcc@8                                    swig@3
heatshrink                               termshark
helmsman                                 terraform@0.11
hey                                      terraformer
include-what-you-use                     virgil
ipopt                                    yapf
janet
==> Updated Formulae
erlang ✔                                 libnfs
gettext ✔                                libnice
git ✔                                    libnids
openssl ✔                                libnotify
rabbitmq ✔                               libntlm
abyss                                    libodfgen
ack                                      libofx
acpica                                   libomp
agda                                     libopenmpt
aide                                     libosinfo
akamai                                   libpeas
akka                                     libphonenumber
aliyun-cli                               libpq
allure                                   libpqxx
allureofthestars                         libprotoident
alot                                     libpsl
amazon-ecs-cli                           libpst
ammonite-repl                            libpulsar
amqp-cpp                                 libqalculate
amtk                                     libquicktime
angle-grinder                            librasterlite
angular-cli                              librdkafka
anjuta                                   libre
annie                                    librealsense
ansible                                  librem
ant                                      libressl
ant@1.9                                  librest
anyenv                                   librsvg
apache-archiva                           libsass
apache-arrow-glib                        libsecret
apache-drill                             libshout
apache-spark                             libsigc++
app-engine-python                        libsmf
apt-dater                                libsodium
aqbanking                                libsoup
arangodb                                 libspectre
aravis                                   libspectrum
argon2                                   libssh2
argyll-cms                               libsvm
armadillo                                libswiften
arpack                                   libtorrent-rasterbar
artifactory                              libtrace
asciidoctor                              libuninameslist
asciidoctorj                             libuv
asdf                                     libvirt
ask-cli                                  libvirt-glib
aspectj                                  libwpd
astrometry-net                           libwpg
atari800                                 libxc
atk                                      libxlsxwriter
atkmm                                    libxml++
atlassian-cli                            libxml++3
atomist-cli                              libxo
audacious                                libzdb
auditbeat                                lighttpd
augeas                                   lilv
autorest                                 linkerd
avra                                     lldpd
avro-c                                   llvm
avro-cpp                                 lmod
avro-tools                               logstash
awf                                      logtalk
aws-okta                                 loudmouth
aws-sdk-cpp                              lsd
awscli                                   luarocks
axel                                     lv2
azure-cli                                lwtools
azure-storage-cpp                        lxc
b2-tools                                 lynis
babel                                    lysp
babl                                     lzip
badtouch                                 mackup
balena-cli                               macvim
ballerina                                mafft
baobab                                   magic-wormhole
bartycrouch                              mailutils
basex                                    mame
bat                                      mariadb
bazel                                    mariadb-connector-c
beanstalkd                               mariadb@10.1
bear                                     mariadb@10.2
bedops                                   mat2
bee                                      math-comp
bettercap                                maxima
bgpstream                                maxwell
binaryen                                 mbedtls
bind                                     mcabber
binwalk                                  mdbook
bison                                    mdbtools
bit                                      mdds
bitcoin                                  mdk
bitlbee                                  mednafen
bitrise                                  megatools
bitwarden-cli                            memcached
blink1                                   mercurial
bluepill                                 mesa
bookloupe                                meson
boost                                    mesos
boost-bcp                                metaproxy
boost-build                              metricbeat
boost-mpi                                mgba
boost-python                             micronaut
boost-python3                            micropython
bowtie2                                  midgard2
braid                                    midnight-commander
buildifier                               mighttpd2
buildkit                                 mikutter
buku                                     mill
bundletool                               minbif
bwfmetaedit                              minimal-racket
byobu                                    minio
byteman                                  minio-mc
bzip2                                    minizinc
bzt                                      mk-configure
cadaver                                  mkl-dnn
caffe                                    mksh
cairo                                    mkvtoolnix
calcurse                                 mlkit
calicoctl                                mlt
camlp4                                   mmark
cargo-completion                         mmseqs2
cataclysm                                molecule
catimg                                   monero
cattle                                   monetdb
cc65                                     mongo-c-driver
ccache                                   mongoose
ccextractor                              mono-libgdiplus
ccls                                     mosquitto
center-im                                mp3splt
certbot                                  mpck
cf4ocl                                   mpd
cfengine                                 mpdscribble
cfn-lint                                 mpich
cfr-decompiler                           mplayer
cgal                                     mpop
cgit                                     mruby
cglm                                     msgpack
cgrep                                    msitools
chafa                                    msktutil
chakra                                   msmtp
chamber                                  mtools
charm                                    mu
checkbashisms                            mujs
checkstyle                               mupdf
chicken                                  mupdf-tools
chrome-export                            mutt
chronograf                               mvnvm
circleci                                 mysql
citus                                    mysql@5.7
clang-format                             mysqltuner
cloc                                     n
clojure                                  nano
clozure-cl                               nanopb-generator
clutter                                  nativefier
clutter-gst                              nats-streaming-server
clutter-gtk                              nave
cmake                                    ncdc
cmark-gfm                                ncmpc
cmocka                                   ncmpcpp
cockroach                                nco
cocoapods                                ndpi
cogl                                     needle
cointop                                  neo4j
collectd                                 neomutt
commandbox                               neovim
composer                                 netcdf
conan                                    netdata
conserver                                nethack
consul                                   netpbm
convox                                   newsboat
coq                                      newt
corectl                                  nexus
corsixth                                 nghttp2
cp2k                                     nginx
cpansearch                               nifi-registry
cppad                                    nim
cppcheck                                 nlopt
cpprestsdk                               nnn
cql                                      node
cracklib                                 node-build
crc32c                                   node@10
cromwell                                 node_exporter
crosstool-ng                             nodenv
crowdin                                  nomad
cryfs                                    nordugrid-arc
cryptol                                  noti
crystal                                  notmuch
csound                                   nss
cucumber-cpp                             ntfs-3g
curl                                     ntl
curl-openssl                             numpy
curlftpfs                                nwchem
cutter                                   nzbget
cython                                   ocaml-num
dartsim                                  ocrmypdf
datetime-fortran                         octave
dav1d                                    odpi
davix                                    ola
dbus-glib                                ompl
dc3dd                                    oniguruma
dcd                                      opa
dcm2niix                                 open-mpi
dehydrated                               openapi-generator
dep                                      openblas
dependency-check                         opencascade
desktop-file-utils                       opencc
dfc                                      opencoarrays
dfmt                                     openconnect
dhall                                    opencv
dhall-json                               opencv@3
diff-pdf                                 openfortivpn
diff-so-fancy                            openh264
diffoscope                               openimageio
digdag                                   openshift-cli
dita-ot                                  openslide
django-completion                        openssl@1.1
dmd                                      opensubdiv
dnscontrol                               openvdb
dnscrypt-proxy                           operator-sdk
dnstwist                                 orbit
docfx                                    orc-tools
docker                                   osc
docker-completion                        oscats
docker-compose                           osm-gps-map
docker-compose-completion                osm2pgrouting
docker-credential-helper                 osmosis
docker-machine-driver-xhyve              ospray
doctl                                    osquery
dopewars                                 osrm-backend
double-conversion                        owfs
dovecot                                  oxipng
druid                                    p11-kit
dscanner                                 packer
dspdfviewer                              packmol
dub                                      paket
duc                                      pam-u2f
duck                                     pandoc
dungeon                                  pandoc-crossref
duo_unix                                 pango
dwdiff                                   pangomm
dynare                                   paperkey
e2fsprogs                                paps
easy-tag                                 parallel
easyengine                               parallelstl
eccodes                                  pari
efl                                      passenger
eiffelstudio                             patchelf
elasticsearch                            payara
elasticsearch@5.6                        pcapplusplus
elixir                                   pcb
embree                                   pcb2gcode
emscripten                               pdal
encfs                                    pdf2htmlex
enchant                                  pdf2svg
enigma                                   pdfpc
enscript                                 pdftoipe
envconsul                                pdns
epubcheck                                pdnsrec
erlang@19                                peg-markdown
erlang@20                                percona-xtrabackup
eslint                                   perl
etcd                                     peru
etl                                      petsc
ettercap                                 petsc-complex
evince                                   pgbadger
exiftool                                 pgcli
exiv2                                    pgformatter
expat                                    pgplot
exploitdb                                pgrouting
eye-d3                                   phoronix-test-suite
f3                                       php
faas-cli                                 php-cs-fixer
fastme                                   php@7.1
faudio                                   php@7.2
fceux                                    phpmyadmin
ffmpeg                                   phpstan
ffsend                                   phpunit
fftw                                     physfs
fibjs                                    picard-tools
file-formula                             picat
fio                                      pick
firebase-cli                             pidgin
flatbuffers                              pilosa
flex                                     pinboard-notes-backup
flintrock                                pinfo
flow                                     pioneers
fluid-synth                              planck
fluxctl                                  plantuml
fn                                       plplot
fobis                                    plzip
folly                                    pmd
fontforge                                pms
fonttools                                pngquant
fourstore                                pod2man
fq                                       podofo
freeciv                                  ponyc
freedink                                 poppler
freeradius-server                        postgresql
freetds                                  postgresql@10
freetype                                 postgresql@9.4
frpc                                     postgresql@9.5
frps                                     postgresql@9.6
frugal                                   postgrest
fs-uae                                   pqiv
fselect                                  pre-commit
fuse-emulator                            prefixsuffix
fuseki                                   presto
futhark                                  prettier
gabedit                                  profanity
gammu                                    proguard
gandi.cli                                proj
gauge                                    prometheus
gawk                                     protobuf-c
gbdfed                                   protoc-gen-go
gcab                                     prototool
gcc                                      pstoedit
gcsfuse                                  pulumi
gdal                                     pumba
gdb                                      pure-ftpd
gdcm                                     pushpin
gdk-pixbuf                               py2cairo
gdl                                      pybind11
gdmap                                    pyenv
gearsystem                               pygobject
gecode                                   pygobject3
geeqie                                   pygtk
gegl                                     pygtkglext
gel                                      pygtksourceview
genact                                   pypy
gengetopt                                pypy3
genometools                              pyside
geoipupdate                              qalculate-gtk
geos                                     qbs
gerbv                                    qca
gexiv2                                   qd
ghex                                     qemu
ghostscript                              qmmp
ghq                                      qpdf
ghr                                      qrupdate
gibo                                     qt
git-cinnabar                             quantlib
git-cola                                 quazip
git-flow-avh                             quicktype
git-fresh                                quilt
git-ftp                                  qwt
git-quick-stats                          r
git-recent                               radare2
git-remote-hg                            rancid
git-review                               range-v3
git-secret                               raylib
git-town                                 rbspy
gitg                                     rclone
gitlab-runner                            rdesktop
gitleaks                                 rdup
gitless                                  re2
gjs                                      readline
gkrellm                                  reattach-to-user-namespace
glade                                    rebar3
glances                                  recode
glib                                     recon-ng
glib-networking                          recoverjpeg
glibmm                                   redis
glooctl                                  redo
glslang                                  redshift
glyr                                     remind
gmic                                     reposurgeon
gmime                                    reprepro
gmsh                                     restview
gmt                                      rhino
gnome-autoar                             riemann
gnome-builder                            riff
gnome-latex                              rke
gnome-recipes                            rmlint
gnome-themes-standard                    rocksdb
gnu-getopt                               roll
gnu-indent                               rom-tools
gnu-typist                               root
gnu-units                                roswell
gnumeric                                 rpm
gnunet                                   rrdtool
gnupg                                    rsyslog
gnuplot                                  rt-audio
gnuradio                                 rtags
gnutls                                   rtmidi
go                                       rtv
goaccess                                 ruby-build
gobby                                    rust
gobject-introspection                    rustup-init
gobuster                                 s-search
godep                                    sassc
goffice                                  saxon
golang-migrate                           sbcl
gollum                                   scala
golo                                     scalapack
gom                                      scalariform
gomplate                                 sccache
goocanvas                                sceptre
goofys                                   schismtracker
google-authenticator-libpam              scipy
google-benchmark                         scmpuff
googler                                  scons
gor                                      scrcpy
goreleaser                               scrollkeeper
gosu                                     sd
gpa                                      sdb
gpac                                     sdcc
gpgme                                    sdcv
gpredict                                 sdl2_ttf
gpsbabel                                 sec
gpsim                                    serd
gqview                                   serf
gr-osmosdr                               serve
gradio                                   serverless
gradle                                   sfcgal
grafana                                  shadowsocks-libev
grails                                   shared-mime-info
grakn                                    shc
graph-tool                               shfmt
graphviz                                 ship
grib-api                                 shogun
gromacs                                  shpotify
groovy                                   shyaml
groovysdk                                silk
grpc                                     simple-scan
grpcurl                                  simple-tiles
grsync                                   sipp
gsmartcontrol                            sipsak
gspell                                   siril
gssdp                                    sk
gst-editing-services                     skaffold
gst-libav                                skktools
gst-plugins-bad                          skopeo
gst-plugins-base                         sleepwatcher
gst-plugins-good                         sleuthkit
gst-plugins-ugly                         smali
gst-python                               smimesign
gst-rtsp-server                          sn0int
gst-validate                             snownews
gstreamer                                socat
gstreamermm                              sofia-sip
gtk+                                     solr
gtk+3                                    solr@7.7
gtk-chtheme                              sonar-scanner
gtk-doc                                  sonarqube
gtk-gnutella                             sonobuoy
gtk-mac-integration                      sops
gtk-vnc                                  source-highlight
gtkdatabox                               source-to-image
gtkextra                                 sourcekitten
gtkglext                                 sourcery
gtkmm                                    spades
gtkmm3                                   sparse
gtksourceview                            sphinx-doc
gtksourceview3                           spice-protocol
gtksourceview4                           spin
gtksourceviewmm                          spirv-cross
gtksourceviewmm3                         sqlcipher
gtkspell3                                sqlmap
gts                                      sratom
gucharmap                                srt
guile                                    sshfs
gupnp                                    sshtrix
gupnp-av                                 sslh
gupnp-tools                              sslscan
gwenhywfar                               sslsplit
gwyddion                                 stellar-core
gx                                       step
gxml                                     stk
h3                                       stout
hadolint                                 streamripper
hamlib                                   strongswan
hana                                     stunnel
hapi-fhir-cli                            subversion
harfbuzz                                 suil
haskell-stack                            suite-sparse
hbase                                    sundials
hdf5                                     superlu
hdf5@1.8                                 supervisor
hebcal                                   swagger-codegen
heimdal                                  swagger-codegen@2
helmfile                                 swi-prolog
herrie                                   swift-protobuf
hexyl                                    swiftformat
hfstospell                               swiftlint
highlight                                swig
hlint                                    swimat
homeassistant-cli                        sylpheed
homebank                                 sync_gateway
httping                                  syncthing
hub                                      synfig
hugo                                     sysbench
hunspell                                 talloc
hydra                                    taskell
hyperfine                                tass64
hyperkit                                 tbb
hypre                                    tcsh
i2pd                                     tdlib
iamy                                     teleconsole
ibex                                     telegraf
icecream                                 teleport
imagemagick                              template-glib
imagemagick@6                            tepl
imageoptim-cli                           terraform
imake                                    terraforming
imapsync                                 terragrunt
influxdb                                 terrahub
inlets                                   testssl
interactive-rebase-tool                  texmath
ios-webkit-debug-proxy                   tfenv
iperf3                                   thefuck
ipfs                                     tiger-vnc
ipython                                  tika
irssi                                    tile38
ispc                                     tippecanoe
istioctl                                 tkdiff
itk                                      tmux
ivykis                                   tmux-xpanes
jadx                                     tmuxinator-completion
jboss-forge                              tokei
jdnssec-tools                            tomcat
jdupes                                   tomcat@7
jena                                     tomcat@8
jenkins                                  tomee-plus
jenkins-job-builder                      tomee-webprofile
jenkins-lts                              topgrade
jfrog-cli-go                             tor
jhipster                                 torsocks
jigdo                                    tox
jmxterm                                  traefik
jnettop                                  trafficserver
joplin                                   translate-shell
jsdoc3                                   travis
json-fortran                             treefrog
json-glib                                trezor-agent
jsonnet                                  triton
jsonschema2pojo                          ttyd
juju                                     tundra
just                                     txr
jvgrep                                   typescript
kafka                                    u-boot-tools
kahip                                    ucloud
kallisto                                 ufraw
kapacitor                                uhd
khal                                     unbound
kibana                                   uncrustify
kitchen-sync                             ungit
klavaro                                  unp64
knot                                     unrar
kobalt                                   unzip
kops                                     upscaledb
kotlin                                   urdfdom_headers
ktlint                                   userspace-rcu
kubecfg                                  utf8proc
kubeless                                 util-linux
kubeprod                                 utimer
kubernetes-cli                           uwsgi
kubernetes-helm                          v8
kubernetes-service-catalog-client        vagrant-completion
kustomize                                vala
kyoto-cabinet                            valabind
kyoto-tycoon                             vamp-plugin-sdk
lablgtk                                  vault
lammps                                   vault-cli
landscaper                               vcdimager
lapack                                   vegeta
lasi                                     velero
lasso                                    verilator
laszip                                   vert.x
latex2html                               vfuse
latexml                                  vice
lazygit                                  viewvc
lbdb                                     vim
lcdf-typetools                           vim@7.4
ldapvi                                   vips
ldc                                      visp
ledger                                   volt
lego                                     vowpal-wabbit
lensfun                                  vte
leveldb                                  vte3
lf                                       vulkan-headers
lgogdownloader                           vultr
libb2                                    wabt
libbitcoin                               wandio
libbitcoin-blockchain                    wartremover
libbitcoin-client                        watchexec
libbitcoin-database                      wdfs
libbitcoin-explorer                      wdiff
libbitcoin-network                       webdis
libbitcoin-node                          webpack
libbitcoin-protocol                      websocat
libbitcoin-server                        websocketd
libbluray                                webtorrent-cli
libcddb                                  weechat
libcdio                                  wesnoth
libcdr                                   wget
libchamplain                             whois
libcoap                                  widelands
libcroco                                 wildfly-as
libdap                                   wimlib
libdazzle                                wine
libdc1394                                winetricks
libebml                                  wiredtiger
libedit                                  wireguard-go
liberasurecode                           wireguard-tools
libestr                                  wiremock-standalone
libetonyek                               wireshark
libev                                    wla-dx
libevent                                 wmctrl
libfabric                                wp-cli
libfixbuf                                wp-cli-completion
libgaiagraphics                          wtf
libgda                                   wv
libgdata                                 wxmaxima
libgee                                   wxpython
libgeotiff                               xboard
libgit2                                  xcodegen
libglade                                 xctool
libglademm                               xmake
libgnomecanvas                           xmrig
libgnomecanvasmm                         xonsh
libgsf                                   xpdf
libgtop                                  xplanet
libgweather                              xsane
libhttpseverywhere                       xsimd
libical                                  yaf
libiconv                                 yamllint
libidl                                   yara
libidn2                                  yarn
libimagequant                            yash
libinfinity                              yelp-tools
libiptcdata                              ykman
libjson-rpc-cpp                          ykpers
libjwt                                   yle-dl
liblas                                   you-get
liblinear                                youtube-dl
liblqr                                   yq
libltc                                   yubico-piv-tool
liblunar                                 z3
libmagic                                 zenity
libmatroska                              zim
libmp3splt                               zimg
libmpd                                   zlog
libmpdclient                             zola
libmtp                                   zsh-autosuggestions
libmwaw                                  zshdb
libmypaint                               zurl
==> Renamed Formulae
gnatsd -> nats-server
==> Deleted Formulae
compose2kube        guile@2.0           scala@2.10          whirr
dsd                 js-test-driver      swig@3.04           xmoto
erlang@18           minisat             tomcat@6
gtk-engines         node@6              typesafe-activator
gtk-murrine-engine  rlvm                varnish@4

==> Installing dependencies for mysql: openssl
==> Installing mysql dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2s.high_sierra.
==> Downloading from https://akamai.bintray.com/b7/b72b8d9e582713d909936d7236542
######################################################################## 100.0%
==> Pouring openssl-1.0.2s.high_sierra.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

openssl is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.

If you need to have openssl first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

For compilers to find openssl you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl/include"

==> Summary
?  /usr/local/Cellar/openssl/1.0.2s: 1,795 files, 12.1MB
==> Installing mysql
==> Downloading https://homebrew.bintray.com/bottles/mysql-8.0.16.high_sierra.bo
==> Downloading from https://akamai.bintray.com/cd/cd3e3fcba5c6c4bd74a0dfd2fc464
######################################################################## 100.0%
==> Pouring mysql-8.0.16.high_sierra.bottle.tar.gz
==> /usr/local/Cellar/mysql/8.0.16/bin/mysqld --initialize-insecure --user=zhang
==> Caveats
We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -uroot

To have launchd start mysql now and restart at login:
  brew services start mysql
Or, if you don't want/need a background service you can just run:
  mysql.server start
==> Summary
?  /usr/local/Cellar/mysql/8.0.16: 275 files, 272.7MB
==> `brew cleanup` has not been run in 30 days, running now...
Removing: /Users/zhangjingyi/Library/Caches/Homebrew/erlang--21.3.6.high_sierra.bottle.tar.gz... (76.1MB)
Removing: /usr/local/Cellar/openssl/1.0.2r... (1,795 files, 12.1MB)
Removing: /Users/zhangjingyi/Library/Caches/Homebrew/openssl--1.0.2r.high_sierra.bottle.tar.gz... (3.7MB)
Removing: /Users/zhangjingyi/Library/Caches/Homebrew/rabbitmq--3.7.14.tar.xz... (9MB)
Removing: /Users/zhangjingyi/Library/Logs/Homebrew/libtiff... (64B)
Removing: /Users/zhangjingyi/Library/Logs/Homebrew/wxmac... (64B)
Removing: /Users/zhangjingyi/Library/Logs/Homebrew/libpng... (64B)
Removing: /Users/zhangjingyi/Library/Logs/Homebrew/erlang... (64B)
Removing: /Users/zhangjingyi/Library/Logs/Homebrew/rabbitmq... (2 files, 312B)
Removing: /Users/zhangjingyi/Library/Logs/Homebrew/jpeg... (64B)
Removing: /Users/zhangjingyi/Library/Logs/Homebrew/openssl... (64B)
Pruned 0 symbolic links and 2 directories from /usr/local
==> Caveats
==> openssl
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

openssl is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.

If you need to have openssl first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

For compilers to find openssl you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl/include"

==> mysql
We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -uroot

To have launchd start mysql now and restart at login:
  brew services start mysql
Or, if you don't want/need a background service you can just run:
  mysql.server start
  • 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
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 333
  • 334
  • 335
  • 336
  • 337
  • 338
  • 339
  • 340
  • 341
  • 342
  • 343
  • 344
  • 345
  • 346
  • 347
  • 348
  • 349
  • 350
  • 351
  • 352
  • 353
  • 354
  • 355
  • 356
  • 357
  • 358
  • 359
  • 360
  • 361
  • 362
  • 363
  • 364
  • 365
  • 366
  • 367
  • 368
  • 369
  • 370
  • 371
  • 372
  • 373
  • 374
  • 375
  • 376
  • 377
  • 378
  • 379
  • 380
  • 381
  • 382
  • 383
  • 384
  • 385
  • 386
  • 387
  • 388
  • 389
  • 390
  • 391
  • 392
  • 393
  • 394
  • 395
  • 396
  • 397
  • 398
  • 399
  • 400
  • 401
  • 402
  • 403
  • 404
  • 405
  • 406
  • 407
  • 408
  • 409
  • 410
  • 411
  • 412
  • 413
  • 414
  • 415
  • 416
  • 417
  • 418
  • 419
  • 420
  • 421
  • 422
  • 423
  • 424
  • 425
  • 426
  • 427
  • 428
  • 429
  • 430
  • 431
  • 432
  • 433
  • 434
  • 435
  • 436
  • 437
  • 438
  • 439
  • 440
  • 441
  • 442
  • 443
  • 444
  • 445
  • 446
  • 447
  • 448
  • 449
  • 450
  • 451
  • 452
  • 453
  • 454
  • 455
  • 456
  • 457
  • 458
  • 459
  • 460
  • 461
  • 462
  • 463
  • 464
  • 465
  • 466
  • 467
  • 468
  • 469
  • 470
  • 471
  • 472
  • 473
  • 474
  • 475
  • 476
  • 477
  • 478
  • 479
  • 480
  • 481
  • 482
  • 483
  • 484
  • 485
  • 486
  • 487
  • 488
  • 489
  • 490
  • 491
  • 492
  • 493
  • 494
  • 495
  • 496
  • 497
  • 498
  • 499
  • 500
  • 501
  • 502
  • 503
  • 504
  • 505
  • 506
  • 507
  • 508
  • 509
  • 510
  • 511
  • 512
  • 513
  • 514
  • 515
  • 516
  • 517
  • 518
  • 519
  • 520
  • 521
  • 522
  • 523
  • 524
  • 525
  • 526
  • 527
  • 528
  • 529
  • 530
  • 531
  • 532
  • 533
  • 534
  • 535
  • 536
  • 537
  • 538
  • 539
  • 540
  • 541
  • 542
  • 543
  • 544
  • 545
  • 546
  • 547
  • 548
  • 549
  • 550
  • 551
  • 552
  • 553
  • 554
  • 555
  • 556
  • 557
  • 558
  • 559
  • 560
  • 561
  • 562
  • 563
  • 564
  • 565
  • 566
  • 567
  • 568
  • 569
  • 570
  • 571
  • 572
  • 573
  • 574
  • 575
  • 576
  • 577
  • 578
  • 579
  • 580
  • 581
  • 582
  • 583
  • 584
  • 585
  • 586
  • 587
  • 588
  • 589
  • 590
  • 591
  • 592
  • 593
  • 594
  • 595
  • 596
  • 597
  • 598
  • 599
  • 600
  • 601
  • 602
  • 603
  • 604
  • 605
  • 606
  • 607
  • 608
  • 609
  • 610
  • 611
  • 612
  • 613
  • 614
  • 615
  • 616
  • 617
  • 618
  • 619
  • 620
  • 621
  • 622
  • 623
  • 624
  • 625
  • 626
  • 627
  • 628
  • 629
  • 630
  • 631
  • 632
  • 633
  • 634
  • 635
  • 636
  • 637
  • 638
  • 639
  • 640
  • 641
  • 642
  • 643
  • 644
  • 645
  • 646
  • 647
  • 648
  • 649
  • 650
  • 651
  • 652
  • 653
  • 654
  • 655
  • 656
  • 657
  • 658
  • 659
  • 660
  • 661
  • 662
  • 663
  • 664
  • 665
  • 666
  • 667
  • 668
  • 669
  • 670
  • 671
  • 672
  • 673
  • 674
  • 675
  • 676
  • 677
  • 678
  • 679
  • 680
  • 681
  • 682
  • 683
  • 684
  • 685
  • 686
  • 687
  • 688
  • 689
  • 690
  • 691
  • 692
  • 693
  • 694
  • 695
  • 696
  • 697
  • 698
  • 699
  • 700
  • 701
  • 702
  • 703
  • 704
  • 705
  • 706
  • 707
  • 708
  • 709
  • 710
  • 711
  • 712
  • 713
  • 714
  • 715
  • 716
  • 717
  • 718
  • 719
  • 720
  • 721
  • 722
  • 723
  • 724
  • 725
  • 726
  • 727
  • 728
  • 729
  • 730
  • 731
  • 732
  • 733
  • 734
  • 735
  • 736
  • 737
  • 738
  • 739
  • 740
  • 741
  • 742
  • 743
  • 744
  • 745
  • 746
  • 747
  • 748
  • 749
  • 750
  • 751
  • 752
  • 753
  • 754
  • 755
  • 756
  • 757
  • 758
  • 759
  • 760
  • 761
  • 762
  • 763
  • 764
  • 765
  • 766
  • 767
  • 768
  • 769
  • 770
  • 771
  • 772
  • 773
  • 774
  • 775
  • 776
  • 777
  • 778
  • 779
  • 780
  • 781
  • 782

3.启动MySQL

先根据提示进行配置,执行命令:
在这里插入图片描述

然后启动MySQL

zhangjingyideMacBook-Pro:bin zhangjingyi$ mysql.server start 
Starting MySQL
..
 SUCCESS! 
  • 1
  • 2
  • 3
  • 4

4.设置密码

zhangjingyideMacBook-Pro:bin zhangjingyi$ mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0
Please set the password for root here.

New password: 

Re-enter new password: 

Estimated strength of the password: 25 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
 ... Failed! Error: Your password does not satisfy the current policy requirements

New password: 

Re-enter new password: 

Estimated strength of the password: 50 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n

 ... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : n

 ... skipping.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done! 
  • 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
  • 69
  • 70

5.遇到问题

Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
  • 1

原因:没有启动MySQL就去初始化密码了,需要先运行MySQL

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

闽ICP备14008679号