Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access denied for user 'tracks'@'172.17.0.3' #2843

Open
john2exonets opened this issue Oct 6, 2022 · 7 comments
Open

Access denied for user 'tracks'@'172.17.0.3' #2843

john2exonets opened this issue Oct 6, 2022 · 7 comments
Labels
Documentation All the words.

Comments

@john2exonets
Copy link

Trying to use the Containerized version of Tracks 2.6.1, but getting the "We're sorry, but something went wrong" error when I try to access the app from a browser for the first time. A 'docker logs tracks' dump show the following error:

I, [2022-10-05T23:08:24.718345 #9]  INFO -- : [736d9929-6860-49ca-bb67-fd48592595bc] Started GET "/login" for 172.17.0.1 at 2022-10-05 23:08:24 +0000
I, [2022-10-05T23:08:24.732359 #9]  INFO -- : [736d9929-6860-49ca-bb67-fd48592595bc] Processing by LoginController#login as HTML
I, [2022-10-05T23:08:24.753607 #9]  INFO -- : [736d9929-6860-49ca-bb67-fd48592595bc] Completed 500 Internal Server Error in 21ms (Allocations: 565)
F, [2022-10-05T23:08:24.755115 #9] FATAL -- : [736d9929-6860-49ca-bb67-fd48592595bc]
[736d9929-6860-49ca-bb67-fd48592595bc] Mysql2::Error::ConnectionError (Access denied for user 'tracks'@'172.17.0.3' (using password: YES)):
[736d9929-6860-49ca-bb67-fd48592595bc]
[736d9929-6860-49ca-bb67-fd48592595bc] app/models/user.rb:146:in `no_users_yet?'
[736d9929-6860-49ca-bb67-fd48592595bc] app/controllers/login_controller.rb:25:in `login'

Since Tracks is inside another container, MySQL seems to be having problems with the 'tracks' user. I have tried 'tracks'@'localhost', 'tracks'@'172.17.0.2', & 'tracks'@'172.17.0.3'....none of those seem to work.

What am I doing wrong? I installed my MySQL and Tracks containers using the installation document from this repo.

@ZeiP
Copy link
Member

ZeiP commented Oct 6, 2022

Are you installing using the ”Docker installation using a separate container” instructions? If so, you're probably right – the SQL user needs to be created allowing all hosts to connect! The correct SQL query for creating the user would be
mysql> GRANT ALL PRIVILEGES ON tracks.* TO yourmysqluser@'%' IDENTIFIED BY 'password-goes-here' WITH GRANT OPTION;

@ZeiP ZeiP closed this as completed in 3fd631a Oct 6, 2022
@ZeiP ZeiP added the Documentation All the words. label Oct 6, 2022
@john2exonets
Copy link
Author

This doesn't work.....still get the same error!!

MariaDB [mysql]> select * from user where user = 'tracks';
+------+--------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+---------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+-----------------------+-------------------------------------------+------------------+---------+--------------+--------------------+
| Host | User   | Password                                  | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Show_db_priv | Super_priv | Create_tmp_table_priv | Lock_tables_priv | Execute_priv | Repl_slave_priv | Repl_client_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Create_user_priv | Event_priv | Trigger_priv | Create_tablespace_priv | Delete_history_priv | ssl_type | ssl_cipher | x509_issuer | x509_subject | max_questions | max_updates | max_connections | max_user_connections | plugin                | authentication_string                     | password_expired | is_role | default_role | max_statement_time |
+------+--------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+---------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+-----------------------+-------------------------------------------+------------------+---------+--------------+--------------------+
| %    | tracks | *192075E51AD8FAB8349335869018443202C4232E | N           | N           | N           | N           | N           | N         | N           | N             | N            | N         | N          | N               | N          | N          | N            | N          | N                     | N                | N            | N               | N                | N                | N              | N                   | N                  | N                | N          | N            | N                      | N                   |          |            |             |              |             0 |           0 |               0 |                    0 | mysql_native_password | *192075E51AD8FAB8349335869018443202C4232E | N                | N       |              |           0.000000 |
+------+--------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+---------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+-----------------------+-------------------------------------------+------------------+---------+--------------+--------------------+
1 row in set (0.001 sec)
PS C:\Users\john\ToDo\MYSQL> docker logs tracks
=> Booting Puma
=> Rails 6.0.5.1 application starting in production
=> Run `rails server --help` for more startup options
Puma starting in single mode...
* Puma version: 5.6.4 (ruby 2.7.6-p219) ("Birdie's Version")
*  Min threads: 5
*  Max threads: 5
*  Environment: production
*          PID: 9
* Listening on http://0.0.0.0:3000
Use Ctrl-C to stop
I, [2022-10-07T01:41:58.770060 #9]  INFO -- : [640f8f9c-7080-4ef3-a719-fea75fc65c6d] Started GET "/" for 172.17.0.1 at 2022-10-07 01:41:58 +0000
I, [2022-10-07T01:41:58.771701 #9]  INFO -- : [640f8f9c-7080-4ef3-a719-fea75fc65c6d] Processing by TodosController#index as HTML
I, [2022-10-07T01:41:58.773994 #9]  INFO -- : [640f8f9c-7080-4ef3-a719-fea75fc65c6d] Redirected to http://localhost:3000/login
I, [2022-10-07T01:41:58.774158 #9]  INFO -- : [640f8f9c-7080-4ef3-a719-fea75fc65c6d] Filter chain halted as :login_or_feed_token_required rendered or redirected
I, [2022-10-07T01:41:58.774400 #9]  INFO -- : [640f8f9c-7080-4ef3-a719-fea75fc65c6d] Completed 302 Found in 2ms (Allocations: 681)
I, [2022-10-07T01:41:58.777375 #9]  INFO -- : [5a167e05-20f9-4f24-8b94-a10b4cc3b6be] Started GET "/login" for 172.17.0.1 at 2022-10-07 01:41:58 +0000
I, [2022-10-07T01:41:58.777813 #9]  INFO -- : [5a167e05-20f9-4f24-8b94-a10b4cc3b6be] Processing by LoginController#login as HTML
I, [2022-10-07T01:41:58.779397 #9]  INFO -- : [5a167e05-20f9-4f24-8b94-a10b4cc3b6be] Completed 500 Internal Server Error in 2ms (Allocations: 878)
F, [2022-10-07T01:41:58.779809 #9] FATAL -- : [5a167e05-20f9-4f24-8b94-a10b4cc3b6be]
[5a167e05-20f9-4f24-8b94-a10b4cc3b6be] Mysql2::Error::ConnectionError (Access denied for user 'tracks'@'172.17.0.3' (using password: YES)):
[5a167e05-20f9-4f24-8b94-a10b4cc3b6be]
[5a167e05-20f9-4f24-8b94-a10b4cc3b6be] app/models/user.rb:146:in `no_users_yet?'
[5a167e05-20f9-4f24-8b94-a10b4cc3b6be] app/controllers/login_controller.rb:25:in `login'

@ZeiP
Copy link
Member

ZeiP commented Oct 7, 2022

Did you check that logging in directly to the MySQL container works using, for example
docker exec -it mariadb mysql -utracks -p

@ZeiP ZeiP reopened this Oct 7, 2022
@john2exonets
Copy link
Author

I could not find any logs or errors in the Mariadb container:

C:\Users\john\ToDo\MYSQL>docker exec -it tracks-db mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.9.3-MariaDB-1:10.9.3+maria~ubu2204 mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show variables like 'log_error';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_error     |       |
+---------------+-------+
1 row in set (0.005 sec)
PS C:\Users\john\ToDo\MYSQL> docker exec -it tracks-db /bin/bash
root@4decc5c2063f:/# ll /var/log/mysql/
total 8
drwxr-s--- 2 mysql adm  4096 Oct  5 18:21 ./
drwxr-xr-x 1 root  root 4096 Oct  5 18:21 ../
root@4decc5c2063f:/#

@john2exonets
Copy link
Author

Years later, newer version (2.7.1), newer computers, and I STILL get this error:

** Invoke db:reset (first_time)
** Invoke db:drop (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:load_config
** Invoke db:check_protected_environments (first_time)
** Invoke db:load_config
** Execute db:check_protected_environments
rake aborted!
ActiveRecord::ConnectionNotEstablished: Access denied for user 'tracks'@'172.17.0.19' (using password: YES) (ActiveRecord::ConnectionNotEstablished)

@john2exonets
Copy link
Author

john2exonets commented Oct 28, 2024

For anyone else running into this issue, here is how to get around this issue (then you run into the next issue...)

Start you DB container (I used Mariadb)

  1. You have to log into the database container and create the 'tracks' database:
      MariaDB [(none)]> create database tracks;
Query OK, 1 row affected (0.000 sec)
  1. You have to create TWO tracks users; One to do the initial config with, and one for the Tracks container to use:
     MariaDB [(none)]> create user 'tracks'@'%' identified by 'password';  
     MariaDB [(none)]> create user 'tracks'@'172.17.0.9' identified by 'password';

Make sure you have the local IP address of the Tracks container. You can always start the Tracks container, watch it crap out, then grab the DB container logs to see the 'Access denied for user tracks' error to see what the IP address is:

[f72429dd-ba3f-4af8-8507-330f4a59bd82] ActiveRecord::ConnectionNotEstablished (Access denied for user 'tracks'@'172.17.0.9' (using password: YES)):
  1. Run the DB setup;
docker run \
  --link tracks-db:db \
  --rm -t \
  -e "DATABASE_PASSWORD=password" \
  -e "DATABASE_TYPE=mysql2" \
  -e "DATABASE_PORT=3306" \
  tracksapp/tracks:2.7.1 bin/rake db:reset --trace
  1. Start Tracks;
docker run -d -t \
  -p 8003:3000 \
  --name tracks \
  --link tracks-db:db \
  tracksapp/tracks:2.7.1

At this point, Tracks should be running.... However, it still has the problem about only being able to run just once -- no restarts of the container allowed:

=> Booting Puma
=> Rails 6.1.7.8 application starting in production
=> Run `bin/rails server --help` for more startup options
A server is already running. Check /app/tmp/pids/server.pid.
Exiting

This is documented in ticket #2844

@john2exonets
Copy link
Author

Just to add to my last post: Overnight my Tracks container restarted, and I could no longer login. Checked the logs and it was back to "Access denied for user 'tracks'" again :( Killed the container, and modified my Start Tracks script:

docker run -d -t \
  -p 8003:3000 \
  -e DATABASE_USERNAME="tracks" \
  -e DATABASE_PASSWORD="password" \
  --name tracks \
  --link tracks-db:db \
  tracksapp/tracks:2.7.1

That seems to do the trick for surviving restarts ....of course, you STILL have to delete the /app/tmp/pids/server.pid file in order for it to run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation All the words.
Projects
None yet
Development

No branches or pull requests

2 participants