Category: Development

  • How to Fix MariaDB Error 1130 with wp-env and Docker

    For almost a year now, I’ve been using the @wordpress/env package, which contains npm scripts and runs WordPress in a Docker container. It helped me a lot in the process of developing my korean payment plugin, Korea for WooCommerce, but also while working on client projects.

    When coupled with Github, wp-env and Docker make for a quality development environment. However, I recently encountered a particularly annoying problem with this setup. When switching between projects quickly, I’ve received the following error message:

    Host 'XXX.XXX.XXX.XXX' is not allowed to connect to this MySQL server

    Solutions to this problem do exist on Stack Overflow, but they were not suitable to use with wp-env. So, I would like to share the solution I’ve found most useful for resolving this problem.

    How to Fix MariaDB Error 1130 with wp-env and Docker (In 3 Steps)

    Fortunately, the fix I’ve found for this error is quick and easy to implement. There are just three short steps.

    Step 1: Find the Name of Your wp-env Container

    First, you need to locate the name of the container created by wp-env. To do this, in the directory of your project containing .wp-env.json, you must run the following command:

    docker ps

    This should give you a list of containers. In the Names column, you’ll see the following information:

    7b3099bc856ae9db898a196c0465cadb_wordpress_1
    7b3099bc856ae9db898a196c0465cadb_tests-wordpress_1
    7b3099bc856ae9db898a196c0465cadb_mysql_1

    In this example, “7b3099bc856ae9db898a196c0465cadb” is the name of the container created by wp-env.

    Step 2: Access the Directory Containing Your docker-compose File

    Once you have the name of your wp-env container, you can use it to access the directory containing the docker-compose file created by wp-env. To do so, run the following command in your terminal:

    cd ~/.wp-env/7b3099bc856ae9db898a196c0465cadb
    docker-compose down -v
    docker-compose up -d

    This should create a fresh environment.

    Step 3: Restart wp-env

    Finally, go back to your project folder and run:

    wp-env start

    You should then receive a message informing you that your WordPress dev environment is ready.

    In Conclusion

    I’ve found wp-env extremely useful for plugin development and client projects alike. However, it sometimes throws a database error that can be tricky to resolve.

    Fortunately, you can fix this problem in just three steps:

    1. Find the name of your wp-env container.
    2. Access the directory containing your docker-compose file.
    3. Restart wp-env.

    Do you have any questions about fixing MariaDB Error 1130 with wp-env and Docker? Let me know in the comments section below!