2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

備忘録)MySQLのlocalhostに接続できないときの対処法の例

Last updated at Posted at 2021-06-27

注釈

 この記事は初投稿であることと共に、自分自身の備忘録として書いているため、他の素晴らしい記事と同じ視点で見ると非常に見苦しいものとなっていると思いますが、ご了承ください。

MySQLでのエラーコード

 MySQL を使って表の定義文の確認をしており、一度シャットダウンした後に、使用しようとしたところ、以下のようなエラーコードが表示されました。

ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost:***' (***)

ローカルホスト上で MySQL サーバが接続できないとエラーを吐いています。

試したこと

以下のサイトを参考にしていたので

そのサイトの
1.MySQLインストール に含まれる ・MySQLをWindowsサービスに登録する からやり直しました。

結論

 Windows のサービスとして登録し、管理者コマンドプロンプトにおいて一度は

NET START MYSQL80

というコマンドを入力して実行したはずなのですが、どういうわけかサービスが停止していました。

そのため、管理者コマンドプロンプトにおいて以下のコマンドを入力すると、

C:\WINDOWS\system32>NET START MYSQL80
The MySQL80 service is starting.
The MySQL80 service was started successfully.

このようにサービスが実行され、さらに

mysql -u root -p

と入力し、インストールした際に設定したパスワードを入力すると、

C:\Users\USERNAME>mysql -u root -p
Enter password: *
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 
Server version: 8.0.25 MySQL Community Server - GPL

Copyright (c) 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>

見事MySQLを起動させることができました。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?