ERROR 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

vic

RRRrrrRRRrrrRRrrr
i'm trying to use mySQL. but it doesn" seem to work,


this is the tutorial i used to build apache, php, mySQL

http://www.devshed.com/Server_Side/Administration/BuildingOnOSX/page3.html

and i also have SQL4X Manager, (versiontracker) and it does not see the user i created in NetInfo...

what's the error about and is mysql installed properly how can i see the man for mysql?

any helpfull tips appreciated from all u who got php and mysql running!
 
I get this all the time, you need to go into the CLI and type: safe_mysqld -p
or for an unsecure connection (or if you haven't setup your users yet)
type: safe_mysqld -Sg (cap the s lower g it means skip grant tables)
 
now i get this error!!!!!

is there a tutoria on seting up users and db??

[localhost:~] vic% safe_mysqld -Sg
Starting mysqld daemon with databases from /usr/local/var
/usr/local/bin/safe_mysqld: permission denied: /usr/local/var/localhost.err [230]
rm: /tmp/mysql.sock: Operation not permitted
/usr/local/bin/safe_mysqld: permission denied: /usr/local/var/localhost.err [238]
tee: /usr/local/var/localhost.err: Permission denied
010804 20:34:38 mysqld ended
tee: /usr/local/var/localhost.err: Permission denied
 
i logged in as root and did this , it seems something worked, because before i did this i took mysql folder from HD -> "library" and moved to "System" -> "Library"

[localhost:~] root# safe_mysqld -p
Starting mysqld daemon with databases from /usr/local/var
010804 09:45:34 mysqld ended

[localhost:~] root# man mysql
man: no entry for mysql in the manual.
[localhost:~] root# sql -help
sql: Command not found.
[localhost:~] root# mysql -help
ERROR 2005: Unknown MySQL Server Host 'elp' (2)
[localhost:~] root#

P.S. and what the hell is 'elp' ??
 
i found this in the local host.err file...

010801 14:11:28 mysqld started/Library/MySQL/libexec/mysqld: ready for connections010802 13:25:40 mysqld started/Library/MySQL/libexec/mysqld: ready for connections010803 00:19:38 mysqld started/Library/MySQL/libexec/mysqld: ready for connections010803 07:19:00 mysqld started/Library/MySQL/libexec/mysqld: ready for connections010803 16:16:33 mysqld started010803 16:16:35 /Library/MySQL/libexec/mysqld: Can't create/write to file '/Library/MySQL/var/localhost.pid' (Errcode: 13)010803 16:16:35 /Library/MySQL/libexec/mysqld: Can't find file: './mysql/host.frm' (errno: 13)010803 16:16:35 /Library/MySQL/libexec/mysqld: Error on delete of '/Library/MySQL/var/localhost.pid' (Errcode: 2)010803 16:16:35 mysqld ended010804 20:27:18 mysqld started010804 20:27:20 /Library/MySQL/libexec/mysqld: Can't create/write to file '/Library/MySQL/var/localhost.pid' (Errcode: 13)010804 20:27:20 /Library/MySQL/libexec/mysqld: Can't find file: './mysql/host.frm' (errno: 13)010804 20:27:20 /Library/MySQL/libexec/mysqld: Error on delete of '/Library/MySQL/var/localhost.pid' (Errcode: 2)010804 20:27:20 mysqld ended
 
Hi Vic,

My suggestion is that you delete the installation you just did, go back to the devshed page and do it all over again from the top. Of course if you've already created your mysql entry in NetInfo you won't need to do it again, but confirm those settings.

I notice the devshed instructions don't include a step to actually add the user 'mysql' to your system. You should go to the Users panel in System Preferences and add a 'mysql' user if one doesn't exist.

You may want to get a newer version of MySQL than the one they mention, 3.23.38. The latest version is 3.23.40.

Assuming you follow all the steps in the article you should have mysql set up and it should start automatically when you boot MacOS X. If you need to start it manually there's a very particular way you need to do it.

1. Go to the Terminal and become root.
2. cd to the directory where mysql is installed, which should be /usr/local according to the devshed instructions. Don't enter the bin directory.
3. start mysql with ./bin/safe_mysqld &

Now, if you want to go to the mysql command line you'll need to have permissions to do so. By default I believe that mysql allows an anonymous user to connect without a password. You'd want to change this for security and just because it's good practice. To eliminate the anonymous user and set the root password for mysql you should use these steps:

shell> mysql mysql
mysql> DELETE FROM user WHERE Host='localhost' AND User='';
mysql> QUIT
shell> mysqladmin reload
shell> mysqladmin -u root password your_password


You can add more users and permissions to mysql so that you don't have to change to 'root' in order to use it. To do this you'd need to edit the 'mysql' database tables 'host' and 'user'.

The best resource for learning how to install and administer mysql is located right here. You really should read this page even before you start the install. It gives lots of tips, including what to do about problems starting the server.

MySQL also includes a utility called mysql_setpermission but in order to use it you have to install the MySQL perl modules and possibly the DBI mysql modules. They're available at Source Forge.

You may decide you want to install mysql someplace else other than /usr/local. I actually use /usr/local/mysql for the main install and /usr/local/mysql/data for the databases. To do this I added the following options to the ./configure line:

--prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data

There are lots of other configuration options you might try to get things just the way you like.
 
i don't want to set the root usder to be onlky one able to make changes, it annoys me to always have to sudo and change users in "midflight" i'd like to make myself, the admin, vic, the one to administer mysql from what u said i get the impression that to do that i have to type:

shell> mysql mysql
mysql> DELETE FROM user WHERE Host='localhost' AND User='';
mysql> QUIT
shell> mysqladmin reload
shell> mysqladmin -u vic password your_password

is that right?
 
try this :

edit /etc/hostconfig
insert : MYSQLDBSERVER=-YES-
save /etc/hostconfig (as root)

restart mysql
 
mysqladmin -u vic password your_password

No, that won't work because there is no such user yet in the database to authorize against or for whom to change the password. Heed my words, man: read the manual. You can only create users by editing the 'mysql' database directly. So the proper steps to follow would be:

shell> mysql mysql
mysql> delete from user where User='';
mysql> insert into user values('localhost', 'vic', password('mypassword'), 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
mysql> \q
shell> mysqladmin reload


(This gives you maximum priveleges.) Then to connect again you'll have to type:

shell> mysql -p

You'll then be asked for the password for 'vic' (assuming that's also your shell login name) before proceeding.

If, as you say, you prefer simply typing mysql and don't care about security on your home machine then you can of course leave the 'mysql' database alone and allow non-password anonymous access. There's obviously no need to be religious about security in a secure home situation.


Regarding:
edit /etc/hostconfig
insert : MYSQLDBSERVER=-YES-
save /etc/hostconfig (as root)
restart mysql


This doesn't do anything for the benefit of MySQL. It simply gives a mechanism for the startup script (stored in /System/Library/StartupItems/) to check if you want to start MySQL. Therefore you shouldn't expect it to eliminate errors you're having starting up the server. In any case if you followed the instructions on devshed then you already did this.

Incidentally it sounds like you've got it working now. Is that the case?
 
all right, i erased mysql and re-installed the latest one i think it's etc.40

i seem to work but, i get:

ERROR 1044: Access denied for user: '@localhost' to database 'mysq'

when i type: mysql mysql

the user mysql can be seen by the system and i addet it in net info.

basically i can login to my computer as mysql, but not to the mysql server, unless i am doing something wront, i can login a sannonymous though.

and i have a question:

Regarding:
edit /etc/hostconfig
insert : MYSQLDBSERVER=-YES-
save /etc/hostconfig (as root)
restart mysql

specifically:

insert : MYSQLDBSERVER=-YES-

when i check that file, i see:

MYSQLSERVER=-YES-

without DB,

is that ok?

AND when i do:

mysql> insert into user values('localhost', 'vic', password('letmein'), 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
ERROR 1046: No Database Selected
mysql>

i seem to need to add a database...

do i?

AND, i thing u enter mysqladmin by typing,

>mysql
mysql> mysqladmin

and then i get

mysql> mysqladmin
->

just wondering how do i exit the

->

everything i do, seems to give me

->

oh, and


just a mysql unrelated question, (finally)

if a process is suspended, how do u get back to it, or kill it?

and many thanks to all who contributed here!
 
never mind the ->
business, i got a php and mysql manual and now i am rtfm-ing myself, basically to activate a comand in mysql u have to end it with a semicolon (;)
...

now getting to add users and privs according to the book... more soon

but, my man on mysql still doesn't work!!

if i type man mysql i get nothing

help with that much appreciated...
 
AND when i do:
mysql> insert into user values('localhost', 'vic', password('letmein'), 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
ERROR 1046: No Database Selected


You logged into mysql, cool! But you didn't select the 'mysql' database. You could have selected the 'mysql' database from the shell with mysql mysql (the last parameter is the name of the database you want to select). Or from the mysql command prompt you can enter use mysql.


mysql> q
-> exit
->
->
-> q
-> qqqq
-> ?


The correct way to quit is either:

mysql> \q
or
mysql> quit

When you entered 'q' by itself the prompt changed, indicating it was waiting for more. I see you discovered that to end a mysql command you need a semicolon. Of course the commands it shows you when you type ? don't require a semicolon.


Sounds like the man pages didn't get installed in the right place. Go to your oringinal mysql distribution folder and find the folder that contains your manpages (I think it's called 'man'). Copy the various files to the appropriate man# folders in /usr/local/share/man/. For example, man pages ending in .1 go into /usr/local/share/man/man1.


when i check that file, i see:
MYSQLSERVER=-YES-
without DB,
is that ok?


Yep, that's what the installer set up for you it sounds like. If you examine the /System/Library/StartupItems/ folder you'll see a folder with a name beginning with MySQL (if it's been installed!). Inside this folder is a file named the same as the folder. If you examine this file you'll see it's checking for the existence of the item MYSQLSERVER from hostconfig. Whatever it's checking for should match the name in hostconfig.


basically i can login to my computer as mysql, but not to the mysql server, unless i am doing something wrong, i can login as anonymous though.

You can't log in to the mysql ser ver as 'mysql' until you've added a user named 'mysql' to the 'user' table of the 'mysql' database. To do this you can login as an anonymous user (since that seems to work for you) and add the new user. But you don't really need to add such a user. Just add 'vic' and you'll be able to log in as yourself with mysql -p.
 
u said...

Go to the Terminal and become root.
2. cd to the directory where mysql is installed, which should be /usr/local according to the devshed instructions. Don't enter the bin directory.
3. start mysql with ./bin/safe_mysqld &


ion order to sart mysql, i could not do it that way, so i tried doing it while still loged in as me, not root and it worked...

i can't start it as root...

but that's ok, i think.

p.s.

for some reason if i thype in the console mysql -u anynameufeellike it works it allows anyone to log in... is this bad?
 
"checking for the existence of the item MYSQLSERVER from hostconfig. Whatever it's checking for should match the name in hostconfig."

i don't think it's checking for that, this is the content of themy mysql file as seen in pico:


#!/bin/sh

##
# Start MySQL Server
##

. /etc/rc.common

ConsoleMessage "Starting MySQL Daemon"

if [ -x /Library/MySQL/bin/safe_mysqld ]; then
cd /Library/MySQL
/Library/MySQL/bin/safe_mysqld &
fi
 
So here's mine:

if [ "${MYSQLSERVER:=-NO-}" = "-YES-" ]; then

ConsoleMessage "Starting MySQL"

cd /usr/local/mysql
bin/safe_mysqld > /dev/null &

fi


Same idea, but yours only cares if MySQL exists and doesn't care what your hostconfig file has in it. I've installed MySQL from a few different easy package installers (and most recently just using the source distro so I could tweak it more) and the package installers all have a script that checks for the value of MYSQLSERVER. You could almost call it a standard. ;-)

Interesting that you couldn't start it as 'root.' Maybe this is related to having compiled it to run as user 'mysql.' Hard to say. I've actually never done it that way, but instead I let mysql run as root (the default configuration). Hey, I figure: why not?

Once you get it running smoothly and you've got all your user stuff configured nicely, maybe you'll be ready to get integrated with Apache and PHP, eh? That's what I get paid a paltry $35K per-annum to do. Here are some articles on the subject:

Build and Go Articles:
Build and configure PHP/Apache/MySQL

StepWise: Apache 1.3.20 and PHP 4.0.6

O'Reilly: PHP on MacOS X (ADC)


Tutorials:
Webmonkey: PHP/MySQL Tutorial

MacOS X for Web Developers (excellent)


Manuals:
PHP Functions for MySQL

Apache Users' Guide
 
u know, i think i figured out what the error that started this whole topic means, or why it happened, even after all this tweaking, i still showed up. i was about to get really pissed. then i remembered stepwise http://stepwise.com,

and their soft rack, i looked under mac os xamd databases and i found a package for mysql, i did not install the package, since i already installed ( 3times) mysql... but, i found some cool things on thes website that was pointed to from softrack:

http://www.entropy.ch/software/macosx/mysql/

and when i booted my computer, mysql started...

the error in the subject line of this post is the error i got when tring to start mysql manually because it would't start on bootup.

and ps, i erase the mysql user that i installed according to devshed article, and made one according to even easier instructions from ths link: (same as above: http://www.entropy.ch/software/macosx/mysql/

so, let's hope that error doesn't come up again, and i have to admit that i have learned much these few days thanks to slurr and others who have posted here and my trusty php mysql development book .

thanks and hope i won't come back on this thread anytime soon
 
Back
Top