I'm trying to connect to mysql database running in docker which is invoked by tutor:
tutor dev launch
which generates the config.yml file below
CMS_HOST: studio.local.overhang.io
CMS_OAUTH2_SECRET: ue5LfJvi7LyJ5d0kN1mKwXWH
CONTACT_EMAIL: contact#local.overhang.io
ENABLE_HTTPS: false
ID: e7t5Qli0r4Ue4qePDDKP3yHb
JWT_RSA_PRIVATE_KEY: '-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEA5CGyUuSGEoUkgeRQpjpQyZmhPY7YtVIdsNzGaYGjC3XJC3ZT
3BhQTR0M4xrEXONDueODk5ReRwDRMtWmuJo57gDnK0yQ+3mNiCB5Vzuz7q90tMWb
oTsX9wcvOCOqlWXvW/BKaNpB872pRo7yPA2BBmsAZuA0lOf42oyhEep/LgHk9XQr
LHD5l6y6uWIsxMorCmw19pn987RgyHcs0ewFOY6M/ftnnMFus0b+tc3t3x6llfRe
/WTvEEC1MFjSGnawXDWU6b14RJYgBX6owHUZr3yUY8ROcklIGYferWbG3K8JwRui
RyboorrwGfGUcFpKgkLwFJq4k+ut6Fgxmf1I9QIDAQABAoIBAE7ZxsUX769fDatH
uwh5h4rm6vBX+1dQtqp25K16/Vvsrjyj/YBJdxfwPpAQpGZmtvX9SXEtCxkHk0c6
yZFs3TECZuR0ZnhFH0I51zbrj9mkE3aYBp7HyhS8CvogecmBniXs/AsZxUn1+BhH
ODrBgCMzwMPOIt6E/2Kq0NFcd/DyV3TI1SPZZAoZRJMf12nxsCOrJ10z+4z27wvw
cVHkxfeizo1bLdaSDzOSDswh2QZf02dO9ByeaGyOeKr2QMaxGqIwunwxE6WNYRG2
hVNIFyWs/bSmnjTQ3K1mKh5r0XRPmOzVQUoqFnUpeA1N9APMby2aRa/qzflcnP1z
PIpQRVECgYEA50yrFQn0HdECID8u3pBQWhOth2Q/cZM9LsK5ebTEq7/k1Qz26xFR
89HBUOb9+vakjYS9mU6xEGTtDdo2k/i9hdK2kZS2UA+P5x05uo6L1frVJpt/0ROi
3u0BLb2K23tWM2hlGG/NWLwbp4Jn6VIq6hSxRa9qRHx11AYULy65RTsCgYEA/H5s
qgpGKSyLm3eqCEBlz9GA2fcUVdkXcxYQ6L8luUL0jfGKWYkhkg2VYj6NtZtNGB9K
n8J5aDJeZhahxWBnAyu/Jv0yvLkxucyQEr77dHZzCtqG6OuoP1VFAz/8plmDuTqr
+0TYW2zt4fGQnX2+sLxNDSUgkJ1UmSvQFFkhB48CgYA6aATHgkTvhoi35dyK/Pwd
Uty91JWks15+wVMepYQILqO1HNn5D92W6P+c00eNKNzyk3NhFBroHeQyXEjt4qDQ
+x1484l5/AQFgz7Bmh87gGR0pE2JWSEGk+h5SWSX+bQRtSnaGtlKr+13xhlBNKt7
gpAlHZ+C/b6vNH3CUFUeYwKBgDCDWf2R28ktdeV5KIJNXUKAznESuCWGgKrsInOV
xnnCE5ryPdLWNk0JrxohSrkKDdYErSHlC86pXtnen1Z9H03Mqf2jyIvaSWOZmlT/
vPCzkYcUVbeLD9ibWZc2RCTyLgz46PJuV+O5Gju/XjnkXy81/tf3ujoPAKIteN1w
ApihAoGAcz+xo1VYxZXZzxID0hS2ikLWBcnThcjYN6dsKB7mh1P+EBrDFpT3Ozjp
EyzfjcCgQAcWuWooYF85MPq4YE/Dgu1GmzHfKqLXALw2Z7TR5Hl9oZxzRQb2AMKt
eBty8RjunNs2dt9n4l2VrWeIFiNKlR8el/RzXk4ZhcW84KTq7mM=
-----END RSA PRIVATE KEY-----'
LANGUAGE_CODE: en
LMS_HOST: local.overhang.io
MYSQL_ROOT_PASSWORD: 9vXd2uA6
OPENEDX_MYSQL_PASSWORD: esJCvsog
OPENEDX_SECRET_KEY: R6m93ga6apJcYJDjCMSUrPNF
PLATFORM_NAME: My Open edX
PLUGINS:
- mfe
so I'm assuming the user is root and the password is either 9vXd2uA6, esJCvsog, not sure which one, so I wait until the mysql container is up:
================================================
Database creation and migrations
================================================
Initialising all services...
Running init task in mysql
docker-compose -f tutor/tutor-dev/env/local/docker-compose.yml -f tutor/tutor-dev/env/dev/docker-compose.yml -f tutor/tutor-dev/env/dev/docker-compose.tmp.yml --project-name tutor_dev -f tutor/tutor-dev/env/local/docker-compose.jobs.yml -f tutor/tutor-dev/env/dev/docker-compose.jobs.yml -f tutor/tutor-dev/env/dev/docker-compose.jobs.tmp.yml run --rm mysql-job sh -e -c 'echo "Initialising MySQL..."
mysql_connection_max_attempts=10
mysql_connection_attempt=0
until mysql -u root --password="9vXd2uA6" --host "mysql" --port 3306 -e '"'"'exit'"'"'
do
mysql_connection_attempt=$(expr $mysql_connection_attempt + 1)
echo " [$mysql_connection_attempt/$mysql_connection_max_attempts] Waiting for MySQL service (this may take a while)..."
if [ $mysql_connection_attempt -eq $mysql_connection_max_attempts ]
then
echo "MySQL initialisation error" 1>&2
exit 1
fi
sleep 10
done
echo "MySQL is up and running"
# edx-platform database
mysql -u root --password="9vXd2uA6" --host "mysql" --port 3306 -e "CREATE DATABASE IF NOT EXISTS openedx;"
mysql -u root --password="9vXd2uA6" --host "mysql" --port 3306 -e "CREATE USER IF NOT EXISTS '"'"'openedx'"'"';"
mysql -u root --password="9vXd2uA6" --host "mysql" --port 3306 -e "ALTER USER '"'"'openedx'"'"'#'"'"'%'"'"' IDENTIFIED BY '"'"'esJCvsog'"'"';"
mysql -u root --password="9vXd2uA6" --host "mysql" --port 3306 -e "GRANT ALL ON openedx.* TO '"'"'openedx'"'"'#'"'"'%'"'"';"'
[+] Running 1/0
⠿ Container tutor_dev-mysql-1 Running 0.0s
Initialising MySQL...
mysql: [Warning] Using a password on the command line interface can be insecure.
MySQL is up and running
and I try:
% mysql -u root --password="9vXd2uA6" --port 3306 -h mysql
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2005 (HY000): Unknown MySQL server host 'mysql' (8)
and
% mysql -u root --password="9vXd2uA6" --port 3306
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
and
% docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8e4c6ab90f55 openedx-dev:15.2.0 "celery --app=cms.ce…" 5 minutes ago Up 4 minutes 8000/tcp tutor_dev-cms-worker-1
75ed5ee2ef21 openedx-dev:15.2.0 "./manage.py cms run…" 5 minutes ago Up 4 minutes 0.0.0.0:8001->8000/tcp tutor_dev-cms-1
4f94ee5fd720 overhangio/openedx-gradebook-dev:15.0.4 "docker-entrypoint.s…" 5 minutes ago Up 4 minutes 0.0.0.0:1994->1994/tcp tutor_dev-gradebook-1
e28c194381b0 overhangio/openedx-account-dev:15.0.4 "docker-entrypoint.s…" 5 minutes ago Up 4 minutes 0.0.0.0:1997->1997/tcp tutor_dev-account-1
1707bf5263f7 openedx-dev:15.2.0 "celery --app=lms.ce…" 5 minutes ago Up 4 minutes 8000/tcp tutor_dev-lms-worker-1
3a76937f82a1 overhangio/openedx-authn-dev:15.0.4 "docker-entrypoint.s…" 5 minutes ago Up 4 minutes 0.0.0.0:1999->1999/tcp tutor_dev-authn-1
821e6fa12f1f overhangio/openedx-profile-dev:15.0.4 "docker-entrypoint.s…" 5 minutes ago Up 4 minutes 0.0.0.0:1995->1995/tcp tutor_dev-profile-1
30685779c278 overhangio/openedx-course-authoring-dev:15.0.4 "docker-entrypoint.s…" 5 minutes ago Up 4 minutes 0.0.0.0:2001->2001/tcp tutor_dev-course-authoring-1
7657705346b6 overhangio/openedx-learning-dev:15.0.4 "docker-entrypoint.s…" 5 minutes ago Up 4 minutes 0.0.0.0:2000->2000/tcp tutor_dev-learning-1
f3289604200e overhangio/openedx-discussions-dev:15.0.4 "docker-entrypoint.s…" 5 minutes ago Up 4 minutes 0.0.0.0:2002->2002/tcp tutor_dev-discussions-1
0111b9ee8228 openedx-dev:15.2.0 "./manage.py lms run…" 5 minutes ago Up 4 minutes 0.0.0.0:8000->8000/tcp tutor_dev-lms-1
1aa5c71a9e38 mongo:4.2.17 "docker-entrypoint.s…" 5 minutes ago Up 5 minutes 27017/tcp tutor_dev-mongodb-1
d1a62a1e4f39 redis:6.2.6 "docker-entrypoint.s…" 5 minutes ago Up 5 minutes 6379/tcp tutor_dev-redis-1
89ba0c7d746b elasticsearch:7.10.1 "/tini -- /usr/local…" 5 minutes ago Up 5 minutes 9200/tcp, 9300/tcp tutor_dev-elasticsearch-1
7274bb8cc66b mysql:5.7.35 "docker-entrypoint.s…" 5 minutes ago Up 5 minutes 3306/tcp, 33060/tcp tutor_dev-mysql-1
then all the below fails as well:
% docker run -it mysql:5.7.35 bash
root#b862b4a24e28:/# mysql -u root --password="9vXd2uA6" --port 3306
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
root#b862b4a24e28:/# mysql -u root --password="9vXd2uA6" --port 3306^C
root#b862b4a24e28:/# mysql -u root --password="9vXd2uA6" --port 3306 -h mysql
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2005 (HY000): Unknown MySQL server host 'mysql' (22)
root#b862b4a24e28:/# mysql -u root --password="esJCvsog" --port 3306
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Note: If there is a way to run the whole thing entirely outside docker,
pointing to the documentation where this is addressed if one exists /
specifying how to do so, will be greatly appreciated.
In a situation like this, I would suggest starting from the beginning.
Using these commands you can init MySQL again.
tutor dev stop
sudo rm -rf "$(tutor config printroot)/data/mysql"
tutor dev launch
Related
I have setup wordpress with mariadb containers without any issues.
Now I am trying to test wordpress with mysql.
Commands used:
$ docker run --name mysql01 -e MYSQL_ROOT_PASSWORD=Password1234 -d mysql
$ docker run --name wordpress01 --link mysql01 -p 8080:80 -e WORDPRESS_DB_HOST=mysql01:3306 -e WORDPRESS_DB_USER=root -e WORDPRESS_DB_PASSWORD=Password1234 -e WORDPRESS_DB_NAME=wordpress -e WORDPRESS_TABLE_PREFIX=wp_ -d wordpress
status of containers:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e71299679e73 mysql "docker-entrypoint..." 2 minutes ago Up 2 minutes 3306/tcp, 33060/tcp mysql01
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c0a7dd46fb33 wordpress "docker-entrypoint..." 5 minutes ago Exited (1) 4 minutes ago wordpress01
e71299679e73 mysql "docker-entrypoint..." 7 minutes ago Up 7 minutes 3306/tcp, 33060/tcp mysql01
Error Logs:
$ docker logs wordpress01
WordPress not found in /var/www/html - copying now...
Complete! WordPress has been successfully copied to /var/www/html
Warning: mysqli::__construct(): (HY000/2002): Connection refused in Standard input code on line 22
MySQL Connection Error: (2002) Connection refused
Warning: mysqli::__construct(): (HY000/2002): Connection refused in Standard input code on line 22
MySQL Connection Error: (2002) Connection refused
Warning: mysqli::__construct(): (HY000/2002): Connection refused in Standard input code on line 22
MySQL Connection Error: (2002) Connection refused
Warning: mysqli::__construct(): The server requested authentication method unknown to the client [caching_sha2_password] in Standard input code on line 22
Warning: mysqli::__construct(): (HY000/2054): The server requested authentication method unknown to the client in Standard input code on line 22
MySQL Connection Error: (2054) The server requested authentication method unknown to the client
...
WordPress doesn't work by default with MySQL v8 yet as mentioned here. Also, the example in wordpress docker image readme uses MySQL v5.7. Changing mysql version to 5.7 should do the job.
docker run --name mysql01 -e MYSQL_ROOT_PASSWORD=Password1234 -d mysql:5.7
If you need to use mysql:latest docker image, starting mysql with --default-authentication-plugin=mysql_native_password argument should also work as mentioned here.
docker run --name mysql01 -e MYSQL_ROOT_PASSWORD=Password1234 -d mysql --default-authentication-plugin=mysql_native_password
I installed MySQL Server in CentOS 7:
[root#master1 ~]# rpm -qa | grep mysql
mysql-community-release-el7-5.noarch
mysql-community-server-5.6.39-2.el7.x86_64
mysql-community-common-5.6.39-2.el7.x86_64
mysql-community-client-5.6.39-2.el7.x86_64
mysql-community-libs-5.6.39-2.el7.x86_64
Now I need to execute the following commands:
mysql -u root -p welcome123
CREATE USER 'hive'#'localhost' IDENTIFIED BY 'hivepwd';
However, I get the following error:
[root#master1 ~]# mysql -u root -p welcome123
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
I read the recommendations that it's necessary to check my.cnf but I cannot find this file:
[root#master1 ~]# vi /etc/mysql/my.cnf
[root#master1 ~]# cd /etc/mysql/
-bash: cd: /etc/mysql/: No such file or directory
Finally, I tried to reset the password:
[root#master1 ~]# mysqladmin password newpassword
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
I also tried /usr/bin/mysql_secure_installation. It asks me to enter a root password. So, I generated the password, but it's not accepted and provides the above-shown error.
grep 'A temporary password is generated for root#localhost' /var/log/mysqld.log |tail -1
P.S.
I think that MySQL Server is not actually running:
[root#master1 ~]# ps -ef | grep mysql
root 17964 1 0 17:12 ? 00:00:00 /bin/bash /usr/bin/mysql-systemd-start post
root 20359 14673 0 17:17 pts/0 00:00:00 /usr/bin/perl /usr/bin/mysql_secure_installation
root 21799 14673 0 17:21 pts/0 00:00:00 grep --color=auto mysql
Then I re-install it just in case:
[root#master1 ~]# yum install -y mysql-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.uv.es
* extras: mirror.uv.es
* updates: mirror.uv.es
Package mysql-community-server-5.6.39-2.el7.x86_64 already installed and latest version
Nothing to do
When I want to start the service, it lasts forever:
[root#master1 ~]# systemctl start mysqld.service
My XAMPP mysql server is working fine
then I download the separate mysql from oracle and installed it. It is running fine but after some days I cant start it as :> mysql -u root
and in xampp mysql server it is also not working it shows stopped always.
I am providing all the commands that I tried from google as well as StackOverflow
and also I am providing all results of all commands.
Please refer commands before answering.
Number indicates ways that I tried.
1.> `mysql -u root -p`
2.> `mysql -u root`
3.> `sudo su`
3.1.> `ps aux | grep mysql`
3.2.> `kill -9 8306`
4.> `sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start`
5.> `sudo killall mysqld`
6.> Changing content of file as: `innodb_force_recovery = 1` in
`/Applications/XAMPP/xamppfiles/etc/my.cnf`
7.> Changing content of file as: read only permission in
`/Applications/XAMPP/xamppfiles/etc/my.cnf`
8.> Port changed from 3306 to 3307 3308 but nothing is happened
9.> Activity manager : mysql service is. not listed
10.> Reinstalled XAMPP
I followed this 10 ways so please dont answer on this 10 ways
Result of commands :
<.1.
Pratiks-MacBook-Pro:~ pratik$ mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock' (2 "No such file or directory")
<.2.
Pratiks-MacBook-Pro:~ pratik$ mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock' (2 "No such file or directory")
<.3.
Pratiks-MacBook-Pro:~ pratik$ sudo su
Password:
sh-3.2# ps aux | grep mysql
root 8306 0.0 0.0 4258468 180 s000 U+ 11:35AM 0:00.00 grep mysql
sh-3.2# kill -9 8306
sh: kill: (8306) - No such process
sh-3.2#
<.4.
Pratiks-MacBook-Pro:~ pratik$ sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
Starting MySQL
.2018-03-13 11:44:29 8513 mysqld_safe Logging to '/Applications/XAMPP/xamppfiles/var/mysql/Pratiks-MacBook-Pro.local.err'.
2018-03-13 11:44:29 8513 mysqld_safe Starting mysqld daemon with databases from /Applications/XAMPP/xamppfiles/var/mysql
ERROR!
<.5.
Pratiks-MacBook-Pro:~ pratik$ sudo killall mysqld
No matching processes were found
I spin up a docker container for MySQL server
docker run --detach --name=mysql_db_server --env="MYSQL_ROOT_PASSWORD=password" mysql
Then I run another container for phpmyadmin that is linked to MySQL server as follows
docker run --name myadmin -d --link mysql_db_server:mysql -p 8080:80 phpmyadmin/phpmyadmin
I am able to see phpmyadmin on http://localhost:8080 but I am not able to log into it using either
root --- password or
admin --- password
$docker ps -a
output
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
85e68b8bab30 phpmyadmin/phpmyadmin "/run.sh phpmyadmin" 3 hours ago Up 3 hours 0.0.0.0:8080->80/tcp myadmin
b4d130cdb230 mysql "docker-entrypoint.s…" 3 hours ago Up 3 hours 3306/tcp mysql_db_server
What am I doing wrong?
Use myadmin instead of mysql
docker run --name myadmin -d --link mysql_db_server:myadmin -p 8080:80 phpmyadmin/phpmyadmin
Log in to MySQL console with your user:
For that run the command -- docker exec -it app_db_1 /bin/bash
and now you can login to MYSQL console with your user:
root#5f1d313df243:/# mysql -uroot -ppassword
and change the Authentication Plugin with the password here:
mysql> ALTER USER root IDENTIFIED WITH mysql_native_password BY 'PASS';
you will get output something like this -- Query OK, 0 rows affected (0.08 sec)
exit
exit
Read more about the Preferred Authentication Plugin on the MySQL 8.0 Reference Manual
https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password
It will work perfectly with a docker as well as docker-compose:
now you can log in to phpMyAdmin on http://localhost:8080 with root & PASS.
(Don't use port 8080 because it might get a problem when your system already uses 8080 port other processes.)
I use Mac OS X 10.9.
I have mysqld service installed, and listen at 127.0.0.1:3306.
$ netstat -Lan|grep 3306
0/0/80 127.0.0.1.3306
I want to deploy one more mysqld in docker container and will connect here from other containers as well as host machine command line.
Create MySQL container:
docker run --name mysql_1 -e MYSQL_ROOT_PASSWORD=secret -d mysql:latest -p 3306:3306
But I'm unable to connect it from host machine:
$ docker-machine ip default
192.168.99.100
$ docker ps -a|grep mysql
138f33b27756 mysql:latest "docker-entrypoint.sh" About an hour ago Exited (1) About an hour ago
mysql_1
$ mysql -h 192.168.99.100
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.99.100' (61)