Home » Questions » Computers [ Ask a new question ]

Help setting up MySQL (to use with PHP and Apache) on OS X

Help setting up MySQL (to use with PHP and Apache) on OS X

Ok, I recently got interested in making my mac a server, maybe for a blog. I used DynDns for a free domain name, that will always resolve to my current IP, updated with the DynDns Updater application I downloaded. I reserved my local IP, so DHCP will always assign the same local IP to my mac. I port-forwarded port 80 on the router to my mac. I symlinked /Library/WebServer/Documents to point to /Users/me/Sites/, so that I could put stuff in there instead.

Asked by: Guest | Views: 446
Total answers/comments: 2
Guest [Entry]

"If you are not experienced in this area, a good new-user-friendly solution is MAMP. (One especially nice thing about MAMP is that the versions of PHP on OSX (and MySQL on an OSX server) are not necessarily the ones you would choose, if you could. MAMP's versions are more up-to-date and I believe enable more modules for PHP.)

It's dead easy to install and use, with excellent documentation. You should, however, make sure to set a secure password before using it as a proper (externally visible) server.

To answer another question, WordPress uses MySQL to store posts, comments, users and more. The database is, in a way, the real heart of the blog. The rest is mostly interchangeable templates to style the content. (That's an exaggeration I suppose. The PHP takes all the raw data in the database and turns it into a blog, rather than a heap.)

Edit: those instructions that you refer to assume that you already have a working MySQL installation. It sounds like you don't. If you want to go the more complex route, you first need to give the root user of your MySQL installation a password (a very secure one) and then create a second user (with fewer privileges than root) to own the WordPress database. Again, if you've never used MySQL, I wouldn't necessarily recommend that you do this all. At the least, you should read up a bit on how to set-up and administer MySQL. Here's a link: Getting Started with MySQL."
Guest [Entry]

"I suspect the problem that you may be having is that mysql isn't in the path for the user that you're using to set-up your database with. If you specify the full patch and use the default admin user your command line should look something like

/usr/local/mysql/bin/mysql -u root -p

It should then prompt you for the password for your root account. It's also possible MySQL may not be set to run at startup on your mac. If it's not starting automatically, you can start it from the command line using the following

sudo /usr/local/mysql/bin/mysqld_safe &

There is a great GUI client available for OS X called CocoaMySQL which I'd recommend especially if you're new to MySQL, it reduces the learning curve quite a bit.

Oh, and you're spot on the database is used to store comments, and posts in the blog along with other information such as user account information and possibly a lot more (I'm not particularly familiar with Wordpress so not sure what the 'lot more' might be). Get it set-up without the intention of using it full time and just use it to experiment, learn your way around the database for a while and you can discover most of what the database is used for yourself :)"