Question

how can i connect to mysql database from my PC

as i was following the tutorial to install mysql i have been struggling to connect from my MAC,

i already changed the bind-address in mysql conf to the public ip4 address.

i have enabled root and i created a separate user account, but still cant connect.

i also tried with sudo ufw allow 3306/tcp, sudo service ufw restart.

the error I’m getting is the following.

[08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up. com.mysql.cj.exceptions.CJException: null, message from server: “Host ‘C-XX-XXX-XXX-XXX.{some host}.net’ is not allowed to connect to this MySQL server”.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Based on your error message above, I believe that your MySQL and UFW configuration is correct and your MAC has successfully connected to the MySQL server software. But MySQL refused your MAC connection because the MySQL account used to connect was not allowed. That means you entered a wrong host value when creating the separate user account. Try to create a different MySQL account with the correct host value C-XX-XXX-XXX-XXX.{some host}.net mentioned in the error message. For example:

CREATE USER 'sammy'@'C-XX-XXX-XXX-XXX.{some host}.net' IDENTIFIED BY 'password';