Although I have years of website-building experience, I still bump up against areas of coding that aren’t comfort zones. Every web developer I know who is honest will tell you the same. There seems to be a misunderstanding that those of us who build the web know everything about it. Here’s a little inside tip: We don’t.
More often than not, web developers are tasked with “make x happen to y” and if it’s something we’ve never built before, we scramble to Google or Stack Overflow to figure out how to build the tool or application necessary to fit the requirements of our assignment. For the most part, we’re always building on the knowledge that we already have, exploring to see what can be achieved with the fewest lines of code possible.
Lately, I’ve been spending a significant amount of time learning SQL, a language that deals with querying databases. Databases are how and where websites store various types of information.
About two weeks ago, before my deep dives into SQL, dabbling inside databases scared me. I’ve always walked a fine line composed of fear and healthy respect for them because I know one false move and click of a button can wipe out a large swath of crucial data. Immersing myself in how the SQL language is written and functions has pulled the curtain back and given me an appreciation for a language that’s 40+ years old and yet still holds an astonishing amount of power in the digital space.
I didn’t truly grasp the amount of knowledge I had about databases and SQL until I recently started a side project. Late one night, I started tinkering around with one of my personal websites that has been dormant for more than a year. I built its foundation and later abandoned it because I wasn’t exactly sure how I wanted the website to function. One tiny problem: once I opened the developer site, I found a solid white screen with the prompt “Error establishing a database connection” instead of the actual web content.
I was also having issues on the back end of my website as I couldn’t access the WordPress editor via wp-admin. A peek at the error log in the WordPress back-end files let me know I would have to do the dreaded dig in the database.
For websites to connect to a database, there are a few requirements:
- a database name
- a database username
- a database password
- name of the host
- the charset used
- the collate type
Database settings live in the wp-config.php file and look like this:
In my case, my database password was wrong. “That’s OK, I’ll find it” I thought. Then I couldn’t find it. Time to engage Plan B:
- I opened the MySQL database manager inside my hosting account, created a new database username and password and assigned both to the database attached to the website URL.
- Next, I opened the wp-config.php file, similar to the screenshot above, and edited the username and password fields.
- I refreshed the URL of my test site and the “Error establishing a database connection” prompt was still there.
- Then I had a horrible thought: “Did I enter that information in the correct wp-config.php file?”
- I opened my main URL and the site was down with the same ““Error establishing a database connection” message.
- Of course, I edited the wrong file; it was 9:45 p.m. So, I took a deep breath and performed the same steps as before, but edited the correct files and hit “save.”
Boom, everything became beautiful again.
Sometimes you have to break things to make things. The greatest builders of tech, as well as tangible items, have intentionally torn items apart for the specific purpose of seeing inside to discover what part interacts with another to make the magic happen. Sometimes they think they know what they’re doing and the thing still breaks — yet when perseverance prevails, a lesson is learned and all is not lost. Had I not simultaneously broken two of my own websites, I wouldn’t have known how much I knew about working with databases. Sure, I had watched videos, read tutorials and successfully regurgitated the information in quizzes that accompanied the lessons, but to truly know the information was sticky, I had to actually use it in a real life scenario. I did and it worked.