# Not able to install mysql51-server



## Cyberian (Feb 13, 2012)

Yo guys, 

I'm new to FreeBSD / Unix-like operating-systems and was wondering if you guys could help me out with this 'installing mysql-server' problem I'm having. All right here it goes: I can't seem to get mysql51-server to install properly. I've tried mysql50-server and mysql55-server as well, but I got the same problem over and over again. 

To install mysql51-server I entered the following commands:

`# cd /usr/ports/databases/mysql51-server`
`# make install clean`

Everything is going smooth (I think), until the end, when I get this message (don't know if all the displayed information is useful though):


```
.....
===>   Installing ldconfig configuration file
===>   Registering installation for mysql-client-5.1.61
===>   Returning to build of mysql-server-5.1.61
===>   Generating temporary packing list
===>  Checking if databases/mysql51-server already installed
===> Creating users and/or groups.
Using existing group `mysql'.
Creating user `mysql' with uid `88'.
pw: user 'mysql' already exists
*** Error code 74

Stop in /usr/ports/databases/mysql51-server.
```

Since I'm not that knowledgeable about this sort of thing I just try to follow the next step in the installing process according to the "how to" I was using until just now:

`# rehash`
`# mysql_install_db --user=mysql`

Then I got this error:


```
mysql_install_db: Command not found.
```

So, anyone willing to help me out here? 

Like I said at the start of this post I tried different versions of the mysql-server so before my latest attempt I gave this command: 

`# pkg_delete -xi mysql`


----------



## SirDice (Feb 13, 2012)

There already appears to be a MySQL user. Normally it would just use that account. But it seems to have some problems with it. Try removing the user account and try again.

`# pw group del mysql`
`# pw user del mysql`


----------



## Cyberian (Feb 13, 2012)

SirDice said:
			
		

> There already appears to be a MySQL user. Normally it would just use that account. But it seems to have some problems with it. Try removing the user account and try again.
> 
> `# pw group del mysql`
> `# pw user del mysql`



Deleting the group goes as to be expected, but when try to delete the mysql user I get this response:


```
pw: no such user `mysql'
```

When I try to reinstall mysql51-server I get the same response as before though:


```
pw: user 'mysql' already exists
```

I reinstalled the mysql51-server giving these commands:

`# cd /usr/ports/databases/mysql51-server`
`# make deinstall clean`
`# make -D BUILD_OPTIMIZED install clean`


----------



## frijsdijk (Feb 13, 2012)

Something else must be borked, because even though the user/group exist, I can always install mysql..

I'm wondering, what's the output of:


```
id mysql
finger mysql
grep -i mysql /etc/master.passwd /etc/passwd /etc/group
```


----------



## Cyberian (Feb 13, 2012)

`# id mysql`

```
id: mysql: no such user
```
`# finger mysql`

```
finger: mysql: no such user
```
`# grep -i mysql /etc/master.passwd /etc/passwd /etc/group`

```
/etc/master.passwd:mysql:*:88:88::0:0:MySQL Daemon:/var/db/mysql:/usr/sbin/nologin
/etc/passwd:mysql:*:88:88:MySQL Daemon:/var/db/mysql:/usr/sbin/nologin
/etc/group:mysql:*:88:
```


----------



## frijsdijk (Feb 14, 2012)

It seems your passwd database is out of sync.

Try:


```
pwd_mkdb /etc/master.passwd
```

Then, the id and finger command should give output, and you'll probably be able to install mysql

Did you edit master.passwd or passwd with vi? (you should edit it with 'vipw')


----------



## Cyberian (Feb 14, 2012)

Ah, nice one, it worked. I havenâ€™t used vi, so that cant be it, I only use 'ee' to make adjustments (still have to learn VI though, got the cheatsheet printed out on my desk and all :stud). 

There is still a problem though, when I try to run the script mysql_install_db to set up the grant tables needed by MySQL. I get this error:

`# mysql_install_db --user=`


```
Installing MySQL system tables...
ERROR: 1136  Column count doesn't match value count at row 1
120214 16:16:38 [ERROR] Aborting

120214 16:16:38 [Note] /usr/local/libexec/mysqld: Shutdown complete


Installation of system tables failed!
```

So in response I wanted to start the mysqld daemon with:

`# /usr/local/libexec/mysqld --skip-grant &`

But then I got this output:


```
[1] 11864
server# 120214 16:27:47 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

120214 16:27:47 [ERROR] Aborting

120214 16:27:47 [Note] /usr/local/libexec/mysqld: Shutdown complete
```

So now I cant use the command line tool /usr/local/bin/mysql to connect to the mysql database and look at the grant tables:

`# /usr/local/bin/mysql`


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

I thought I could might fix this by using the touch commando:
`# touch /tmp/mysql.sock`

But no luck there..

Any idea on how to fix this?


----------



## frijsdijk (Feb 14, 2012)

It's now probably all a bit b0rked because you've various versions of MySQL installed, or at least tried to. It's easier than you think. First of all, the rc.d script will create all the stuff for you if it's not there. So, if this a new installation, and you have no databases to keep or any other data in mysql, then I would:


```
rm -rf /var/db/mysql/
```

Or, if you want to be safe:


```
mv /var/db/mysql /var/db/backup-mysql
```

And then:

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

.. assuming that:


```
mysql_enable="YES"
```

.. is already in /etc/rc.conf.

After that, verify that MySQL is running by:


```
/usr/local/etc/rc.d/mysql-server status
```

Login:


```
mysql -uroot
```


----------



## Cyberian (Feb 14, 2012)

Thanks mate, that fixed the problem. I'm very grateful for your help!


----------

