MySQL is the world's most popular open source database. Official-images repo's library/mysql file ( history) Official-images PRs with label library/mysql Repo-info repo's repos/mysql/ directory ( history) Supported tags and respective Dockerfile links The cryptography package installed above is an optional dependency of pymysql that is needed to perform authentication against the MySQL database.Ĭongratulations! You now have a complete set up, including a blank MySQL database that is ready to be used.The Docker Community Forums, the Docker Community Slack, or Stack Overflow If you need a recommendation, my driver of choice is pymysql, which you can install into your Python virtual environment as follows: (venv) $ pip install pymysql cryptography There are several MySQL drivers for Python that can be used here, so you should use your favorite if you have one. To access your MySQL database you have to install a Python client, sometimes also called driver. Stopping and restarting the server as shown above does not cause any data loss. To start the server again, repeat the "up" command as before: $ docker-compose up -d If you'd like to stop the MySQL server, you can do so with this command, issued from the directory in which you have your docker-compose.yml file: $ docker-compose down This user will have full access to the database, but it will not be able to access or create other databases, which is a good security principle to follow.įrom now on, you can log in to phpMyAdmin using the user you just created, and your view of the database server will be constrained to only what's relevant to manage this particular database. Leave the host set to "%", then enter a password for the new user.Ĭonfirm that the "Grant all privileges on database retrofun" option is enabled, and then scroll all the way to the bottom of the page and click the "Go" button to create the user. Click it to create a new user.įor the username you can choose any name that you like, but a naming convention that I find useful is to use the same name for the database and the user, so in this case it would be retrofun. Near the bottom of the page there is a section titled "New" with an "Add user account" link. Using the root database user for day-to-day operations is too risky, because this account is too powerful and should only be used for important administration tasks.Ĭlick on the "Privileges" tab for the new database. Near the top you should see the "Create Database" section.Įnter a name for the new database, for example retrofun, and click the "Create" button.Ī good practice when creating a new database is to also define a user specifically assigned to it. Once you access the phpMyAdmin interface, click on the "Databases" tab.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |