Difficulty in running MySQL (mysqld)

Hello

I have successfully installed MySQL from ports but I have difficulty in running it as a daemon.

I've put mysql_enable="YES" in /etc/rc.conf but it's no use.

When I type (as root)

# # mysql -u mysql -p and enter the password it returns

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

When I type (as mysql user)

% /usr/local/libexec/mysqld it returns

Code:
100412 ... [Warning] Can't create test file /var/db/mysql/IBM.lower-test
...   Can't change dir to 'var/db/mysql' (Errcode: 13)
100412 ... [ERROR] Aborting

I have tried:

# mysql_install_db and it ran without problems but still no use.

What can I do?

Thanks.
 
Have you even started mysql? Try # /usr/local/etc/rc.d/mysql-server start.
 
Thank you for the response.

# /usr/local/etc/rc.d/mysql-server start works, ie command line prompt returns back without error message

# /usr/local/etc/rc.d/mysql-server restart also works but it asks "mysql not running? (check /var/db/mysql/IBM.EV.pid) then Starting mysql.

But in both cases, mysqld is still not there (# ps -aucx | grep mysqld returns nothing.
 
Check /var/db/mysql/IBM.EV.err.

restart just tries to make sure there is no server running and stops it if needed. It did not ask, it told you there is no mysqld running, which is expected. This is why I use restart even if I just want to start.
 
Thank you.

/var/db/mysql/IBM.EV.err gives

Code:
InnoDB: OS error number 13 in a file operation. The error means "mysqld does not have the access rights to the directory"
File name ./ibdata1
File operation call: 'create'
 
After installing MySQL for the first time, you might want to:

Code:
# mysql_install_db --user=mysql

and...

Code:
# mysqld_safe &

To finish the install.

After these two commands you can setup your desired root password with:

Code:
# /usr/local/bin/mysqladmin -u root password 'your_passwd'
Hope this helps.
 
As mentioned in the error output, what are the permissions on /var/db/mysql? The user that mysql runs as needs to own this directory (or, at the very least, have read/write permission to it), in order to create the database files in here.
 
First I have changed the mod:

# chmod -R 777 /var/db/mysql

and only then worked mysql with

# /usr/local/etc/rc.d/mysql-server restart

Then I 've set the root password with:

# /usr/local/bin/mysqladmin -u root password 'my_passwd'

And it's working finally :)

Thanks.

There's one final thing I'd like to ask though... (I think it's unnecessary to open a separate topic for it)

So far I've been granting the Unix file permissions in a rough way, i.e.

# chmod -R 777 foldername.

But I want to grant a certain user (let's say the "mysql" user) rwx permissions for a specific folder (let's say /var/db/mysql folder). How do you do it?
 
aurora72 said:
First I have changed the mod:

# chmod -R 777 /var/db/mysql
Don't EVER do that again. NEVER make something world writable!

But I want to grant a certain user (let's say the "mysql" user) rwx permissions for a specific folder (let's say /var/db/mysql folder). How do you do it?
See chown(1).
 
Code:
drwx------  7 mysql  mysql  512 Apr 12 23:01 /var/db/mysql

All directories under it have the same permissions (700 (rwx,---,---), mysql:mysql), and the files in them all appear to be 660 (rw-,rw-,---), mysql:mysql.
 
SirDice said:
Don't EVER do that again. NEVER make something world writable!


See chown(1).


I removed others access to that directory by:

# chmod -R o-wrx /var/db/mysql

And granted read&write permissions to mysql group by

# chown -R :mysql /var/db/mysql

Now the latest situation is :

# ls -la /var/db/mysql

drwxrwx--- 4 mysql mysql 512 Apr 13 20:11 mysql

I guess it's secure enough.
 
When I

# chmod -R 700 /var/db/mysql

unfortunately

# /usr/local/etc/rc.d/mysql-server start

is unable to start mysql.

What may I be missing?
 
I've found what was missing :) It is:

# cd /var/db && chown -R mysql mysql/

That is (as you might very clearly notice) the user mysql must own that directory.

I had confused the mysql group with the mysql user but now it's working even under the chmod

700 mysql directory. And by the way I have learned the intricacies of Unix file permissions.

Thanks!
 
Back
Top