macOS Mojave 降级安装 MySQL 5.7
时间:2023-02-24
浏览:394
作者:佚名
积累知识,胜过积蓄金银!毕竟在##column_title##开发的过程中,会遇到各种各样的问题,往往都是一些细节知识点还没有掌握好而导致的,因此基础知识点的积累是很重要的。下面本文《macOS Mojave 降级安装 MySQL 5.7》,就带大家讲解一下MySQL、MacOS知识点,若是你对本文感兴趣,或者是想搞懂其中某个知识点,就请你继续往下看吧~
macOS Mojave 降级安装 MySQL 5.7
更新历史
2018年12月17日 - 初稿
阅读原文 - https://wsgzao.github.io/post...
扩展阅读
Install MySQL 5.7 on macOS Mojave - https://medium.com/@at0dd/ins...
正常安装
默认新版本是MySQL 8.0
brew update
brew install 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
卸载现有版本
无论是官方dmg还是brew都记得先备份重要数据后再清理
# 正常关闭并删除MySQL mysql.server stop brew services stop mysql brew remove mysql # 无法正常删除MySQL ps -ax | grep mysql stop and kill any MySQL processes brew remove mysql brew cleanup sudo rm /usr/local/mysql sudo rm -rf /usr/local/var/mysql sudo rm -rf /usr/local/mysql*
安装MySQL指定版本
# 安装MySQL 5.7
brew install mysql@5.7
brew link --force mysql@5.7
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
mysql@5.7 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have mysql@5.7 first in your PATH run:
echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc
For compilers to find mysql@5.7 you may need to set:
export LDFLAGS="-L/usr/local/opt/mysql@5.7/lib"
export CPPFLAGS="-I/usr/local/opt/mysql@5.7/include"
For pkg-config to find mysql@5.7 you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/mysql@5.7/lib/pkgconfig"
To have launchd start mysql@5.7 now and restart at login:
brew services start mysql@5.7
Or, if you don't want/need a background service you can just run:
/usr/local/opt/mysql@5.7/bin/mysql.server start
# 开机自启动
brew services restart mysql@5.7
# 设置环境变量
echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc
# 手动启动和关闭
/usr/local/opt/mysql@5.7/bin/mysql.server start
/usr/local/opt/mysql@5.7/bin/mysql.server stop
安装mysqldb
Python中最连接Mysql常用的驱动是:
- mysql-python :mysql的C语言的驱动
- mysql-connector:msql官方的驱动
- pymysql:python语言的驱动
# 使用MySQLdb ,但是提示importerror no module named mysqldb brew install mysql-connector-c pip install mysql-python # 可能会出现以下错误,按照提示做即可 Error: Cannot install mysql because conflicting formulae are installed. mysql-connector-c: because both install MySQL client libraries Please `brew unlink mysql-connector-c` before continuing. Unlinking removes a formula's symlinks from /usr/local. You can link the formula again after the install finishes. You can --force this install, but the build may fail or cause obscure side-effects in the resulting software.
今天带大家了解了MySQL、MacOS的相关知识,希望对你有所帮助;关于数据库的技术知识我们会一点点深入介绍,欢迎大家关注golang学习网公众号,一起学习编程~
本文内容来源于互联网,如有侵权请联系删除。
近期热门
11.18
11.15
站内热门
最新文章
11.27
11.27
11.27
热门专题
