現在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>
以下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」に変更したという経緯があります。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/12/04 07:12
退会済みユーザー
2019/12/04 07:14
2019/12/04 07:27