# MySQL does not start after fresh emerge

## daemonflower

I've had it with trying to update mysql from a prehistoric version, so I wiped my old databases, unemerged all installed versions of mysql and emerged it freshly again. 

It does not start up though. After emerge mysql and emerge  --config =dev-db/mysql-5.0.24-r1, /etc/init.d/mysql start gave the following error:

```
 * Service mysql starting

 my_print_defaults NOT found or not executable

 MySQL datadir is empty or invalid

 Please check your my.cnf : /etc/mysql-500/my.cnf                         [ !! ]

 * ERROR:  mysql failed to start
```

I followed the advice and found that emerge had created the folder /var/lib/mysql instead of /var/lib/mysql-500 as given in the config. After renaming the folder (rather than tampering with the pristine my.cnf) I got this error:

```
 I  * Service mysql starting

 my_print_defaults NOT found or not executable

/sbin/start-stop-daemon: stat /usr/sbin/mysqld-500: No such file or directory (No such file or directory)

 MySQL-500 NOT started (2)                                                [ !! ]

 * ERROR:  mysql failed to start
```

Renaming /usr/sbin/mysqld to mysqld-500 turned up this error:

```
 * Service mysql starting

 my_print_defaults NOT found or not executable

 MySQL-500 NOT started (1)                                                [ !! ]

 * ERROR:  mysql failed to start
```

without leaving any trace in either /var/log/mysql/mysqld.err or /var/log/mysql-500/mysqld.err (which is the logfile given in the my.cnf).

Now what I'd like to know is this:

Have I forgotten a step besides emerge --config?

Shouldn't the paths in the my.cnf match the paths on the file system in any case? IOW, is this a bug I should file?

How do I get mysql running?Thanks...

----------

## andersbk

This might help you:

http://gentoo-wiki.com/HOWTO_MySQL

out.

----------

## .:chrome:.

do you have read the output of mySQL ebuild, at the end of emerge process?

emerge mysql --config

----------

## daemonflower

I hadn't read the MySQL Install Guide (hadn't found it), but what it says boils down to:

```
# emerge mysql

# emerge --config =dev-db/mysql-<your version here>

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

Which is exactly what I did.

At the end of the guide there is a mention of "eselect mysql". In my case, even if I rename the moved files back to their old (unversioned) names:

```
# eselect mysql list

Available MySQL versions:

  (none found)
```

EDIT: I unmerged and reemerged mysql, to start with a fresh install, and tried "emerge --config mysql" (without the version number) this time. Same thing.

----------

## daemonflower

I don't understand what I'm doing wrong. Surely I must do something wrong, or else bug reports would be all over the place. I've tried to emerge mysql 4.1.21 instead, with the same result. Then I removed everything remotely resembling old configs and databases, with still the same result.

I have come a little further now, with some manual work (but that is not how it is supposed to be).

```
cd /etc/

mv mysql mysql-500; sudo ln -s mysql-500 mysql

cd /var/lib

mv mysql mysql-500; sudo ln -s mysql-500 mysql

cd /usr/sbin

mv mysqld mysqld-500; sudo ln -s mysqld-500 mysqld
```

at least lets me start mysqld. Connecting to the server with the mysql command does not work yet, I'll have to change some more names, apparently:

```
mysql

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
```

I'll work on it.

Btw, here's my /etc/conf.d/mysql:

```
mysql_slot_500=()
```

and my my.cnf:

```
[client]

port                                            = 3306

socket                                          = /var/run/mysqld/mysqld.sock

[mysql]

character-sets-dir=/usr/share/mysql/charsets

default-character-set=utf8

[mysqladmin]

character-sets-dir=/usr/share/mysql/charsets

default-character-set=utf8

[mysqlcheck]

character-sets-dir=/usr/share/mysql/charsets

default-character-set=utf8

[mysqldump]

character-sets-dir=/usr/share/mysql/charsets

default-character-set=utf8

[mysqlimport]

character-sets-dir=/usr/share/mysql/charsets

default-character-set=utf8[mysqlshow]

character-sets-dir=/usr/share/mysql/charsets

default-character-set=utf8

[myisamchk]

character-sets-dir=/usr/share/mysql/charsets

[myisampack]

character-sets-dir=/usr/share/mysql/charsets

[mysqld_safe]

err-log                                         = /var/log/mysql/mysql.err

[mysqld]

character-set-server            = utf8

default-character-set           = utf8

user                                            = mysql

port                                            = 3306

socket                                          = /var/run/mysqld/mysqld.sock

pid-file                                        = /var/run/mysqld/mysqld.pid

log-error                                       = /var/log/mysql/mysqld.err

basedir                                         = /usr

datadir                                         = /var/lib/mysql

skip-locking

key_buffer                                      = 16M

max_allowed_packet                      = 1M

table_cache                             = 64

sort_buffer_size                        = 512K

net_buffer_length                       = 8K

read_buffer_size                        = 256K

read_rnd_buffer_size            = 512K

myisam_sort_buffer_size         = 8M

language                                        = /usr/share/mysql/english

bind-address                            = 127.0.0.1

log-bin

server-id                                       = 1

tmpdir                                          = /tmp/

innodb_buffer_pool_size = 16M

innodb_additional_mem_pool_size = 2M

innodb_data_file_path = ibdata1:10M:autoextend:max:128M

innodb_log_file_size = 5M

innodb_log_buffer_size = 8M

set-variable = innodb_log_files_in_group=2

innodb_flush_log_at_trx_commit = 1

innodb_lock_wait_timeout = 50

[mysqldump]

quick

max_allowed_packet                      = 16M

[mysql]

[isamchk]

key_buffer                                      = 20M

sort_buffer_size                        = 20M

read_buffer                             = 2M

write_buffer                            = 2M

[myisamchk]

key_buffer                                      = 20M

sort_buffer_size                        = 20M

read_buffer                             = 2M

write_buffer                            = 2M

[mysqlhotcopy]

interactive-timeout
```

Except for removing the comments, I haven't touched either of them.

EDIT: an additional 

```
cd /var/run/mysqld

sudo ln -s mysqld-500.pid mysqld.pid

sudo ln -s mysqld-500.sock mysqld.sock
```

seems to have solved the problem. I can now use mysql to connect.

----------

## khantheripper

 *Quote:*   

>  Surely I must do something wrong, or else bug reports would be all over the place.

 

I also just emerged version 4.1.2, and when I typed "mysql", I also got this message:

```
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
```

----------

## khantheripper

 :Very Happy:    As it turns out, I just had to execute the following, to set the (MySQL) root password and start the server:

```
emerge --config =dev-db/mysql-4.1.19 
```

Now the problem is solved for me.

----------

## Muddy

I tried that and here is what I ended up with

```

Configuring pkg...

 * MySQL DATADIR is /var/lib/mysql

 * Previous datadir found, it's YOUR job to change

 * ownership and take care of it

 * Creating the mysql database and setting proper

 * permissions on it ...

 * Insert a password for the mysql 'root' user

 * Avoid ["'\_%] characters in the password

    >

 * Retype the password

    >

!!! ERROR: dev-db/mysql-4.1.21 failed.

Call stack:

  ebuild.sh, line 1527:   Called pkg_config

  ebuild.sh, line 1255:   Called mysql_pkg_config

  mysql.eclass, line 619:   Called die

!!! MySQL databases not installed

!!! If you need support, post the topmost build error, and the call stack if relevant.

```

----------

