One - One Code All

Blog Content

mac升级mysql数据库到mysql8.0

MySQL Linux-Mac   2019-08-18 23:56:40

升级mysql到8.0


具体更新流程:

1. 导出数据,export_mysql_data.py

2. 停止mysql数据库: brew services stop mysql

3. 杀死多余进程:ps -ax | grep mysql

4. 拷贝数据文件做备份:sudo cp -r  /usr/local/var/mysql/* ./

5. 查看安装的数据库 brew info mysql




brew info mysql

mysql: stable 8.0.15 (bottled)

Open source relational database management system

https://dev.mysql.com/doc/refman/8.0/en/

Conflicts with:

  mariadb (because mysql, mariadb, and percona install the same binaries.)

  mariadb-connector-c (because both install plugins)

  mysql-cluster (because mysql, mariadb, and percona install the same binaries.)

  mysql-connector-c (because both install MySQL client libraries)

  percona-server (because mysql, mariadb, and percona install the same binaries.)

/usr/local/Cellar/mysql/5.7.20 (324 files, 233.7MB) *

  Poured from bottle on 2017-12-26 at 11:56:24

From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/mysql.rb

==> Dependencies

Build: cmake ✘

Required: openssl ✘

==> Requirements

Required: macOS >= 10.10 ✔

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

==> Analytics

install: 72,984 (30 days), 193,829 (90 days), 801,624 (365 days)

install_on_request: 67,938 (30 days), 182,339 (90 days), 746,443 (365 days)

build_error: 0 (30 days)


6. 查看最新的数据库版本


7. 删除mysql

$ brew remove mysql

Uninstalling /usr/local/Cellar/mysql/5.7.20... (324 files, 233.7MB)


$ brew cleanup

Warning: Skipping boost: most recent version 1.69.0 not installed

Warning: Skipping cmake: most recent version 3.14.0 not installed

Warning: Skipping erlang: most recent version 21.3.2 not installed

Warning: Skipping erlang@20: most recent version 20.3.8.20 not installed

Warning: Skipping freetype: most recent version 2.10.0 not installed

Warning: Skipping gcc: most recent version 8.3.0 not installed

Warning: Skipping gearman: most recent version 1.1.18_1 not installed

Warning: Skipping geoip: most recent version 1.6.12 not installed

Warning: Skipping graphicsmagick: most recent version 1.3.31 not installed

Warning: Skipping hdf5: most recent version 1.10.5 not installed

Warning: Skipping imagemagick: most recent version 7.0.8-35 not installed

Warning: Skipping libidn2: most recent version 2.1.1a not installed

Warning: Skipping libpng: most recent version 1.6.36 not installed

Warning: Skipping libressl: most recent version 2.8.3 not installed

Warning: Skipping libtiff: most recent version 4.0.10_1 not installed

Warning: Skipping libunistring: most recent version 0.9.10 not installed

Warning: Skipping llvm: most recent version 8.0.0 not installed

Warning: Skipping mercurial: most recent version 4.9.1 not installed

Warning: Skipping mpfr: most recent version 4.0.2 not installed

Warning: Skipping nginx: most recent version 1.15.10 not installed

Warning: Skipping ninja: most recent version 1.9.0 not installed

Warning: Skipping open-mpi: most recent version 4.0.0 not installed

Warning: Skipping openblas: most recent version 0.3.5 not installed

Warning: Skipping openssl: most recent version 1.0.2r not installed

Warning: Skipping openssl@1.1: most recent version 1.1.1b not installed

Warning: Skipping pcre: most recent version 8.43 not installed

Warning: Skipping python@2: most recent version 2.7.16 not installed

Warning: Skipping rabbitmq: most recent version 3.7.12 not installed

Warning: Skipping redis: most recent version 5.0.4 not installed

Warning: Skipping source-highlight: most recent version 3.1.8_11 not installed

Warning: Skipping sphinx-doc: most recent version 1.8.5 not installed

Warning: Skipping sqlite: most recent version 3.27.2 not installed

Warning: Skipping tmux: most recent version 2.8 not installed

Warning: Skipping watch: most recent version 3.3.15 not installed

Warning: Skipping wget: most recent version 1.20.1_4 not installed

Warning: Skipping zsh-completions: most recent version 0.30.0 not installed


8. 查看数据文件是否还在

ls /usr/local/var/mysql/

$ ls /usr/local/bin/mysql

ls: /usr/local/bin/mysql: No such file or directory

$ ls /usr/local/Cellar/mysql/

ls: /usr/local/Cellar/mysql/: No such file or directory


9. 查看brew源的mysql版本:https://github.com/Homebrew/homebrew-core/blob/master/Formula/mysql.rb

10. 重新安装mysql: brew install mysql


==> Installing dependencies for mysql: openssl

==> Installing mysql dependency: openssl

==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2s.mojave.bottle.tar.gz

==> Downloading from https://akamai.bintray.com/c4/c4a762d719c2be74ac686f1aafabb32f3c5d5ff3a9893

######################################################################## 100.0%

==> Pouring openssl-1.0.2s.mojave.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"


For pkg-config to find openssl you may need to set:

  export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"


==> Summary

????  /usr/local/Cellar/openssl/1.0.2s: 1,795 files, 12.0MB

==> Installing mysql

==> Downloading https://homebrew.bintray.com/bottles/mysql-8.0.17.mojave.bottle.tar.gz

==> Downloading from https://akamai.bintray.com/10/10cf5cf9a3d69d003df6d3e199077c86355a23bfbcec4

                                                                           0.3%

curl: (56) LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54

Error: Failed to download resource "mysql"

Download failed: https://homebrew.bintray.com/bottles/mysql-8.0.17.mojave.bottle.tar.gz

Warning: Bottle installation failed: building from source.

==> Installing dependencies for mysql: cmake

==> Installing mysql dependency: cmake

==> Downloading https://homebrew.bintray.com/bottles/cmake-3.15.2.mojave.bottle.tar.gz

==> Downloading from https://akamai.bintray.com/76/76de3a5828825352b3b05951df73aea22ddd27fe158d4

#########                                                                 12.8%

curl: (56) LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54

Error: Failed to download resource "cmake"

Download failed: https://homebrew.bintray.com/bottles/cmake-3.15.2.mojave.bottle.tar.gz

Warning: Bottle installation failed: building from source.

==> Installing dependencies for cmake: readline, sqlite, python and sphinx-doc

==> Installing cmake dependency: readline

==> Downloading https://homebrew.bintray.com/bottles/readline-8.0.0_1.mojave.bottle.tar.gz

==> Downloading from https://akamai.bintray.com/fa/faab004773e6449dd97971311cb62a9bbaa44f1483b82

######################################################################## 100.0%

==> Pouring readline-8.0.0_1.mojave.bottle.tar.gz

==> Caveats

readline is keg-only, which means it was not symlinked into /usr/local,

because macOS provides the BSD libedit library, which shadows libreadline.

In order to prevent conflicts when programs look for libreadline we are

defaulting this GNU Readline installation to keg-only.


For compilers to find readline you may need to set:

  export LDFLAGS="-L/usr/local/opt/readline/lib"

  export CPPFLAGS="-I/usr/local/opt/readline/include"


For pkg-config to find readline you may need to set:

  export PKG_CONFIG_PATH="/usr/local/opt/readline/lib/pkgconfig"


==> Summary

????  /usr/local/Cellar/readline/8.0.0_1: 48 files, 1.5MB

==> Installing cmake dependency: sqlite

==> Downloading https://homebrew.bintray.com/bottles/sqlite-3.29.0.mojave.bottle.tar.gz

==> Downloading from https://akamai.bintray.com/5f/5f2f8f36a8d13733b0374ac39bdcd32dea10315e7442b

######################################################################## 100.0%

==> Pouring sqlite-3.29.0.mojave.bottle.tar.gz

==> Caveats

sqlite is keg-only, which means it was not symlinked into /usr/local,

because macOS provides an older sqlite3.


If you need to have sqlite first in your PATH run:

  echo 'export PATH="/usr/local/opt/sqlite/bin:$PATH"' >> ~/.bash_profile


For compilers to find sqlite you may need to set:

  export LDFLAGS="-L/usr/local/opt/sqlite/lib"

  export CPPFLAGS="-I/usr/local/opt/sqlite/include"


For pkg-config to find sqlite you may need to set:

  export PKG_CONFIG_PATH="/usr/local/opt/sqlite/lib/pkgconfig"


==> Summary

????  /usr/local/Cellar/sqlite/3.29.0: 11 files, 3.9MB

==> Installing cmake dependency: python

==> Downloading https://homebrew.bintray.com/bottles/python-3.7.4.mojave.bottle.tar.gz

==> Downloading from https://akamai.bintray.com/81/81fc6e5914a16387bd09387ce08e99122ea3ad65c55de

######################################################################## 100.0%

==> Pouring python-3.7.4.mojave.bottle.tar.gz

Error: The `brew link` step did not complete successfully

The formula built, but is not symlinked into /usr/local

Could not symlink bin/2to3

Target /usr/local/bin/2to3

already exists. You may want to remove it:

  rm '/usr/local/bin/2to3'


To force the link and overwrite all conflicting files:

  brew link --overwrite python


To list all files that would be deleted:

  brew link --overwrite --dry-run python


Possible conflicting files are:

/usr/local/bin/2to3 -> /Library/Frameworks/Python.framework/Versions/3.7/bin/2to3

/usr/local/bin/2to3-3.7 -> /Library/Frameworks/Python.framework/Versions/3.7/bin/2to3-3.7

/usr/local/bin/idle3 -> /Library/Frameworks/Python.framework/Versions/3.7/bin/idle3

/usr/local/bin/idle3.7 -> /Library/Frameworks/Python.framework/Versions/3.7/bin/idle3.7

/usr/local/bin/pydoc3 -> /Library/Frameworks/Python.framework/Versions/3.7/bin/pydoc3

/usr/local/bin/pydoc3.7 -> /Library/Frameworks/Python.framework/Versions/3.7/bin/pydoc3.7

/usr/local/bin/python3 -> /Library/Frameworks/Python.framework/Versions/3.7/bin/python3

/usr/local/bin/python3-config -> /Library/Frameworks/Python.framework/Versions/3.7/bin/python3-config

/usr/local/bin/python3.7 -> /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7

/usr/local/bin/python3.7-config -> /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7-config

/usr/local/bin/python3.7m -> /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7m

/usr/local/bin/python3.7m-config -> /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7m-config

/usr/local/bin/pyvenv -> /Library/Frameworks/Python.framework/Versions/3.7/bin/pyvenv

/usr/local/bin/pyvenv-3.7 -> /Library/Frameworks/Python.framework/Versions/3.7/bin/pyvenv-3.7

==> /usr/local/Cellar/python/3.7.4/bin/python3 -s setup.py --no-user-cfg install --force --verbo

==> /usr/local/Cellar/python/3.7.4/bin/python3 -s setup.py --no-user-cfg install --force --verbo

==> /usr/local/Cellar/python/3.7.4/bin/python3 -s setup.py --no-user-cfg install --force --verbo

==> Caveats

Python has been installed as

  /usr/local/bin/python3


Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to

`python3`, `python3-config`, `pip3` etc., respectively, have been installed into

  /usr/local/opt/python/libexec/bin


If you need Homebrew's Python 2.7 run

  brew install python@2


You can install Python packages with

  pip3 install

They will install into the site-package directory

  /usr/local/lib/python3.7/site-packages


See: https://docs.brew.sh/Homebrew-and-Python

==> Summary

????  /usr/local/Cellar/python/3.7.4: 3,865 files, 60MB

==> Installing cmake dependency: sphinx-doc

==> Downloading https://homebrew.bintray.com/bottles/sphinx-doc-2.1.2_1.mojave.bottle.tar.gz

==> Downloading from https://akamai.bintray.com/e4/e4bd825fb464c545a58e8e0c8f1b6cea3ec362a77080b

######################################################################## 100.0%

==> Pouring sphinx-doc-2.1.2_1.mojave.bottle.tar.gz

==> Caveats

sphinx-doc is keg-only, which means it was not symlinked into /usr/local,

because this formula is mainly used internally by other formulae.

Users are advised to use `pip` to install sphinx-doc.


If you need to have sphinx-doc first in your PATH run:

  echo 'export PATH="/usr/local/opt/sphinx-doc/bin:$PATH"' >> ~/.bash_profile


==> Summary

????  /usr/local/Cellar/sphinx-doc/2.1.2_1: 3,747 files, 53.4MB

==> Downloading https://github.com/Kitware/CMake/releases/download/v3.15.2/cmake-3.15.2.tar.gz

==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.com/537699/e862

######################################################################## 100.0%

==> ./bootstrap --prefix=/usr/local/Cellar/cmake/3.15.2 --no-system-libs --parallel=8 --datadir=

==> make

==> make install

==> Caveats

Emacs Lisp files have been installed to:

  /usr/local/share/emacs/site-lisp/cmake

==> Summary

????  /usr/local/Cellar/cmake/3.15.2: 5,800 files, 53.2MB, built in 9 minutes 11 seconds

==> Downloading https://cdn.mysql.com/Downloads/MySQL-8.0/mysql-boost-8.0.17.tar.gz

######################################################################## 100.0%

==> cmake . -DCMAKE_C_FLAGS_RELEASE=-DNDEBUG -DCMAKE_CXX_FLAGS_RELEASE=-DNDEBUG -DCMAKE_INSTALL_

==> make

==> make install

==> ./mysql-test-run.pl status --vardir=/private/tmp/d20190818-75590-wc6sma

==> /usr/local/Cellar/mysql/8.0.17/bin/mysqld --initialize-insecure --user=grantbai --basedir=/u

Last 15 lines from /Users/grantbai/Library/Logs/Homebrew/mysql/post_install.01.mysqld:

2019-08-18 20:22:59 +0800


/usr/local/Cellar/mysql/8.0.17/bin/mysqld

--initialize-insecure

--user=grantbai

--basedir=/usr/local/Cellar/mysql/8.0.17

--datadir=/usr/local/var/mysql

--tmpdir=/tmp


mysqld: Can't create/write to file '/usr/local/var/mysql/is_writable' (OS errno 13 - Permission denied)

2019-08-18T12:22:59.069082Z 0 [System] [MY-013169] [Server] /usr/local/Cellar/mysql/8.0.17/bin/mysqld (mysqld 8.0.17) initializing of server in progress as process 95132

2019-08-18T12:22:59.071224Z 0 [ERROR] [MY-010460] [Server] --initialize specified but the data directory exists and is not writable. Aborting.

2019-08-18T12:22:59.071235Z 0 [ERROR] [MY-013236] [Server] The designated data directory /usr/local/var/mysql/ is unusable. You can remove all files that the server added to it.

2019-08-18T12:22:59.071280Z 0 [ERROR] [MY-010119] [Server] Aborting

2019-08-18T12:22:59.071445Z 0 [System] [MY-010910] [Server] /usr/local/Cellar/mysql/8.0.17/bin/mysqld: Shutdown complete (mysqld 8.0.17)  Homebrew.

Warning: The post-install step did not complete successfully

You can try again using `brew postinstall mysql`

==> 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.17: 283 files, 272.5MB, built in 56 minutes 6 seconds

==> 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"


For pkg-config to find openssl you may need to set:

  export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"


==> readline

readline is keg-only, which means it was not symlinked into /usr/local,

because macOS provides the BSD libedit library, which shadows libreadline.

In order to prevent conflicts when programs look for libreadline we are

defaulting this GNU Readline installation to keg-only.


For compilers to find readline you may need to set:

  export LDFLAGS="-L/usr/local/opt/readline/lib"

  export CPPFLAGS="-I/usr/local/opt/readline/include"


For pkg-config to find readline you may need to set:

  export PKG_CONFIG_PATH="/usr/local/opt/readline/lib/pkgconfig"


==> sqlite

sqlite is keg-only, which means it was not symlinked into /usr/local,

because macOS provides an older sqlite3.


If you need to have sqlite first in your PATH run:

  echo 'export PATH="/usr/local/opt/sqlite/bin:$PATH"' >> ~/.bash_profile


For compilers to find sqlite you may need to set:

  export LDFLAGS="-L/usr/local/opt/sqlite/lib"

  export CPPFLAGS="-I/usr/local/opt/sqlite/include"


For pkg-config to find sqlite you may need to set:

  export PKG_CONFIG_PATH="/usr/local/opt/sqlite/lib/pkgconfig"


==> python

Python has been installed as

  /usr/local/bin/python3


Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to

`python3`, `python3-config`, `pip3` etc., respectively, have been installed into

  /usr/local/opt/python/libexec/bin


If you need Homebrew's Python 2.7 run

  brew install python@2


You can install Python packages with

  pip3 install

They will install into the site-package directory

  /usr/local/lib/python3.7/site-packages


See: https://docs.brew.sh/Homebrew-and-Python

==> sphinx-doc

sphinx-doc is keg-only, which means it was not symlinked into /usr/local,

because this formula is mainly used internally by other formulae.

Users are advised to use `pip` to install sphinx-doc.


If you need to have sphinx-doc first in your PATH run:

  echo 'export PATH="/usr/local/opt/sphinx-doc/bin:$PATH"' >> ~/.bash_profile


==> cmake

Emacs Lisp files have been installed to:

  /usr/local/share/emacs/site-lisp/cmake

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

$ Re-enter new password: 

 ... Failed! Error: File './mysql/user.MYD' not found (Errcode: 2 - No such file or directory)



$ ps aux|grep mysql|grep 'my.cnf'

GrantdeMacBook-Pro:bin grantbai$

GrantdeMacBook-Pro:bin grantbai$ mysql --help|grep 'my.cnf'

                      order of preference, my.cnf, $MYSQL_TCP_PORT,

/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf



Re-enter new password: 

 ... Failed! Error: File './mysql/user.MYD' not found (Errcode: 2 - No such file or directory)


这个错误不好解决,只好重新下载dmg安装包直接安装,更简单方便了,重启一下。OK了,可以使用了。



上一篇:php/python/mysql: authentication method unknown to the client [caching_sha2_password] [duplicate]
下一篇:centos卸载软件不要直接运行yum remove

The minute you think of giving up, think of the reason why you held on so long.