-
Notifications
You must be signed in to change notification settings - Fork 1
Troubleshooting
This line attempts to configure a datajoint database using an existing docker-image. To diagnose the issue, try the following steps:
-
sudo docker-compose ps
if nothing is returned, then the issue is likely with docker-compose. Make sure the install is correct and that the config files are in the expected places.
Depending on the error, a couple things could be wrong. Most commonly, the issue is that mysql is not running in the background and thus can't be logged into.
- most likely, this is an issue with the path.
- try:
export PATH=${PATH}:/usr/local/mysql/bin
- re-run the original line. if the error is gone, add the above line to your
./bash-profile
.
- if the path is not the issue, make sure that MySQL is properly installed.
Note: if on Linux, proceed. if on macOS, exact commands may differ.
Fix: https://www.tecmint.com/fix-error-2003-hy000-cant-connect-to-mysql-server-on-127-0-0-1-111/
Summary:
-
If
ps -Af | grep mysqld
only returns an entry with the user name and not withmysql
, similar to:al 18214 18159 0 13:01 pts/4 00:00:00 grep mysqld
then mysql is not running and needs to be started.
for Linux, try running:
sudo systemctl start mysql.service
and/orsudo service mysqld start
- If either of these return:
Failed to start mysqld.service: Unit mysqld.service not found.
, refer here.
for macOS with Homebrew, try running:
brew services start mysql@5.7
- If either of these return:
-
Check again by running
ps -Af | grep mysqld
Output should now look something like:mysql 18365 1 30 13:04 ? 00:00:01 /usr/libexec/mysqld --basedir=/usr
al 18410 18159 0 13:04 pts/4 00:00:00 grep mysqld
-
Get the port information for where mysql is running by:
sudo netstat -lnp | grep mysql
(default is 3306) -
Try logging into mysql again using that port:
mysql -h 127.0.0.1 -u root -P <port>
(replacing with the number given in the previous step)
If should now be possible to run the MySQL server from Terminal and within a Jupyter notebook.
This can occur from running mysql -h 127.0.0.1 -u root -P 3306
or mysql -h 127.0.0.1 -u root
, or from logging into the database from Jupyter without it being completely configured.
Fix:
- In a new terminal, try running the mysql command with an additional argument forcing the password prompt:
mysql -h 127.0.0.1 -u root -p
- The terminal should request a password entry:
Enter password:
If you have not yet reconfigured your password nor have altered the docker-compose.yaml file, the password will besimple
Note: it is important to change this password once you are running a stable database. For information on how to do so within the DataJoint framework, go here. - If everything worked, then you will enter the MySQL monitor and now have access to the MySQL server.
Try:
sudo mysql -u root
mysql> USE mysql;
mysql> CREATE USER 'YOUR_SYSTEM_USER'@'localhost' IDENTIFIED BY '';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'YOUR_SYSTEM_USER'@'localhost';
mysql> UPDATE user SET plugin='auth_socket' WHERE User='YOUR_SYSTEM_USER';
mysql> FLUSH PRIVILEGES;
mysql> exit;
-
service mysql restart
$ service mysql restart
if output of brew postinstall mysql@5.7
includes Warning: The post-install step did not complete successfully.
:
This may be caused by competing installs of MySQL.
For possible solutions, refer here.
Likely, a new update for MySQL has been released, or some part of your original MySQL build was incomplete/incorrect.
For Ubuntu, try:
-
sudo apt-get update
, followed by, -
sudo apt-get install mysql-server
-
Restart MySQL:
sudo systemctl start mysql.service
-
Then run
ps -Af | grep mysqld
. The output should resemble:mysql 7186 1 2 12:34 ? 00:00:00 /usr/sbin/mysqld
al 10799 5963 0 12:35 pts/2 00:00:00 grep --color=auto mysqld
As of writing (Jan 2024), DataJoint has not updated to Python versions > 3.9 (here). This may lead to the above error when trying to connect using datajoint.conn()
.
Try downgrading the Python version to ≥3.7, ≤3.9, or create a new virtual environment with an appropriate Python version.