今天继续学习Python爬虫,爬虫的学习过程的确不是一帆风顺,总能遇到这样那样的问题,还好遇到的问题都逐一解决,当然收获也很多。今天学习ORM框架,这个概念其实第一次接触,(ORM:Object/Relation Mapping,对象-关系映射)。通过这个框架来操作数据库,ORM系统一般以中间件的形式存在,主要实现程序对象到关系数据库数据的映射。话不多说,今天的问题是mysql5.7启动时出现的错误。
MacBookAir:~ root# /usr/local/opt/mysql@5.7/bin/mysql.server start
Starting MySQL
... ERROR! The server quit without updating PID file (/usr/local/var/mysql/MacBookAir.lan.pid).
Mac系统通过brew安装mysql5.7后,启动报错的解决办法
根据以上报错提示,没有更新PID文件(/usr/local/var/mysql/MacBookAir.lan.pid),进行一些操作处理,还是没有解决。我决定重新安装mysql5.7,这次根据提示我按步骤进行操作,提示如下:
liuxiaowei@MacBookAir ~ % brew install mysql@5.7
==> Downloading https://ghcr.io/v2/homebrew/core/mysql/5.7/manifests/5.7.36
Already downloaded: /Users/liuxiaowei/Library/Caches/Homebrew/downloads/3bd8201ca705f862e6a7e4c71ec30e87f77b9372889bd10d37989ac9edf694b1--mysql@5.7-5.7.36.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/mysql/5.7/blobs/sha256:5289b664
Already downloaded: /Users/liuxiaowei/Library/Caches/Homebrew/downloads/e6da9b8d37c53e90332bc6c290ce514b6913c16310d45cad80490b191d45c903--mysql@5.7--5.7.36.monterey.bottle.tar.gz
==> Pouring mysql@5.7--5.7.36.monterey.bottle.tar.gz
==> 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
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"
To restart mysql@5.7 after an upgrade:
brew services restart mysql@5.7
Or, if you don't want/need a background service you can just run:
/usr/local/opt/mysql@5.7/bin/mysqld_safe --datadir=/usr/local/var/mysql
==> Summary
🍺 /usr/local/Cellar/mysql@5.7/5.7.36: 320 files, 234.3MB
==> Running `brew cleanup mysql@5.7`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
根据提示,首先要运行mysql_secure_installation,
MacBookAir:bin root# ./mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
出现报错,错误提示,不能通过socket连接本地服务器,在临时文件夹下mysql.sock,通过查找资料,在国外网站https://stackoverflow.com/questions/ 找到了同样的问题和解决办法。
MacBookAir:~ root# chown -R _mysql:mysql /usr/local/var/mysql
MacBookAir:bin root# ./mysql.server start
Starting MySQL
. SUCCESS!
于是根据这个办法进行操作,👌!问题解决!也特意记录下来此次的解决问题过程,加深记忆。希望对遇到我同样的问题的人有所帮助。欢迎收藏、点赞、分享。