質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

Laravel 5

Laravel 5は、PHPフレームワークLaravelの最新バージョンで、2014年11月に発表予定です。ディレクトリ構造がが現行版より大幅に変更されるほか、メソッドインジェクションやFormRequestの利用が可能になります。

Q&A

2回答

3931閲覧

MySQLに変更したポートでアクセスできなかった???

Chandler_Bing

総合スコア673

MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

Laravel 5

Laravel 5は、PHPフレームワークLaravelの最新バージョンで、2014年11月に発表予定です。ディレクトリ構造がが現行版より大幅に変更されるほか、メソッドインジェクションやFormRequestの利用が可能になります。

0グッド

0クリップ

投稿2019/12/04 06:52

編集2019/12/04 07:12

現在laravelからMySQLに接続しようとしています。

env

1DB_CONNECTION=mysql 2DB_HOST=localhost 3DB_PORT=3307 4DB_DATABASE=laravel_login 5DB_USERNAME=root 6DB_PASSWORD=root

ポート番号を3307にしていたせいで以下のエラーが出ておりました。

cmd

1C:\xampp\htdocs\sample>mysql -u root -p 2Enter password: **** 3Welcome to the MySQL monitor. Commands end with ; or \g. 4Your MySQL connection id is 343 5Server version: 5.7.26-log MySQL Community Server (GPL) 6 7Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. 8 9Oracle is a registered trademark of Oracle Corporation and/or its 10affiliates. Other names may be trademarks of their respective 11owners. 12 13Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 14 15mysql> show databases; 16+--------------------+ 17| Database | 18+--------------------+ 19| information_schema | 20| laravel_login | 21| mysql | 22| performance_schema | 23| sys | 24+--------------------+ 255 rows in set (0.00 sec) 26 27mysql>

しかし、ポートは3307に変更しています。
イメージ説明

以下DBのiniファイルです。(一部抜粋)

# # This is for a system with little memory (<= 64M) where MySQL is only used # from time to time and it's important that the mysqld daemon # doesn't use much resources. # # You can copy this file to # C:/xampp/mysql/bin/my.cnf to set global options, # mysql-data-dir/my.cnf to set server-specific options (in this # installation this directory is C:/xampp/mysql/data) or # ~/.my.cnf to set user-specific options. # # In this file, you can use all long options that a program supports. # If you want to know which options a program supports, run the program # with the "--help" option. # The following options will be passed to all MySQL clients [client] # password = your_password port=3306//ここ?? socket="C:/xampp/mysql/mysql.sock" # Here follows entries for some specific programs # The MySQL server default-character-set=utf8mb4 [mysqld] port=3307//ここ? socket="C:/xampp/mysql/mysql.sock" basedir="C:/xampp/mysql" tmpdir="C:/xampp/tmp" datadir="C:/xampp/mysql/data" pid_file="mysql.pid" # enable-named-pipe key_buffer=16M max_allowed_packet=1M sort_buffer_size=512K net_buffer_length=8K read_buffer_size=256K read_rnd_buffer_size=512K myisam_sort_buffer_size=8M log_error="mysql_error.log" # Change here for bind listening # bind-address="127.0.0.1" # bind-address = ::1 # for ipv6 # Where do all the plugins live plugin_dir="C:/xampp/mysql/lib/plugin/" # Don't listen on a TCP/IP port at all. This can be a security enhancement, # if all processes that need to connect to mysqld run on the same host. # All interaction with mysqld must be made via Unix sockets or named pipes. # Note that using this option without enabling named pipes on Windows # (via the "enable-named-pipe" option) will render mysqld useless! # # commented in by lampp security #skip-networking #skip-federated # Replication Master Server (default) # binary logging is required for replication # log-bin deactivated by default since XAMPP 1.4.11 #log-bin=mysql-bin # required unique id between 1 and 2^32 - 1 # defaults to 1 if master-host is not set # but will not function as a master if omitted server-id =1 # Replication Slave (comment out master section to use this) # # To configure this host as a replication slave, you can choose between # two methods : # # 1) Use the CHANGE MASTER TO command (fully described in our manual) - # the syntax is: # # CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>, # MASTER_USER=<user>, MASTER_PASSWORD=<password> ; # # where you replace <host>, <user>, <password> by quoted strings and # <port> by the master's port number (3306 by default). # # OR # # 2) Set the variables below. However, in case you choose this method, then # start replication for the first time (even unsuccessfully, for example # if you mistyped the password in master-password and the slave fails to # connect), the slave will create a master.info file, and any later # change in this file to the variables' values below will be ignored and # overridden by the content of the master.info file, unless you shutdown # the slave server, delete master.info and restart the slaver server. # For that reason, you may want to leave the lines below untouched # (commented) and instead use CHANGE MASTER TO (see above) # # required unique id between 2 and 2^32 - 1 # (and different from the master) # defaults to 2 if master-host is set # but will not function as a slave if omitted #server-id = 2 # # The replication master for this slave - required #master-host = <hostname> # # The username the slave will use for authentication when connecting # to the master - required #master-user = <username> # # The password the slave will authenticate with when connecting to # the master - required #master-password = <password> # # The port the master is listening on. # optional - defaults to 3306 #master-port = <port> # # binary logging - not required for slaves, but recommended #log-bin=mysql-bin コード

見て分かる通り、いくつかport=3306になっており表面的には3307に代わっても実際には3306だったということですか??
以前ここ?としている「3307」の部分が「3306」であるのが原因でMySQLが立ち上がらなかったので「3307」に変更したという経緯があります。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

お疲れ様です。ポートは「3307」に変更済みです。

これをみておいおいって思ったので回答します。

本当にLaravel の .env に設定した値が正しいなら、下記のコマンドを実行してログインできるかを確認してください。

bash

1mysql -h localhost -u root -P 3307 -D laravel_login -p

投稿2019/12/04 07:05

退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2019/12/04 07:14

言われたことやってから追加の質問してください。
m.ts10806

2019/12/04 07:27

明後日の方向で自己解決しそうだから、やはり放置しましょう。昨日の自分すら別人の仕業の人ですから。
guest

0

MySQLのデフォルトポートは3306だと思うのですが、ポート番号あってますか?

投稿2019/12/04 06:58

peperoncino000

総合スコア148

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

Chandler_Bing

2019/12/04 06:58

お疲れ様です。ポートは「3307」に変更済みです。
Chandler_Bing

2019/12/04 07:01

お疲れ様です。「ポートは3307」に変更しており、ZAMPPを立ち上げた際にも3307になっているのに 3306に変更したら上手くいきました。が、その内容について質問します。 ありがとうございます。
m.ts10806

2019/12/04 07:28 編集

ZAMPPなんてものは存在しません。 少なくともPHP界隈には。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問