Closed dciccale closed 3 years ago
so i tried from the magento installation gui, to use the host defined in the linked container on magento container.
that would be 172.17.0.13:3306
from environments variable inside magento container
MAGENTO_DB_1_PORT_3306_TCP_ADDR=172.17.0.13
MYSQL_PORT_3306_TCP_PORT=3306
but still can't connect to the db
After you start the MySQL server with Docker Compose, can you connect to the MySQL server using other tools, e.g. MySQL workbench? I think maybe the MySQL server is not started correctly.
Same here. I can start a session in the running magento container:
docker exec -ti magentodocker_web_1 bash
Once in, I can use the bundled mysql
to connect:
mysql -h db -u magento -p <ENTER>
(yes, I've modified my docker-compose.yml
to use db
for the database container name.)
It prompts for a password, and I'm in.
Yet, like the OP, I'm getting Database connection error.
on the installation UI.
OK, so it turns out the Magento installation "wizard" doesn't create the "magento" database for you. I fixed this with:
# from the magento container
mysql -h db -u root -p <ENTER>
# enter $MYSQL_ROOT_PASSWORD
Then, in the MySQL prompt:
mysql> CREATE DATABASE IF NOT EXISTS magento;
mysql> GRANT ALL ON magento.* TO 'magento'@'%' IDENTIFIED BY 'magento';
Extra, if you want the sample data (from shell inside Magento container (but I don't recommend running this for the version at the time of this comment, because the installation doesn't complete if you install sample data)):
MYSQL_HOST=db MYSQL_USER=magento MYSQL_PASSWORD=magento MYSQL_DATABASE=magento install-sampledata
YMMY, e.g. MYSQL_HOST=mysql
for the default case.
Here the same error:
vagrant@vagrant:~/docker-magento$ docker exec -it b6b4a5c1d5b5 install-magento
FAILED
ERROR: Database connection error.
logs
vagrant@vagrant:~/docker-magento$ docker logs 9c2a78d516c3
Running mysql_install_db ...
2016-07-22 08:27:13 13 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-07-22 08:27:13 13 [Note] InnoDB: The InnoDB memory heap is disabled
2016-07-22 08:27:13 13 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-07-22 08:27:13 13 [Note] InnoDB: Memory barrier is not used
2016-07-22 08:27:13 13 [Note] InnoDB: Compressed tables use zlib 1.2.7
2016-07-22 08:27:13 13 [Note] InnoDB: Using Linux native AIO
2016-07-22 08:27:13 13 [Note] InnoDB: Using CPU crc32 instructions
2016-07-22 08:27:13 13 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-07-22 08:27:13 13 [Note] InnoDB: Completed initialization of buffer pool
2016-07-22 08:27:13 13 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2016-07-22 08:27:13 13 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2016-07-22 08:27:13 13 [Note] InnoDB: Database physically writes the file full: wait...
2016-07-22 08:27:14 13 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2016-07-22 08:27:14 13 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2016-07-22 08:27:14 13 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2016-07-22 08:27:14 13 [Warning] InnoDB: New log files created, LSN=45781
2016-07-22 08:27:14 13 [Note] InnoDB: Doublewrite buffer not found: creating new
2016-07-22 08:27:14 13 [Note] InnoDB: Doublewrite buffer created
2016-07-22 08:27:14 13 [Note] InnoDB: 128 rollback segment(s) are active.
2016-07-22 08:27:14 13 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-07-22 08:27:14 13 [Note] InnoDB: Foreign key constraint system tables created
2016-07-22 08:27:14 13 [Note] InnoDB: Creating tablespace and datafile system tables.
2016-07-22 08:27:14 13 [Note] InnoDB: Tablespace and datafile system tables created.
2016-07-22 08:27:14 13 [Note] InnoDB: Waiting for purge to start
2016-07-22 08:27:14 13 [Note] InnoDB: 5.6.23 started; log sequence number 0
2016-07-22 08:27:14 13 [Note] Binlog end
2016-07-22 08:27:14 13 [Note] InnoDB: FTS optimize thread exiting.
2016-07-22 08:27:14 13 [Note] InnoDB: Starting shutdown...
2016-07-22 08:27:16 13 [Note] InnoDB: Shutdown completed; log sequence number 1625977
Installing MySQL system tables...OK
2016-07-22 08:27:16 36 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-07-22 08:27:16 36 [Note] InnoDB: The InnoDB memory heap is disabled
2016-07-22 08:27:16 36 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-07-22 08:27:16 36 [Note] InnoDB: Memory barrier is not used
2016-07-22 08:27:16 36 [Note] InnoDB: Compressed tables use zlib 1.2.7
2016-07-22 08:27:16 36 [Note] InnoDB: Using Linux native AIO
2016-07-22 08:27:16 36 [Note] InnoDB: Using CPU crc32 instructions
2016-07-22 08:27:16 36 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-07-22 08:27:16 36 [Note] InnoDB: Completed initialization of buffer pool
2016-07-22 08:27:16 36 [Note] InnoDB: Highest supported file format is Barracuda.
2016-07-22 08:27:16 36 [Note] InnoDB: 128 rollback segment(s) are active.
2016-07-22 08:27:16 36 [Note] InnoDB: Waiting for purge to start
2016-07-22 08:27:16 36 [Note] InnoDB: 5.6.23 started; log sequence number 1625977
2016-07-22 08:27:16 36 [Note] Binlog end
2016-07-22 08:27:16 36 [Note] InnoDB: FTS optimize thread exiting.
2016-07-22 08:27:16 36 [Note] InnoDB: Starting shutdown...
2016-07-22 08:27:18 36 [Note] InnoDB: Shutdown completed; log sequence number 1625987
Filling help tables...OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h 9c2a78d516c3 password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
WARNING: Found existing config file /usr/my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as /usr/my-new.cnf,
please compare it with your file and take the changes you need.
WARNING: Default config file /etc/mysql/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
Finished mysql_install_db
2016-07-22 08:27:18 1 [Note] Plugin 'FEDERATED' is disabled.
2016-07-22 08:27:18 1 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-07-22 08:27:18 1 [Note] InnoDB: The InnoDB memory heap is disabled
2016-07-22 08:27:18 1 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-07-22 08:27:18 1 [Note] InnoDB: Memory barrier is not used
2016-07-22 08:27:18 1 [Note] InnoDB: Compressed tables use zlib 1.2.7
2016-07-22 08:27:18 1 [Note] InnoDB: Using Linux native AIO
2016-07-22 08:27:18 1 [Note] InnoDB: Using CPU crc32 instructions
2016-07-22 08:27:18 1 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-07-22 08:27:18 1 [Note] InnoDB: Completed initialization of buffer pool
2016-07-22 08:27:18 1 [Note] InnoDB: Highest supported file format is Barracuda.
2016-07-22 08:27:18 1 [Note] InnoDB: 128 rollback segment(s) are active.
2016-07-22 08:27:18 1 [Note] InnoDB: Waiting for purge to start
2016-07-22 08:27:19 1 [Note] InnoDB: 5.6.23 started; log sequence number 1625987
2016-07-22 08:27:19 1 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 1ab1bc97-4fe6-11e6-9bdd-0242ac110002.
2016-07-22 08:27:19 1 [Note] Server hostname (bind-address): '*'; port: 3306
2016-07-22 08:27:19 1 [Note] IPv6 is available.
2016-07-22 08:27:19 1 [Note] - '::' resolves to '::';
2016-07-22 08:27:19 1 [Note] Server socket created on IP: '::'.
2016-07-22 08:27:19 1 [Note] Event Scheduler: Loaded 0 events
2016-07-22 08:27:19 1 [Note] Execution of init_file '/tmp/mysql-first-time.sql' started.
2016-07-22 08:27:19 1 [Note] Execution of init_file '/tmp/mysql-first-time.sql' ended.
2016-07-22 08:27:19 1 [Note] mysqld: ready for connections.
Version: '5.6.23' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
Solved. You need to put the internal IP of the docker and root user
I noticed that some versions of MySQL docker images didn't work properly due to MySQL bugs. 5.6.23
is a good version which I used before.
Use docker logs
to check for logs and make sure MySQL is started correctly before installing Magento, or using an external MySQL server.
Solved. You need to put the internal IP of the docker and root user
This works for me.
I used the command 'docker inspect mysqlcontainerid' to get the internal Ip of mysql then modified the variable 'MYSQL_HOST' points to that in the env file.
i am using the default
env
file provided as is.even if i go to magento gui to install, i ca't go further than the Configuration > Database Connection step. I get the error "Database connection error.".
i am missing something?