Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialLeigh Maher
21,830 PointsCommand Line has messed up my MAMP
I was trying to set up mySql Community server and SQLWorkbench. I've run into lots of problems and I can't seem to resolve, but I've also just noticed that my MAMP localhost is no longer working. It's believe it's as a result of something that I entered into the command line, most likely this: sudo cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
I can find my server at this ip address 127.0.0.1 but I'm having problems with a wordpress site not displaying properly. How do I change it back so that I can locate my server at http://localhost?
4 Answers
Ben Michel
3,170 PointsHi Leigh!
Yes I do. :D
The hosts file maps hostnames to specified IP addresses, and ::1 localhost essentially resolves the ipv6 notation for 127.0.0.1 to the hostname 'localhost.' In other words, ::1 is 127.0.0.1 in ipv6.
The '::1 localhost' line is standard for the hosts file, and removing this could cause issues in the future if your application is looking to resolve to ::1 but you're only have the ipv4 standard notation in the file. So you might want to keep that in mind, or jot it down somewhere because you may want to add it back at some point.
For now it seems like you were possibly experiencing an issue where some the routes configured for the development environment of your app at localhost couldn't be resolved to their IP address properly, and it was causing some issues.
Hope that helps! :)
Ben Michel
3,170 PointsThere are a few possibilities that could be causing your issues.
Wordpress can often have buggy problems when updates occur and are needed, or in other words: your site could be running smoothly until you make let Wordpress update its server or plugins and then things break and you have to figure out and resolve the missing or changed dependancies and/or the resulting new bugs (in the php/css) making DOM elements display differently than before. Also, if you updated the MySQL server that your site is depending on at localhost, that could've definitely caused some issues you're seeing as well.
Concerning localhost, 127.0.0.1 is the base address for localhost. You can think of 'localhost' as being the domain name for 127.0.0.1 so actually: 127.0.0.1 is http://localhost. The MySQL Community server you just set up is set to do all of its request/post type operations at the localhost:3306 port by default (synonymous with 127.0.0.1:3306).
What the bash command in this exercise is doingβis copying a sample default server configuration file template into a location where it will be used as your default. Try removing that config file, and check out your site via localhost again.
You can do this by typing $ sudo rm /etc/my.cnf
in your terminal. This isn't going to harm anything, if it brings your working environment back to normal, just repeat the $ sudo cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
step when you want to go back to working on the Treehouse course, and then remove after you're done.
A more efficient way to fix that though is to revert to using your earlier configuration file and change the localhost ports your using to unused ports in the 3000's, changing any part of the clients that need to know that as well as needed. For instance, your MAMP server would be operating at localhost:3010, and the treehouse_db could have localhost:3306, or vice versa. Having as server set at the 127.0.0.1 base address is not really a good idea. Your older configuration file may still be in the original installation directory that was made when you installed your MAMP server (which you can then copy over to being your default my.cnf), or could've been erased with the new install. In that case, you'll have to research to figure out what the old settings were.
Hope this helped, cheers! :)
Leigh Maher
21,830 PointsHi Ben, thanks very much for your detailed answer.
I've had subsequently found the reason why the localhost directory wasn't showing at localhost. In the etc/hosts file it had this extra line:
::1 localhost
I removed it and now it works at localhost. I've no idea what this line was doing, or how it got there. Any idea?
Thanks.
Leigh Maher
21,830 PointsThanks Ben. That's good to know. I've put the line back into the hosts file and commented it out, and left a note for myself. That's good advise, and I should do that in future when I'm not sure what code does, just in case I need to put it back in.
Ben Michel
3,170 PointsAnytime! Glad it helped.
Cheers. :D