# MySQL Install

## celloandy

Sorry for posting so many n00b-ish questions of late, but here's may problem: I emerged MySQL, then tried to start it.  First time, it couldn't find my.cnf, so I checked in its config folder and found my.cnf-4.0.14-r1, and created a symlink called my.cnf (is this what I should have done?)  Anyway, that error went away, but it said to run mysql_install_db, so I did, so that finally 'running /etc/init.d/mysql start' worked without errors.  My new problem is that trying run the mysql client coughs up an error about not being able to connect, and 'ps -aux' reveals that mysqld isn't, in fact running.  mysqld.err says that the reason it isn't starting is becaure it "Can't find file: './mysql/host.frm'"  The file does, however, exist at /var/lib/mysql/mysql/host.frm

What did I not do?

Andrew

----------

## kashani

$10 says you didn't run the post install script. 

```

ebuild /var/db/pkg/dev-db/mysql-4.0.14-r1/mysql-4.0.14-r1.ebuild config

```

You might need to tweak the above to conform with your mysql version.

kashani

----------

## slartibartfasz

also check if u updated yoru /etc configfiles correctly - the way mysql is started, changed a bit and it wont work with the old init.d script...

----------

## celloandy

Hm... I just ran etc-update, and that didn't solve the problem.  Neither did running the ebuild config script.  Here's something else, however, that I noticed: if I attempt to stop mysql, I get [!!] rather than [ok], and if I try to start it again after that, I get a warning that it's already been started.

Andrew

----------

## kashani

 *celloandy wrote:*   

> Hm... I just ran etc-update, and that didn't solve the problem.  Neither did running the ebuild config script.  Here's something else, however, that I noticed: if I attempt to stop mysql, I get [!!] rather than [ok], and if I try to start it again after that, I get a warning that it's already been started.
> 
> Andrew

 

Means that the init scripts are confused as to the state of mysql. Happened when the deamon fails in interesting ways after you started it. o fix do the following.

/etc/init.d/mysql zap

/etc/init.d/mysql start    which should work now that you've run the config script.

kashani

----------

## celloandy

Actually, I had my cousin poke around on the machine, and it turns out that the problem was in the permissions.  All of MySQL's files in /var/lib were owned by root:root instead of mysql:mysql.  This seems to have solved the problem.  Starting the daemon manually (mysqld_safe &) and then killing it with the init script has unconfused init.d, as well.

Thanks for everyone's help.

Andrew

----------

## slartibartfasz

take care with the permissions on the directories - the directories and especially /var/lib/mysql/mysql should be mysql:root....

and the permissions should be:

```
ls -l /var/lib/mysql

total 2

drwx------    2 mysql    mysql         312 May 22 16:34 ChemEngDB

drwx------    2 mysql    root          528 May  7 16:15 mysql

drwx------    2 mysql    root           48 May  7 16:15 test

```

----------

## To

 *celloandy wrote:*   

> My new problem is that trying run the mysql client coughs up an error about not being able to connect, and 'ps -aux' reveals that mysqld isn't, in fact running.  mysqld.err says that the reason it isn't starting is becaure it "Can't find file: './mysql/host.frm'"  The file does, however, exist at /var/lib/mysql/mysql/host.frm
> 
> What did I not do?
> 
> Andrew

 

Did you run mysql_install_db? Problably on an old install...  and on /etc/mysql/my.cnf ?

Tó

----------

## hertog

The problem seems to be that the 

```
 ebuild /var/db/pkg/dev-db/mysql-4.0.14-r1/mysql-4.0.14-r1.ebuild config 
```

step doesn't set the permissions correctly (as stated above) It set's them to root:root instead of mysql:root.

A chown -R mysql:root solved my problems.

Anyone filed a bug already?

----------

## Terminal

I seem to be having a similar problem trying to start mysql

```
barney mysql # /etc/init.d/mysql start

 * No /etc/mysql/my.cnf file exists!

 * You dont appear to have the mysql database installed yet.

 * Please run /usr/bin/mysql_install_db to have this done...

```

running /usr/bin/mysql_install_db produces:

```
barney mysql # /usr/bin/mysql_install_db

Installing all prepared tables

030825 11:04:26  /usr/sbin/mysqld: Shutdown Complete

 

 

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

This is done with:

/etc/init.d/mysql start (you have to start the server first!)

/usr/bin/mysqladmin -u root -h barney password 'new-password'

/usr/bin/mysqladmin -u root password 'new-password'

See the manual for more instructions.

 

NOTE:  If you are upgrading from a MySQL <= 3.22.10 you should run

the /usr/bin/mysql_fix_privilege_tables. Otherwise you will not be

able to use the new GRANT command!

 

Please report any problems with the /usr/bin/mysqlbug script!

 

The latest information about MySQL is available on the web at

http://www.mysql.com

Support MySQL by buying support/licenses at https://order.mysql.com

```

however, that doesn't fix it, and I still get the same error trying to start mysql.  I have also set the permissions as slartibartfasz suggested:

```

barney mysql # ls -l /var/lib/mysql

total 12

drwx------    2 mysql    mysql        4096 Aug 24 19:52 ChemEngDB

drwx------    2 mysql    root         4096 Aug 24 18:03 mysql

drwx------    2 mysql    root         4096 Aug 24 18:03 test

```

I'm not at all familiar with mysql (yet) so any help would be appreciated.

----------

## Terminal

*update*

creating the symlink between /etc/mysql/my.cnf-4.0.14-r1 and /etc/mysql/my.cnf fixed the problem.

----------

## paul138

Hmmm...not here.

Starting mysql via init.d/mysql returns this in it's logs (/var/log/nysql/mysqld.err):

```
030828 14:01:52  mysqld started

Warning: Ignoring user change to 'mysql' because the user was set to 'mysql' earlier on the command line

030828 14:01:52  Fatal error: Can't open privilege tables: Can't find file: './mysql/host.frm' (errno: 13)

030828 14:01:52  Aborting

030828 14:01:52  /usr/sbin/mysqld: Shutdown Complete
```

And mysql_install_db does nothing.

----------

## hertog

The ownership of the database files in /usr/share/mysql is wrong.

Changing it to mysql:root worked for me, and I had the exact same error.

----------

## paul138

Hmm...that's no good either. Cant seem to locate a bug report for it. Maybe I'll file one.

----------

## Sh4doW

for fresh mysql-4.0.14-r1 install use something like :

```

# emerge mysql

# mysql_install_db

# chown mysql:root /var/lib/mysql/ -R

# ln -s /etc/mysql/my.cnf-4.0.14-r1 /etc/mysql/my.cnf

```

after that i still get ...

Warning: Ignoring user change to 'mysql' because the user was set to 'mysql' earlier on the command line

... in /var/log/mysql/mysqld.err, but mysql is up & running.

write here if it's working for you.

btw, dont' forget to change root password   :Wink: 

----------

## Forsaken

like hertog said just change the ownership of the files:

```

cd /var/lib/mysql

chown -R mysql:root mysql

/etc/init.d/mysql start

```

That should get you started.. this is of course after you run the config to set up the initial database.

----------

## FastTurtle

Well it started up fine after running mysql_install_db but after setting the root pw, I'm getting an access denied for root@localhost and it's driving me nuts. The last thing it says is (Using pasword: NO)

I followed the instructions to create the root password as sugested and have continued following them. Right now I'm not sure where the error is because i have not been able to access mysqladmin

----------

## skarsol

Try adding a -p at the end of the command line when you are getting the Using password: NO error.

----------

## daysleper

Same problems here, and the solution was to set the permissions as you ppl.  said. This worked perfectly.  :Smile: 

Someone should file a bug so it get's fixed or something.  :Smile: 

----------

## infecticide

I have my database files on a FAT32 partition which I dual boot WinXP.  MySQL can't seem to use the database files properly. I get this same error.  How can I let mySQL use the files on the FAT32 partition?  I know it has something to do with permissions.   I know it can be done because i've had it setup using Knoppix.

----------

## UberLord

You need to mount the partition with the option to set the user to mysql.

This will give mysql full access to the partition, which could be bad from a security POV.

I would look long and hard before doing this.

----------

## infecticide

I was able to solve my apache2/mysql woes by adding gid=users, uid=0000 to fstab.

----------

