# MySQL not running



## bsps (Jun 17, 2013)

Hello all,

I face an issue when starting MySQL. Each time I run status it is said MySQL is not running. I tried to search for this issue but until now I couldnâ€™t find any answer. Also I tried to install a different version of MySQL but still the same issue.

Please see the below for the error file.

```
130617 13:45:50 mysqld_safe Starting mysqld daemon with databases from /var/db/mysql
2013-06-17 13:45:51 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp se
2013-06-17 13:45:51 23252 [Note] Plugin 'FEDERATED' is disabled.
/usr/local/libexec/mysqld: Table 'mysql.plugin' doesn't exist
2013-06-17 13:45:51 23252 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2013-06-17 13:45:51 23252 [Note] InnoDB: The InnoDB memory heap is disabled
2013-06-17 13:45:51 23252 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2013-06-17 13:45:51 23252 [Note] InnoDB: Compressed tables use zlib 1.2.3
2013-06-17 13:45:51 23252 [Note] InnoDB: Not using CPU crc32 instructions
2013-06-17 13:45:51 23252 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2013-06-17 13:45:51 23252 [Note] InnoDB: Completed initialization of buffer pool
2013-06-17 13:45:51 23252 [Note] InnoDB: Highest supported file format is Barracuda.
2013-06-17 13:45:51 23252 [Note] InnoDB: Log scan progressed past the checkpoint lsn 1453445
2013-06-17 13:45:51 23252 [Note] InnoDB: Database was not shutdown normally!
2013-06-17 13:45:51 23252 [Note] InnoDB: Starting crash recovery.
2013-06-17 13:45:51 23252 [Note] InnoDB: Reading tablespace information from the .ibd files...
2013-06-17 13:45:51 23252 [Note] InnoDB: Restoring possible half-written data pages
2013-06-17 13:45:51 23252 [Note] InnoDB: from the doublewrite buffer...
InnoDB: Doing recovery: scanned up to log sequence number 1600607
2013-06-17 13:45:51 23252 [Note] InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percent: 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 5
InnoDB: Apply batch completed
2013-06-17 13:45:52 23252 [Note] InnoDB: 128 rollback segment(s) are active.
2013-06-17 13:45:52 23252 [Note] InnoDB: Waiting for purge to start
2013-06-17 13:45:52 23252 [Note] InnoDB: 5.6.12 started; log sequence number 1600607
2013-06-17 13:45:52 23252 [Note] Server hostname (bind-address): '*'; port: 3306
2013-06-17 13:45:52 23252 [Note] IPv6 is available.
2013-06-17 13:45:52 23252 [Note]   - '::' resolves to '::';
2013-06-17 13:45:52 23252 [Note] Server socket created on IP: '::'.
2013-06-17 13:45:52 23252 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
130617 13:45:52 mysqld_safe mysqld from pid file /var/db/mysql/ASGH.pid ended
```


----------



## ShelLuser (Jun 17, 2013)

Well, judging from the logfile it seems you haven't configured MySQL just yet and now it's using it's default values. So the best way to start is to set up MySQL, start by setting up a configuration file (my.cnf), you can find good examples for it in /usr/local/share/mysql.

You may also want to look into mysql_config(1).

And finally, to set up your database environment in /var/db/mysql, the so called system tables, you'd want to look into mysql_install_db, this script takes care of setting up the initial system tables which your setup is currently missing.


----------



## bsps (Jun 17, 2013)

ShelLuser said:
			
		

> Well, judging from the logfile it seems you haven't configured MySQL just yet and now it's using it's default values. So the best way to start is to set up MySQL, start by setting up a configuration file (my.cnf), you can find good examples for it in /usr/local/share/mysql.
> 
> You may also want to look into mysql_config(1).
> 
> And finally, to set up your database environment in /var/db/mysql, the so called system tables, you'd want to look into mysql_install_db, this script takes care of setting up the initial system tables which your setup is currently missing.



*T*hanks for your fast reply*.*

Regarding the my.cnf I read itâ€™s not necessary as _MySQL_ will use default values. *H*owever *I* _copy_ one of example and edit it as below*:*

```
# For advice on how to change settings please see
# [url]http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html[/url]
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
 basedir = /usr/local/data/mysql/mysqldatabase/
 datadir = /usr/local/data/mysql/mysqldatabase/
# port = .....
# server_id = .....
# socket = .....                                      
                                                      
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
 join_buffer_size = 128M                              
 sort_buffer_size = 2M                                
 read_rnd_buffer_size = 2M                            
                                                      
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
```
and for the second step *I* get the below result when *I* run `mysql_install_db`:


```
mysql_install_db
FATAL ERROR: Could not find ./bin/my_print_defaults

If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.

If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.
```


----------



## ShelLuser (Jun 17, 2013)

It would seem that you have other issues which seem to interfere with MySQL as a whole, my theory at this time is that this limitation (or whatever it is) also disrupted the initial installation process.

First: Which version of FreeBSD are you using?  Also, just to rule things out: How exactly did you install MySQL, and which version did you get?

Finally, also important to know: what do you see when using this command `$ which my_print_defaults`?


----------



## bsps (Jun 17, 2013)

ShelLuser said:
			
		

> It would seem that you have other issues which seem to interfere with MySQL as a whole, my theory at this time is that this limitation (or whatever it is) also disrupted the initial installation process.
> 
> First: Which version of FreeBSD are you using?  Also, just to rule things out: How exactly did you install MySQL, and which version did you get?
> 
> Finally, also important to know: what do you see when using this command `$ which my_print_defaults`?



The FreeBSD version is 9.0. I try first using the package and this issue happens; then I `deinstall` and I try through ports and install the latest version 5.6. *A*lso I tried before many versions, 5 and above, and all have the same issue. *P*lease see the below result for the command 

```
# which my_print_defaults
/usr/local/bin/my_print_defaults
```

Thanks for your support.


----------



## SirDice (Jun 18, 2013)

bsps said:
			
		

> The FreeBSD version is 9.0.


Please upgrade to 9.1, 9.0 has been end-of-life since March 2013.

http://www.freebsd.org/security/unsupported.html


----------



## ShelLuser (Jun 18, 2013)

For starters I'm with @SirDice, you need to upgrade. Look into freebsd-update(8) or the relevant part in the FreeBSD handbook.

Because it's no longer supported there's no way for us to tell if the problems you're having are caused by the older version or something else.


----------



## JUStice (Jun 28, 2013)

If /usr/local/bin/my_print_defaults is the location of my_print_defaults, your basedir is likely to be /usr/local.

my.cnf:

```
..
basedir = [FILE]/usr/local[/FILE]
datadir = [FILE]/var/db/mysql[/FILE]
..
```

You have to double check the owner:group of /var/db/mysql, including files and sub folders. It must be mysql:mysql. Please post the output of `ls -al /var/db/mysql`.


----------

