You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.16 MySQL Community Server - GPL
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
mysql>
环境:
mysql Ver 8.0.16 for macos10.14 on x86_64 (MySQL Community Server - GPL)
macOS 10.12.6
一、下载安装 MySQL 8.0.16
参考:
下载 .dmg 安装包,进行包安装,安装过程中全部选择默认即可。
注意:
MySQL 8.0 默认的密码机制是 caching_sha2_password (Strong),这一步不建议选择默认,建议选回 mysql_native_password (Legacy)。
附:
也可以使用包管理器 Homebrew 安装 MySQL (不建议):
二、启动 MySQL 8.0.16
$ cd /usr/local/mysql $ sudo ./bin/mysqld_safe
把 mysql 的安装路径加入到 shell 中
为了在终端(这里是 iTerm2 )使用
mysql
命令,而不用每次都cd
进入 mysql 的安装路径,建议把 mysql 的安装路径加入到 shell 中(注意:这里的 shell 是 oh-my-zsh 而不是默认的 bash ):前往文件夹:
~/.zshrc
添加 MySQL 路径(或vim ~/.zshrc
):执行以下命令测试是否添加路径成功
查看 mysql 版本:
附:使用 alias 添加别名指向相应的 mysql 路径
在 shell 的资源文件中添加别名,以便更容易从命令行访问常用程序,如 mysql 和 mysqladmin ( bash 或 zsh ):
三、连接 MySQL 8.0.16
语法:
在运行着 mysql 的用户名为 root 的本机电脑上连接 mysql:
四、卸载 MySQL 8.0.16
参考:
打开「系统偏好设置」=> 停止 MySQL 服务 => 卸载 MySQL => 再逐条执行以下命令(因为上一步卸载 MySQL 时已经自动删除了一些文件,所以执行下面命令时可能会提示找不到文件)。
To uninstall MySQL and completely remove it (including all databases) from your Mac do the following:
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*
The text was updated successfully, but these errors were encountered: