# mysql will not start without localhost?



## reppa (Apr 11, 2011)

Hi,

I have some problem with starting mysql (5.5.10) on FreeBSD 8.1.

When I try to start:

[CMD=]/usr/local/etc/rc.d/mysql-server start[/CMD]

```
Starting mysql.
```
[CMD=]/usr/local/etc/rc.d/mysql-server status[/CMD]

```
mysql is not running.
```

If I try this:
[CMD=]/usr/local/bin/mysqld_safe &[/CMD]

```
110411 19:45:20 mysqld_safe Logging to '/home/db/hostname.err'.  grep: grep: grep"74174: No such file or directory: No such file or 
directory
grep: ": No such file or directory
110411 19:45:20 mysqld_safe Starting mysqld daemon with databases from /home/db
```


```
# ps -auwx | grep mysql
root  73915  0.0  0.5  3628  1180   1  I     7:36PM   0:00.04 /bin/sh /usr/local/bin/mysqld_safe
mysql 74174  0.0 32.1 605508 79904   1  I     7:36PM   0:00.60 [mysqld]
```

So it seems to run on my server, but:

```
mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
```

If I try to connect with localhost information:

```
mysql -h 127.0.0.1 -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
...
```

What's wrong? It's seems to work, but not 100 %.

reppa


----------



## SirDice (Apr 11, 2011)

I'm assuming nothing is running in a jail? 

But can you post the relevant rc.conf variables and/or your my.cnf?


----------



## reppa (Apr 11, 2011)

Here is relevant information from my rc.conf:

```
mysql_enable="YES"
```

my.cnf


```
[client]
#password       = your_password
port            = 3306
socket          = /home/db/mysql.sock

# The MySQL server
[mysqld]
port            = 3306
socket          = /home/db/mysql.sock
datadir         = /home/db/
skip-external-locking
key_buffer_size = 384M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
thread_concurrency = 8
#skip-networking
log-bin=mysql-bin
server-id       = 1
#server-id       = 2
#master-host     =   <hostname>
#master-user     =   <username>
#master-password =   <password>
#master-port     =  <port>
#log-bin=mysql-bin
#binlog_format=mixed
#innodb_data_home_dir = /var/db/mysql
#innodb_data_file_path = ibdata1:2000M;ibdata2:10M:autoextend
#innodb_log_group_home_dir = /var/db/mysql
#innodb_buffer_pool_size = 384M
#innodb_additional_mem_pool_size = 20M
#innodb_log_file_size = 100M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
#safe-updates

[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

[mysql.server]
user=mysql
basedir=/usr/local/bin
```

[CMD=""]ls -l /home/[/CMD]

```
drwx------  5 mysql   mysql      512 Apr 11 19:45 db
```

I'm sitting in jail? :q

reppa


----------



## codeWarrior (Apr 12, 2011)

You have some misconceptions about mySQL.... this is not a FreeBSD issue... it has to do with your mysql permissions and access... you should read up on mySQL.


----------



## mamalos (Apr 12, 2011)

Have you run *mysql_install_db* on your system? Do the requested files exist (eg. /home/db/hostname.err)? Because if they don't, your system won't start.  What do your logfiles suggest (which I highly doubt they exist, since /home/db/hostname.err is one of them)? If they exist, check your permissions on *these* files.


----------



## reppa (Apr 12, 2011)

Hi,

Here is my /home/db/hostname.err:


```
110412 19:24:42 mysqld_safe Starting mysqld daemon with databases from /home/db
110412 19:24:42 [Warning] Ignoring user change to 'ser=mysql' because the user was set to 'my$
110412 19:24:42 InnoDB: The InnoDB memory heap is disabled
110412 19:24:42 InnoDB: Mutexes and rw_locks use GCC atomic builtins
110412 19:24:42 InnoDB: Compressed tables use zlib 1.2.3
110412 19:24:43 InnoDB: Initializing buffer pool, size = 128.0M
110412 19:24:43 InnoDB: Completed initialization of buffer pool
InnoDB: The first specified data file ./ibdata1 did not exist:
InnoDB: a new database to be created!
110412 19:24:43  InnoDB: Setting file ./ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
110412 19:24:43  InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
110412 19:24:43  InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: 127 rollback segment(s) active.
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
110412 19:24:43  InnoDB: Waiting for the background threads to start
110412 19:24:44 InnoDB: 1.1.5 started; log sequence number 0
110412 19:24:44 [ERROR] Can't start server: Bind on TCP/IP port: Address already in use
110412 19:24:44 [ERROR] Do you already have another mysqld server running on port: 3306 ?
110412 19:24:44 [ERROR] Aborting
110412 19:24:44  InnoDB: Starting shutdown...
110412 19:24:44  InnoDB: Shutdown completed; log sequence number 1595675
110412 19:24:45 [Note] /usr/local/libexec/mysqld: Shutdown complete
110412 19:24:45 mysqld_safe mysqld from pid file /home/db/xxxx.xxxx.no.pid ended
```


```
-rw-------  1 mysql  mysql        70 Apr 12 19:17 .my.cnf.84316
-rw-------  1 mysql  mysql         1 Apr 12 19:17 .mysql.84316
-rw-rw----  1 mysql  mysql   5242880 Apr 12 19:24 ib_logfile0
-rw-rw----  1 mysql  mysql   5242880 Apr 12 19:24 ib_logfile1
-rw-rw----  1 mysql  mysql  18874368 Apr 12 19:24 ibdata1
-rw-rw----  1 mysql  mysql      1972 Apr 12 19:24 xxx.xxxx.no.err
drwx------  2 mysql  mysql      2048 Apr 12 19:16 mysql
-rw-rw----  1 mysql  mysql     29704 Apr 12 19:16 mysql-bin.000001
-rw-rw----  1 mysql  mysql    995332 Apr 12 19:16 mysql-bin.000002
-rw-rw----  1 mysql  mysql       126 Apr 12 19:24 mysql-bin.000003
-rw-rw----  1 mysql  mysql        57 Apr 12 19:24 mysql-bin.index
drwx------  2 mysql  mysql      1024 Apr 12 19:16 performance_schema
drwx------  2 mysql  mysql       512 Apr 12 19:16 test
```

I ran [cmd=]/usr/local/bin/mysql_install_db --basedir=/usr/local[/cmd] after I had deleted db-files from /home/db

reppa


----------



## reppa (Apr 12, 2011)

codeWarrior said:
			
		

> You have some misconceptions about mySQL.... this is not a FreeBSD issue... it has to do with your mysql permissions and access... you should read up on mySQL.



Can you give me a hint if you know what the problem is?

reppa


----------



## mamalos (Apr 12, 2011)

Once your files are installed successfully, you just use the relevant rc.d script to start mysqld. Before that, be sure you have *kill*ed all mysqld processes, because that is what the message of your logs tells you.


----------



## reppa (Apr 14, 2011)

Right permission to /tmp solved my problem. Mod can set this thread to solved.


----------



## SirDice (Apr 15, 2011)

reppa said:
			
		

> Right permission to /tmp solved my problem.


The permissions should be 1777 for that filesystem. That means it already had enough permissions. What exactly did you change it to?


----------

