最新消息:20210917 已从crifan.com换到crifan.org

【已解决】Mac中Sequel连接本地Mysql出错:Unable to connect to host 127.0.0.1 or the request timed out

Mac crifan 9418浏览 0评论

折腾:

【已解决】Mac本地搭建mysql数据库并导入已备份出的sql文件

期间,mac本地已经通过dmg安装好了mysql了。

而且命令行中也是可以正常登录的。

但是去用Sequel Pro去尝试连接,结果出错:

“Connection failed!

Unable to connect to host 127.0.0.1, or the request timed out.

Be sure that the address is correct and that you have the necessary privileges, or try increasing the connection timeout (currently 10 seconds).

MySQL said: Your password has expired. To log in you must change it using a client that supports expired passwords.”

mac Unable to connect to host 127.0.0.1, or the request timed out.

mac Sequel Unable to connect to host 127.0.0.1, or the request timed out.

Sequel PRO connection error · Issue #2908 · sequelpro/sequelpro

本地mysql的server没有运行

去运行

Unable to connect to host 127.0.0.1, or the request timed out. · Issue #1418 · sequelpro/sequelpro

php – mysql running but cannot connect to 127.0.0.1 – Stack Overflow

Sometimes: Unable to connect to host 127.0.0.1, or the request timed out. MySQL through Sequel PRO

<code>➜  ~ ps -ef | grep mysql
    0 22063 21758   0 11:40上午 ttys008    0:00.07 sudo mysql -u root
    0 22067 22063   0 11:40上午 ttys008    0:00.04 mysql -u root
    0 21662 20742   0 11:39上午 ttys009    0:00.05 sudo mysqld_safe --skip-grant-tables
    0 21663 21662   0 11:39上午 ttys009    0:00.03 /bin/sh /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
   74 21733 21663   0 11:39上午 ttys009    0:02.21 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --skip-grant-tables --log-error=promote.cache-dns.local.err --pid-file=promote.cache-dns.local.pid
  501 22192 20742   0 11:43上午 ttys009    0:00.03 mysql -u root
  501 23117 20742   0 11:59上午 ttys009    0:00.04 mysql -u root
  501 23167 20742   0 12:00下午 ttys009    0:00.01 mysql -u root -p
  501 23199 20742   0 12:01下午 ttys009    0:00.02 mysql -u root -px
  501 26703 20742   0  1:35下午 ttys009    0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn mysql
</code>

mac mysql server 运行

Mac命令行启动MySQL – 简书

“Linux下的MySQL使用非常方便, Mac相对来讲并不是说不方便, 可能更多的是不熟悉, 毕竟Mac主要是通过dmg安装的. 一般情况我们可能会在设置里面去启动或停止MySQL, 但有些时候我们有需要命令去启动.

sudo /usr/local/mysql/support-files/mysql.server start

sudo /usr/local/mysql/support-files/mysql.server stop

sudo /usr/local/mysql/support-files/mysql.server restart”

去试试

<code>➜  ~ sudo /usr/local/mysql/support-files/mysql.server status
Password:
SUCCESS! MySQL running (21733)
➜  ~ sudo /usr/local/mysql/support-files/mysql.server restart
Shutting down MySQL
... SUCCESS!
Starting MySQL
. SUCCESS!
</code>

好像没有问题啊。

结果还是出错:

MySQL for Mac 安装和基本操作_木木_新浪博客

mac下启动/停止/重启mysql服务 – CSDN博客

mac上用终端启动和关闭mysql服务 – CSDN博客

mac sequel Unable to connect to host 127.0.0.1, or the request timed out

sequelpro – Can’t connect to MySQL server on (ip or domain name) – Stack Overflow

Your password has expired. To log in you must change it using a client that supports expired passwords.

mac sequel Your password has expired. To log in you must change it using a client that supports expired passwords.

mysql5.7密码过期ERROR 1862 (HY000): Your password has expired. To log in you must change-去吧奥特曼-51CTO博客

去改为不过期

MAC安装MySQL后进不去 – 简书

php – Mysql password expired. Can’t connect – Stack Overflow

“Your password has expired” after restart mysql when updated mysql 5.7.8-rc(debian) – Database Administrators Stack Exchange

<code>➜  ~ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.22

Copyright (c) 2000, 2018, 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&gt; update user set password_expired='N' where user='root';
ERROR 1046 (3D000): No database selected
mysql&gt; use mysql;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql&gt; SET PASSWORD = PASSWORD('crifan_mysql');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql&gt; update user set password_expired='N' where user='root';
ERROR 1046 (3D000): No database selected
mysql&gt; use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql&gt; update user set password_expired='N' where user='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0

mysql&gt; flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql&gt; quit
Bye
</code>

然后再去sequel试试

就可以连接成功了:

可以进去了:

【总结】

此处在Mac中,虽然之前用mysql的命令行把安装时的临时密码修改过了,且终端中也可以用:

<code>mysql -u root -p
</code>

再输入密码,而进去mysql了。

但是此处工具Sequel Pro中,却无法连接:

  • host:127.0.0.1

  • user:root

  • password:xxx

  • port:3306

而提示:

Unable to connect to host 127.0.0.1, or the request timed out

而再去找具体提示中的原因是:

Your password has expired. To log in you must change it using a client that supports expired passwords.

而具体解决办法是:

再去终端中进去mysql:

<code>mysql -u root -p
</code>

然后去(先选择对应的mysql数据库后,才能)设置密码:

<code>use mysql;
</code>

会提示你:

“ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.”

然后去设置新密码:

<code>SET PASSWORD = PASSWORD('crifan_mysql');
</code>

再去设置密码不过期:

<code>use mysql;
update user set password_expired='N' where user='root’;
</code>

最后记得保存/同步/更新后再退出:

<code>flush privileges;
quit
</code>

即可。

然后Sequel Pro就可以用新密码去连接了。

转载请注明:在路上 » 【已解决】Mac中Sequel连接本地Mysql出错:Unable to connect to host 127.0.0.1 or the request timed out

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
99 queries in 0.201 seconds, using 23.33MB memory