{"id":19721978,"url":"https://github.com/datajoint/mysql-docker","last_synced_at":"2025-04-29T22:30:32.058Z","repository":{"id":47389699,"uuid":"55470774","full_name":"datajoint/mysql-docker","owner":"datajoint","description":"Docker image for MySQL configured to work with DataJoint","archived":false,"fork":false,"pushed_at":"2024-09-03T21:43:27.000Z","size":83,"stargazers_count":18,"open_issues_count":7,"forks_count":18,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-05T19:51:13.050Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/datajoint.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-05T05:40:54.000Z","updated_at":"2023-08-19T02:30:10.000Z","dependencies_parsed_at":"2022-09-13T19:51:14.221Z","dependency_job_id":null,"html_url":"https://github.com/datajoint/mysql-docker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datajoint%2Fmysql-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datajoint%2Fmysql-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datajoint%2Fmysql-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datajoint%2Fmysql-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datajoint","download_url":"https://codeload.github.com/datajoint/mysql-docker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251592897,"owners_count":21614440,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T23:16:08.191Z","updated_at":"2025-04-29T22:30:31.524Z","avatar_url":"https://github.com/datajoint.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"MySQL for DataJoint\n###################\n\nDocker image of MySQL (version 5.7 or 8.0) that comes configured for use with DataJoint!\n\n\nAdministering the MySQL server\n******************************\n\n**WARNING** Whether hosted via Docker or directly on a machine, the MySQL server needs to be administered properly. Please refer to an `appropriate reference \u003chttps://dev.mysql.com/doc/refman/5.7/en/server-administration.html\u003e`_ to administer the server safely and efficiently.\n\nHow to use\n**********\n\nUsing :code:`docker-compose`\n======================\nThe simplest and the recommended way to configure and run a MySQL server with Docker is to use the `Docker compose \u003chttps://docs.docker.com/compose/\u003e`_. Once you have :code:`docker` and :code:`docker-compose` installed on your system (the one on which you'd want to run the MySQL server), copy this `docker-compose.yaml \u003chttps://raw.githubusercontent.com/datajoint/mysql-docker/master/docker-compose.yaml\u003e`_ to a folder, and run :code:`docker-compose up -d` to start the MySQL server. Here is a series of commands to run in the terminal to achieve this:\n\n.. code:: bash\n  \n    mkdir mysql-docker\n    cd mysql-docker\n    wget https://raw.githubusercontent.com/datajoint/mysql-docker/master/docker-compose.yaml\n    docker-compose up -d\n\nThis will start the MySQL server mapped to localhost's port :code:`3306`, and any MySQL data will be stored in the directory :code:`./data`, or if you followed the above instructions, :code:`mysql-docker/data` directory. \n\nBy default the database sets up user :code:`root` with password :code:`simple` (refer to below on how to change this at the startup). You can access your locally running MySQL server using :code:`mysql` client. On Ubuntu system, you can obtain this by installing :code:`apt` package :code:`mysql-client` as follows:\n\n.. code:: bash\n\n    sudo apt-get install mysql-client\n\nOnce :code:`mysql` client is installed, you can access the running server:\n\n.. code:: bash\n\n    mysql -h 127.0.0.1 -u root -p\n    Enter password: [type in your password here: default is \"simple\"]\n\n    mysql \u003e\n\nRead on to find out the details about the content of the :code:`docker-compose.yaml` and how you can customize it to fit your needs.\n\nWhat's in :code:`docker-compose.yaml`?\n===============================\nThe content of the :code:`docker-compose.yaml` is rather simple:\n\n.. code:: yaml\n\n    version: '2.4'\n    services:\n      db:\n        image: datajoint/mysql:5.7 # or datajoint/mysql:8.0\n        ports:\n          - \"3306:3306\"\n        environment:\n          - MYSQL_ROOT_PASSWORD=simple\n          # - DATAJOINT_DATABASE_CONFIG_MONITOR=FALSE\n        volumes:\n          - ./data:/var/lib/mysql\n          # - ./my.cnf:/etc/mysql/my.cnf\n\nLet's step through the parts you might want to customize. The line\n\n.. code:: yaml\n\n    - MYSQL_ROOT_PASSWORD=simple\n\nconfigures the default password. If you would like to use something else, you can modify this prior to starting your server with :code:`docker-compose up`.\n\nThe line:\n\n.. code:: yaml\n\n    # - DATAJOINT_DATABASE_CONFIG_MONITOR=FALSE\n\nhas been commented to indicate that it is optional. It is a DataJoint-unique feature that can be enabled to allow live reloading of the database server if it detects MySQL config changes. The default is ``FALSE`` as it is depicted.\n\nThe lines:\n\n.. code:: yaml\n\n    volumes:\n      - ./data:/var/lib/mysql\n      # - ./my.cnf:/etc/mysql/my.cnf\n\nmaps the local directory :code:`./data` to the :code:`/var/lib/mysql` inside the container where MySQL stores all of its data by default. The next line is commented to indicate that it is optional. It overriding the built-in MySQL configuration that is optimized for DataJoint use to allow it to be easily modified. Uncommenting it will allow you to directly modify the configuration from your machine which is useful when coupling with the above ``DATAJOINT_DATABASE_CONFIG_MONITOR`` feature.\n\n**WARNING**: If you decide to map volume :code:`/var/lib/mysql` (like in the example), then settings for your MySQL server will persist across separate Docker :code:`mysql` instances. In particular, this means that the :code:`MYSQL_ROOT_PASSWORD` setting will be used only when the very first :code:`mysql` Docker container is created. To change the :code:`root` password on an alredy created :code:`mysql` Docker instance, access the database via :code:`mysql` client as :code:`root` and run:\n\n.. code:: bash\n\n    $ mysql -h 127.0.0.1 -u root -p\n    Enter password: [type in your old password]\n    \n    mysql \u003e SET PASSWORD FOR root = PASSWORD('your_new_password');\n\nreplacing the :code:`'your_new_password'` with your new desired password surrounded by quotes (:code:`'`).\n\nBackup\n******\n\nIf you wish to take a disk-based backup of the database, simply back up the local directory matching the :code:`:/var/lib/mysql` volume in your compose file when the database is stopped. To restore, simply copy the backed up data into place before launching the container. Please note that this type of backup is version-specific to the mysql version used with this container.\n\nTo take a backup without stopping the container, you can run:\n\n.. code:: bash\n\n    mysql\u003e flush tables with read lock;\n\nprior to taking the backup, and\n\n.. code:: bash\n\n    mysql\u003e unlock tables;\n\nafter taking the backup. Please note that this will prevent all write activity in the database while the backup is running, and may not provide a consistent state in some environments (e.g. docker-machine or virtualization environments such as docker for windows). Be sure to check related volume mount documentation for your platform and perform regular recovery checks for your environment before relying on any backup strategy.\n\nMore advanced methods for backup such as mysqldump and xtrabackup can also be used to backup the database; please see relevent documentation for further details.\n\nA strategy such as ``mysqldump`` has the benefit of being able to perform a backup without requiring database downtime. The following is an example:\n\n``mysqldump -h$DJ_HOST -u${DJ_USER} -p$DJ_PASS --system=user --quick -v --databases schema_a schema_b schema_c \u003e backup.sql``\n\nIn the above, we connect to MySQL server ``$DJ_HOST`` using user ``$DJ_USER`` with password ``$DJ_PASS``. We perform a backup of the specific schemas ``schema_a``, ``schema_b``, ``schema_c`` written to a file ``backup.sql``. Optional flags were added to include: user management info (usernames + grants), skip caching to commit more often to file, and write more verbose logs.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatajoint%2Fmysql-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatajoint%2Fmysql-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatajoint%2Fmysql-docker/lists"}