Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

noahgolm

macrumors member
Original poster
Aug 18, 2010
65
0
Hi, all. Recently, I have been trying to create a little home server website via my macbook. It has gone fairly well, and I even implemented PHP and JavaScript (I'm so proud as a beginner...)! Anyways, as a way to learn more about the security of websites, I installed MySQL onto my computer. Unfortunately, it does not work at all! I always get the error message:
"Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)"
I checked the /var/lib/ folder, and found that /mysql/mysql.sock or even just /mysql was there! What could be the problem here?
 
Hi, all. Recently, I have been trying to create a little home server website via my macbook. It has gone fairly well, and I even implemented PHP and JavaScript (I'm so proud as a beginner...)! Anyways, as a way to learn more about the security of websites, I installed MySQL onto my computer. Unfortunately, it does not work at all! I always get the error message:
"Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)"
I checked the /var/lib/ folder, and found that /mysql/mysql.sock or even just /mysql was there! What could be the problem here?

You usually get that error message when the MySQL server is NOT running. When you use one of the Mac OS X packages from mysql.com, it installs the server, but does not automatically launch it once the installation is finished. The easiest way to get it going is to also install the control applet for System Preferences by double clicking on it, then open System Preferences and open the MySQL panel and launch the server. You should also install the startup item, which is also part of the MySQL package.

Enjoy! :)
 
Well, I checked, and the server is on. The problem still persists, though! And, through system preferences, I tried to stop and start it again. It stops just fine, but clicking the start button does nothing!

On another note, I just picked up a copy of a book detailing how to build databases with PHP and MySQL. It suggested installing MySQL via the MAMP package. Would this maybe work better than my currently failed install via the .dmg download?
 
Check /tmp when the server is running.

See if mysql.sock is there.
 
For some reason, the server doesn't turn on when I click the preference pane button, or go through terminal!
 
OK, I deleted everything (with the instructions from several websites) from MySQL, and tried reinstalling it. And now, I found out, I can't start the server in the first place! I ran "sudo /usr/local/mysql/bin/mysqld_safe" and the error reads this:

Code:
mysqld_safe mysqld from pid file /var/run/mysql.pid ended

Anyone have any ideas to fix this?
 
Here's the error log for one session:

Code:
101127 18:06:42 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
101127 18:06:42 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
101127 18:06:42 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
101127 18:06:42 [Note] Plugin 'FEDERATED' is disabled.
101127 18:06:42  InnoDB: Started; log sequence number 0 44233
101127 18:06:42 [ERROR] /usr/local/mysql/bin/mysqld: Can't create/write to file '/var/run/mysql.pid' (Errcode: 13)
101127 18:06:42 [ERROR] Can't start server: can't create PID file: Permission denied
101127 18:06:42 mysqld_safe mysqld from pid file /var/run/mysql.pid ended

I don't know why the error "Permission denied" is there. I ran the command with sudo...
 
To be quite honest, I don't know. MySQL is laid out in a bunch of different places, usually /usr and /var. How do check/change the file permissions?
 
To be quite honest, I don't know. MySQL is laid out in a bunch of different places, usually /usr and /var. How do check/change the file permissions?

It shouldn't be... It should all be located in one folder if you used the installer (unless it has changed).

ls -al will give you a listing of the folders with their permissions and chmod will let you change it. If you are the only one that uses that machine and it is behind a firewall you could chmod the parent folder and other files to 775.

Did you follow this installation?

http://hivelogic.com/articles/compiling-mysql-on-snow-leopard
 
Tried chmod 775 to give access, and now I'm getting some different errors, which I don't get. When I just run "mysql" the output is the same, but the error log shows this:

101128 23:32:14 mysqld_safe A mysqld process already exists


And when I then run "mysqld" there is no error log, but the output shows this:

101128 23:38:49 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
101128 23:38:49 [Warning] Can't create test file /usr/local/mysql-5.1.53-osx10.6-x86_64/data/localhost.lower-test
101128 23:38:49 [Warning] Can't create test file /usr/local/mysql-5.1.53-osx10.6-x86_64/data/localhost.lower-test
mysqld: Can't change dir to '/usr/local/mysql-5.1.53-osx10.6-x86_64/data/' (Errcode: 13)
101128 23:38:49 [ERROR] Aborting

101128 23:38:49 [Note] mysqld: Shutdown complete


I'm guessing the first warning is just due to the use of --skip-locking as a nearly outdated command, but could the rest be permission issues still, or something else?
 
Just use MAMP, it's easy and doesn't mess up your system. You will have a complete web server (apache, php, mysql, phpmyadmin) installed in no time flat. Everything will be located in one folder on your Mac (Applications/MAMP). Then put your server files (your code) in Applications/MAMP/htdocs.

Let's say you have a php file in htdocs named mycode.php. You would then load that in a browser with http://localhost:8888/mycode.php. If you change the default MAMP port of 8888 to 80 then you can just use http://localhost/mycode.php It's that simple!
 
Tried chmod 775 to give access, and now I'm getting some different errors, which I don't get. When I just run "mysql" the output is the same, but the error log shows this:

101128 23:32:14 mysqld_safe A mysqld process already exists

This means there is either a mysqld process running (use ps -ef |grep mysql to see)
Or there is a PID file that hasn't been removed.

And when I then run "mysqld" there is no error log, but the output shows this:

101128 23:38:49 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.


That's mostly a nothing warning.


101128 23:38:49 [Warning] Can't create test file /usr/local/mysql-5.1.53-osx10.6-x86_64/data/localhost.lower-test
101128 23:38:49 [Warning] Can't create test file /usr/local/mysql-5.1.53-osx10.6-x86_64/data/localhost.lower-test
mysqld: Can't change dir to '/usr/local/mysql-5.1.53-osx10.6-x86_64/data/' (Errcode: 13)
101128 23:38:49 [ERROR] Aborting

These mean that either the directory doesn't exist, isn't owned by the mysql user, or has the wrong permissions, or a combination of them.
 
What CHMOD command did you use? Did you just change the permission on the folder (chmod 775 mysql)? If so, you probably need to apply the permissions to the contents as well....

chmod -R 775 mysql
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.