# Starting mysqld on FreeBSD



## dhenzler (Nov 20, 2017)

I'm good to go on Solaris  *svcadm enable mysql*  but that doesn't do anything on BSD.  Seems people have this problem a lot as I see many listings for mysql sock not found... 

The only way to NOT get that error is to have mysqld running.

So in FreeBSD ver 11.1 what do you do.

As well am workin on building the Apache, MySQL, PHP stack... are there limits to versions that are compatible ?  I just loaded the newest one for each.  Will be playing with Nextcloud and Wordpress.

Anyone ?


----------



## ShelLuser (Nov 20, 2017)

You'll need to edit /etc/rc.conf in order to enable MySQL. See also its rc file (located in /usr/local/etc/rc.d).

But just do what you'd normally do: Start the MySQL server, set up my.cnf so that your client knows where to find the socket (if the default doesn't suffice) and you're done.

In FreeBSD you'd normally start / stop services using the service(8) command. So, for example, `# service mysql-server start`.


----------



## dhenzler (Nov 20, 2017)

I tried that and it didn't work.  I've loaded mySQL8.0

Any other way to get it started ?


----------



## ShelLuser (Nov 20, 2017)

First of all keep in mind that databases/mysql80-server is an "in-dev" project and considered to be unstable. So you might be better off using the databases/mysql57-server port.

But when you say "doesn't work" what exactly are you referring to?  Because I read more comments about people who wonder about getting started with MySQL I decided to give this a try in my jail and I just can't understand what your issue could be.

When you start MySQL for the first time (for example by using `# service mysql-server onestart`) then it will create the initial database automatically. After that the server gets started and you can connect using the `mysql -u root` command.

So where do things stop working for you and how did you conclude as much?


----------



## dhenzler (Nov 21, 2017)

I've run mySQL for a while now... know when it's running by checking in "top"... see mysqld and the client works.

Not concerned about it being in-dev... I'm just screwing around with ZFS on FreeBSD and want to run some tests on this, and some other configurations.  I have MySQL 5.7 running on my production servers for Nextcloud and Wordpress apps.

I never said doesn't work related to MySQL, but to the startup instructions.  


> Have tried command line with and without "onestart"


. 
I know it runs, because `mysqld_safe` produced a PID file, and the screen showed activity that was completed.  Now it's just a matter of my getting used to a new set of commands for this and other things.  On Solaris it's easy... `svcadm enable mysql`..

Off Topic
Fighting getting Cinnamon started as well.  Perhaps there is a common problem.  I got the basic OS loaded, and started installing pkg's.  When I had no luck with any GUI, I loaded Gnome3, and read a little more.  Some of the docs gave good step by step.  I haven't messed with BSD for over 8 years.  Been living in Solaris land, and finally left when I realized my software wouldn't run on that platform.

Thanks for your reply... but thus far no dice...


----------



## dhenzler (Nov 21, 2017)

```
root@FBSD:~ # service mysql-server start
/etc/rc.conf: mysql-server_enable=YES: not found
/etc/rc.conf: mysql-server_enable=YES: not found
Cannot 'start' mysql. Set mysql_enable to YES in /etc/rc.conf or use 'onestart' instead of 'start'.

root@FBSD:~ # cat /etc/rc.conf
clear_tmp_enable="YES"
syslogd_flags="-ss"
sendmail_disable=YES
hostname="FBSD"
ifconfig_re0="DHCP"
ifconfig_re0_ipv6="inet6 accept_rtadv"
sshd_enable="YES"
moused_enable="YES"
mysql-server_enable=YES
gnome_enable=YES
gdm_enable=YES
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
zfs_enable="YES"
dbus_enable="YES"
hald_enable="YES"

root@FBSD:~ # service mysql-server onestart
/etc/rc.conf: mysql-server_enable=YES: not found
/etc/rc.conf: mysql-server_enable=YES: not found
/usr/local/etc/rc.d/mysql-server: WARNING: failed precmd routine for mysql
```
still no joy  wtf is *precmd*


----------



## SirDice (Nov 21, 2017)

It's 

```
mysql_enable="YES"
```

Handbook: 11.2. Starting Services


----------



## dhenzler (Nov 21, 2017)

I saw a flash on my screen.  Took a photo it went away quickly.  This could be the reason some of 
	

	
	
		
		

		
			





 my software isn't working.  Been fighting cinnamon desktop not running.  I get a bunch of "missing theme" files since trying to remove Gnome3 to force cinnamon to take over.  Little info on how to invoke the software... guess they figure we're all BSD aficionados.

You'll note the "mysql-server_enable="YES" is reported not working.  But in fact is there.

Maybe I should stay with Mint 18.2.  Everything works.  But I want a ZFS OS.


----------



## ShelLuser (Nov 21, 2017)

dhenzler said:


> You'll note the "mysql-server_enable="YES" is reported not working.


You should be aware that with Unix-like operating systems details matter.

You used YES without quotes, which isn't going to work.


----------



## dhenzler (Nov 21, 2017)

I've tried it both ways... with and without... no difference in results... still get same error message.  Go figure !


----------



## anlashok (Nov 21, 2017)

when you type `# service mysql-server start` it looks in/etc/rc.conf to find out what mysql-server initialisation options to run for mysql-server.

It is currently saying /etc/rc.conf: mysql-server_enable=YES: not found because there is not an initialisation command called mysql-server_enable in the initialisation script /usr/local/etc/rc.d/mysql-server, hence it complaining about not being able to find it.

You need 
	
	



```
mysql_enable="YES"
```
 in /etc.rc.conf and not 
	
	



```
mysql-server_enable="YES"
```

For Unix-like operating systems using the correct option/details is also important


----------



## ShelLuser (Nov 21, 2017)

Note that you can learn what to add to /etc/rc.conf by checking the appropriate rc script. So in this case /usr/local/etc/rc.d/mysql-server.  Although you use the script name when running service not all scripts use that same name within /etc/rc.conf, the actual "control statement" can be pretty much anything.

So if you installed something and want to automatically start it, always look at its rc script first to learn what to do.


----------



## dhenzler (Nov 22, 2017)

As much as I dislike Solaris for particular reasons.  I did like their *svcadm enable/disable* feature better than others.  If you had two or more instances of something like *apache2.2* and *apache2.4*, you enabled them together, but could disable the unwanted version with a little more specific description.

*BSD with ZFS* looks like it might do the job I want.  Although I believe it's overly complex to configure by comparison to others.  If it does the job, I'll learn to deal with it.  By the way the photo shows the *YES* without quotes whether you actually have them or not.  This made me think that perhaps I was entering my info into the wrong place.

Right now my cloud is running on Mint 18.2 BTRFS.  But I will evaluate the ZFS distro and go with the winner.

Thanks

Dave


----------



## dhenzler (Nov 23, 2017)

Not one single direct answer... I just love forums.


----------



## tobik@ (Nov 23, 2017)

dhenzler said:


> Not one single direct answer... I just love forums.


I'll try again.

rc-scripts are just shell scripts and they source /etc/rc.conf.  So syntax in it should follow the same syntax as shell scripts. mysql-server_enable=YES is not valid sh(1) syntax for a variable assignment.

Normally there is no need to manually edit /etc/rc.conf.  We have sysrc(8) for that. To enable MySQL just run `sysrc mysql_enable=YES`. Also remove the bad mysql-server_enable entry with `sysrc -x mysql-server_enable`

Once done MySQL will start the next time you boot, but you can start it now with `service mysql-server start`.



ShelLuser said:


> You used YES without quotes, which isn't going to work.


Yeah, it is.


----------



## dhenzler (Nov 23, 2017)

did as directed...  then rebooted... command as follows

```
root@FBSD:~ # service mysql-server start
/usr/local/etc/rc.d/mysql-server: WARNING: failed precmd routine for mysql
```


----------



## SirDice (Nov 23, 2017)

Make sure /var/db/mysql/ is completely empty. The precmd routine will set up the initial databases automatically but it will refuse to do so if it detects files (any file  or directory, it will even trip on a 'lost+found' directory)  in that directory.


----------



## dhenzler (Nov 24, 2017)

That was just perfect.  I learned something, and got mysql and apache24 operating.  Now messing with php71.  Can't seem to get it up  I have the php test directory in the apache folder.  so if/when it runs, it will verify it's specs

I admit to not doing a whole lot of reading on FreeBSD except for the cinnamon desktop issues I am working toward resolving.  Gnome pales in comparison.  It's not a deal breaker, but was a hope for since all of my desktops and servers are running it.

Thanks again for the info.

Am going to do some research on php, and call it a day.

D


----------



## dhenzler (Nov 24, 2017)

PHP running, and when I attempted to run phpmyadmin it required mysql5.7  Dumped mysql80 and loaded mysql56 previously without problems.  But moving to mysql57 has produced an error message again related to precre.

```
root@FBSD:/ # service mysql-server start
/usr/local/etc/rc.d/mysql-server: WARNING: failed precmd routine for mysql

root@FBSD:/ # cat /etc/rc.conf
clear_tmp_enable="YES"
syslogd_flags="-ss"
hostname="FBSD"
ifconfig_re0="DHCP"
ifconfig_re0_ipv6="inet6 accept_rtadv"
sshd_enable="YES"
moused_enable="YES"
gnome_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
zfs_enable="YES"
dbus_enable="YES"
hald_enable="YES"
devfs_system_ruleset="system"
gdm_enable="YES"
cups_enable="YES"
apache24_enable="YES"
php56_enable="YES"
sendmail_enable="NO"
mysql_enable="YES"
```
Hmmm  don't know where to look for the answer.


----------



## SirDice (Nov 24, 2017)

Yeah, the default is MySQL 5.7. For PHP it's 5.6. Have a look at /usr/ports/Mk/bsd.default-versions.mk for more defaults. If you want/need to deviate from those defaults you will have to build from ports or set up your own repository (that's fairly easy to do). The official packages are always built using the default settings and options. And to avoid running into a dependency hell it's best not to mix those two. 

If you set this in /etc/make.conf:

```
DEFAULT_VERSIONS+= mysql=8.0 php=7.1
```
And build everything from ports you can have everything based on the versions you want. 

As for the MySQL issue. Your /var/db/mysql directory contains initialized databases for 8.0, I'm guessing 5.7 can't make sense of that. The other way around is easier to deal with (5.7 -> 8.0). As this is still a new installation just remove all the files from /var/db/mysql and let the precmd routine automatically initialize it again, but now for 5.7.


----------



## dhenzler (Nov 24, 2017)

I originally loaded MySQL80 and PHP71, however I wasn't seeing a connect with Apache24.  Couldn't get the php to decode.  I use a phpinfo() file to detect and display the version I'm using.

So I backed off to MySQL56, and PHP56.  Easy to do, the old files removed during install... reboot and joy!

But then discovered that PHPmyAdmin requires MySQL57.  Install was easy enough, but had the precmd error.   I have other things to do in life besides read every line on every page that comes up on my browser... so backed off to 56 again to see if that still worked.. Yes!  it did... so have a couple problems... Apache isn't talking to 56, and if 57 is required to use PHPmyAdmin... then I'll have to have it.

Maybe next week.  Only a few days left before my hip surgery... don't know what that will bring.


----------



## dhenzler (Nov 25, 2017)

my frustration continues.  No docs found on Internet regarding php ext-20-zip.ini, and the dozen or so others that I likely need to put somewhere.  Trying to setup Nextcloud and it requires about 6 or more of these.

Lousy documentation.  Poor coverage on the Internet

*PHP Version 5.6.31*
System FreeBSD FBSD 11.1-RELEASE FreeBSD 11.1-RELEASE #0 r321309: Fri Jul 21 02:08:28 UTC 2017 root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC amd64
Build Date Nov 16 2017 18:23:13
Configure Command './configure' '--with-layout=GNU' '--localstatedir=/var' '--with-config-file-scan-dir=/usr/local/etc/php' '--disable-all' '--enable-libxml' '--enable-mysqlnd' '--with-libxml-dir=/usr/local' '--with-pcre-regex=/usr/local' '--with-zlib-dir=/usr' '--program-prefix=' '--disable-cli' '--disable-cgi' '--with-apxs2=/usr/local/sbin/apxs' '--with-regex=php' '--with-zend-vm=CALL' '--prefix=/usr/local' '--mandir=/usr/local/man' '--infodir=/usr/local/info/' '--build=amd64-portbld-freebsd11.0' 'build_alias=amd64-portbld-freebsd11.0' 'CC=cc' 'CFLAGS=-O2 '-pipe' '-fstack-protector' '-fno-strict-aliasing'' 'LDFLAGS= '-fstack-protector'' 'LIBS=-lpthread' 'CPPFLAGS=' 'CPP=cpp' 'CXX=c++' 'CXXFLAGS=-O2 '-pipe' '-fstack-protector' '-fno-strict-aliasing'
Server API Apache 2.0 Handler
Virtual Directory Support disabled
Configuration File (php.ini) Path /usr/local/etc
Loaded Configuration File (none)
Scan this dir for additional .ini files /usr/local/etc/php
Additional .ini files parsed /usr/local/etc/php/ext-18-session.ini, /usr/local/etc/php/ext-20-bz2.ini, /usr/local/etc/php/ext-20-ctype.ini, /usr/local/etc/php/ext-20-filter.ini, /usr/local/etc/php/ext-20-gd.ini, /usr/local/etc/php/ext-20-json.ini, /usr/local/etc/php/ext-20-mbstring.ini, /usr/local/etc/php/ext-20-mysql.ini, /usr/local/etc/php/ext-20-mysqli.ini, /usr/local/etc/php/ext-20-openssl.ini, /usr/local/etc/php/ext-20-xml.ini, /usr/local/etc/php/ext-20-zip.ini, /usr/local/etc/php/ext-20-zlib.ini
PHP API 20131106
PHP Extension 20131226
Zend Extension 220131226
Zend Extension Build API220131226,NTS
PHP Extension Build API20131226,NTS
Debug Build no
Thread Safety disabled
Zend Signal Handling disabled
Zend Memory Manager enabled
Zend Multibyte Support provided by mbstring
IPv6 Support enabled
DTrace Support disabled
Registered PHP Streams php, file, glob, data, http, ftp, compress.bzip2, https, ftps, zip, compress.zlib
Registered Stream Socket Transports tcp, udp, unix, udg, ssl, sslv3, tls, tlsv1.0, tlsv1.1, tlsv1.2
Registered Stream Filters string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, bzip2.*, zlib.*
This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
*Configuration*
*apache2handler*
Apache Version Apache/2.4.27 (FreeBSD) PHP/5.6.31
Apache API Version 20120211
Server Administrator you@example.com
Hostnameort 127.0.0.1:0
User/Group www(80)/80
Max Requests Per Child: 0 - Keep Alive: on - Max Per Connection: 100
Timeouts Connection: 60 - Keep-Alive: 5
Virtual Server No
Server Root /usr/local
Loaded Modules core mod_so http_core mod_authn_file mod_authn_core mod_authz_host mod_authz_groupfile mod_authz_user mod_authz_core mod_access_compat mod_auth_basic mod_reqtimeout mod_filter mod_mime mod_log_config mod_env mod_headers mod_setenvif mod_version prefork mod_unixd mod_status mod_autoindex mod_dir mod_alias mod_php5
*Directive* *Local Value* *Master Value*
engine 1 1
last_modified 0 0
xbithack 0 0
*Apache Environment*
*Variable* *Value*
HTTP_HOST localhost
HTTP_USER_AGENT Mozilla/5.0 (X11; FreeBSD amd64; rv:56.0) Gecko/20100101 Firefox/56.0
HTTP_ACCEPT text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_ACCEPT_LANGUAGE en-US,en;q=0.5
HTTP_ACCEPT_ENCODING gzip, deflate
HTTP_REFERER http://localhost/php/
HTTP_DNT 1
HTTP_CONNECTION keep-alive
HTTP_UPGRADE_INSECURE_REQUESTS 1
PATH /sbin:/bin:/usr/sbin:/usr/bin
LD_LIBRARY_PATH /usr/local/lib
SERVER_SIGNATURE _no value_
SERVER_SOFTWARE Apache/2.4.27 (FreeBSD) PHP/5.6.31
SERVER_NAME localhost
SERVER_ADDR ::1
SERVER_PORT 80
REMOTE_ADDR ::1
DOCUMENT_ROOT /usr/local/www/apache24/data
REQUEST_SCHEME http
CONTEXT_PREFIX _no value_
CONTEXT_DOCUMENT_ROOT /usr/local/www/apache24/data
SERVER_ADMIN you@example.com
SCRIPT_FILENAME /usr/local/www/apache24/data/php/phpinfo.php
REMOTE_PORT 42230
GATEWAY_INTERFACE CGI/1.1
SERVER_PROTOCOL HTTP/1.1
REQUEST_METHOD GET
QUERY_STRING _no value_
REQUEST_URI /php/phpinfo.php
SCRIPT_NAME /php/phpinfo.php
*HTTP Headers Information*
*HTTP Request Headers*
HTTP Request GET /php/phpinfo.php HTTP/1.1
Host localhost
User-Agent Mozilla/5.0 (X11; FreeBSD amd64; rv:56.0) Gecko/20100101 Firefox/56.0
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language en-US,en;q=0.5
Accept-Encoding gzip, deflate
Referer http://localhost/php/
DNT 1
Connection keep-alive
Upgrade-Insecure-Requests 1
*HTTP Response Headers*
X-Powered-By PHP/5.6.31
*bz2*


----------



## dhenzler (Nov 25, 2017)

Upon going to *http://localhost/wp-admin/setup-config.php*

Dependency check
Dependencies not found.
The following PHP modules are required to use Nextcloud:​
dom

XMLWriter

iconv

SimpleXML

HASH Message Digest Framework

curl

PDO

Please contact your server administrator to install the missing modules.

*I am he... (so sad... don't know what to do)*
*I think these are required... but where?*
*/usr/local/etc/php*
/usr/local/etc/php/ext-18-session.ini
/usr/local/etc/php/ext-20-bz2.ini
/usr/local/etc/php/ext-20-ctype.ini
/usr/local/etc/php/ext-20-filter.ini
/usr/local/etc/php/ext-20-gd.ini
/usr/local/etc/php/ext-20-json.ini
/usr/local/etc/php/ext-20-mbstring.ini
/usr/local/etc/php/ext-20-mysql.ini
/usr/local/etc/php/ext-20-mysqli.ini
/usr/local/etc/php/ext-20-openssl.ini
/usr/local/etc/php/ext-20-xml.ini
/usr/local/etc/php/ext-20-zip.ini
/usr/local/etc/php/ext-20-zlib.ini


----------



## ShelLuser (Nov 25, 2017)

First look into the extensions port. For example: lang/php56-extensions. This will provide a selection of commonly used php modules. So: /usr/ports/lang/php56-extensions.

And second: you can always use the search function if you need to. `make search name=<name>` or `make search key=<keyword>`, this can be executed from /usr/ports and can be an efficient way to search for something.

Still, your problem is probably solved with the extension port since it contains most of the stuff you mentioned.


----------

