最近在了解Python链接数据库操作,想随心所欲的插入删除数据,下了一个mysql的服务,安装完成之后,卡在了第一行命令,不能前进,在网上查了一下之后立刻解决了,记录一下。
-
安装成功mysql服务,安装教程参考:https://www.cnblogs.com/yinzhengjie/p/10125609.html
-
在命令行中进入mysql:
$ mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)
-
凭借自己的英语能力翻译了一下,大概是:没办法链接本地的一个SQL服务。我想了一下,我解决不了
-
于是,将ERROR这一行复制、粘贴、回车,点击比较靠前搜索结果,参阅了人家的方法,参考文档:https://blog.csdn.net/u012373815/article/details/82188361
-
具体解决步骤:
第一步:找到mysql的安装目录,我的是:/usr/local/mysql,不用去mysql底下的bin目录
第二步:执行 sudo ./support-files/mysql.server start
完成以上两步,问题已解决
/usr/local/mysql ? 20:21:58
$ sudo ./support-files/mysql.server start
Starting MySQL
.Logging to ‘/usr/local/mysql/data/bjhldeMacBook-Pro.local.err’.
. SUCCESS!/usr/local/mysql ? 20:22:03
$ 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.23 MySQL Community Server - GPLCopyright © 2000, 2021, Oracle and/or its affiliates.
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>