MySQL: "Found option without preceding group in config file" - mysql

I have a Windows machine on which I've moved the WAMP www and MySQL data directories to Dropbox.
Those Dropbox folders have downloaded to my Ubuntu laptop.
I'd like to run the websites in /home/me/Dropbox/WAMP/WWW on my Ubuntu laptop using the MySQL data in /home/me/Dropbox/WAMP/SQL/Data.
I've edited /etc/mysql/my.cnf:
datadir=/home/me/Dropbox/WAMP/SQL/Data
I've edited /etc/apache2/sites-available/default.conf:
<VirtualHost *:80>
DocumentRoot "\home\me\Dropbox\WAMP\WWW\site"
ServerName www.site.dev
ServerAlias www.site.dev
<Directory "\home\me\Dropbox\WAMP\WWW\site">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I've edited /etc/hosts:
127.0.0.1 www.site.dev
I've restarted apache2, and when I run www.site.dev in my browser, I am taken to the default apache2 index.html.
When I run >mysql start, I receive:
mysql: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf at line 23!
mysql: [ERROR] Fatal error in defaults handling. Program aborted!
Line 23 of /etc/mysql/my.cnf is:
datadir=/home/me/Dropbox/WAMP/SQL/Data
Help appreciated.
From this answer, I've opened /etc/mysql/my.cnf in Sublime Text editor, and saved it as UT-8 (without BOM), and the issue remains.

Please add [mysqld] at the top of my.cnf and then restart mysql server.
service mysql restart

the file my.cnf should be saved as ANSI encode,and [mysqld] group at the start of the file.

Related

Found option without preceding group in config file /etc/my.cnf at line 1

I haven't found anything online that's helped me address this error. I had to uninstall mysql, and I used this guide to uninstall. Then I reinstalled it. I got this error:
mysqld: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1.
mysqld: [ERROR] Fatal error in defaults handling. Program aborted!
So I uninstalled again, and attempted to uninstall the my.cnf file as well. After reinstalling a second time, I opened my.cnf and my.cnf.default files and [mysqld] is at the very top, with nothing (no comments or space) above it. I also checked to make sure that the files are in UTF-8. I still get this error when running brew postinstall mysql.
Here's what my.cnf file looks like, I moved the comments to the bottom to see if it would fix it:
[mysqld]
bind-address = 127.0.0.1
mysqlx-bind-address = 127.0.0.1
# Default Homebrew MySQL server config
# Only allow connections from localhost
If anyone has any insight that would be greatly appreciated. I'm running MacOS Big Sur.

mysqld ignoring my.cnf (mysql 5.6 on Ubuntu 16.04 Server)

I installed mysql 5.6 on Ubuntu Server 16.04 using this method: https://askubuntu.com/questions/762384/install-mysql-5-6-on-ubuntu-16-04
But i'm having trouble getting mysqld to read /etc/mysql/my.cnf
Specifically i'm trying to set it up for an Atlassian Confluence installation where I have to add in these settings:
[mysqld]
character-set-server=utf8
collation-server=utf8_bin
default-storage-engine=INNODB
max_allowed_packet=256M
innodb_log_file_size=2G
I've checked mysqld --help --verbose and it has the my.cnf in its path. Here's the relevant output:
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf The following
groups are read: mysqld server mysqld-5.6
I know that mysql is reading the file because if I change [mysqld] to [mysql] the arguments are correctly printed when I run mysql --print-defaults also if I put a wrong line in the file mysql will fail to start and tell me where the syntax error is. However mysqld does not report any arguments for mysqld --print-defaults or tell me about syntax errors in the file.
What else can I try?
Solved:
my.cnf was a symbolic link. I deleted it and made it an actual file. Now mysqld --show-defaults is working! So apparently mysql will follow the symlink but mysqld will not. Good to know.
my.cnf was a symbolic link. I deleted it and made it an actual file. Now mysqld --show-defaults is working. So apparently mysql will follow the symlink but mysqld will not.
For mysqld as I know only hard links works. Or maybe you just had wrong permission, on original my.cnf file to which you put symbolic link.

How to put wildcard entry into /etc/hosts?

I recently wanted to point all subdomains for a test domain, let's say example.com to the localhost. Is there a way to point all requests on *.example.com to resolve to 127.0.0.1
It happens that /etc/hosts file doesn't support wild card entries.
You'll have to use other services like dnsmasq. To enable it in dnsmasq, just edit dnsmasq.conf and add the following line:
address=/example.com/127.0.0.1
use dnsmasq
Assuming that you're using a Debian-based dist(ubuntu, mint..), check if it's installed with
(sudo) systemctl status dnsmasq
If it is just disabled, start it with
(sudo) systemctl start dnsmasq
If you have to install it, write
(sudo) apt-get install dnsmasq
To define domains to resolve edit /etc/dnsmasq.conf like this.
address=/example.com/127.0.0.1
to resolve *.example.com
! You must reload dnsmasq to take effect for the changes !
systemctl reload dnsmasq
Here is the configuration for those trying to accomplish the original goal (wildcards all pointing to same codebase -- install nothing, dev environment ie, XAMPP)
hosts file (add an entry)
file: /etc/hosts (non-windows)
127.0.0.1 example.local
httpd.conf configuration (enable vhosts)
file: /XAMPP/etc/httpd.conf
# Virtual hosts
Include etc/extra/httpd-vhosts.conf
httpd-vhosts.conf configuration
file: XAMPP/etc/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin admin#example.local
DocumentRoot "/path_to_XAMPP/htdocs"
ServerName example.local
ServerAlias *.example.local
# SetEnv APP_ENVIRONMENT development
# ErrorLog "logs/example.local-error_log"
# CustomLog "logs/example.local-access_log" common
</VirtualHost>
restart apache
create pac file:
save as whatever.pac wherever you want to and then load the file in the browser's network>proxy>auto_configuration settings (reload if you alter this)
function FindProxyForURL(url, host) {
if (shExpMatch(host, "*example.local")) {
return "PROXY example.local";
}
return "DIRECT";
}

localhost/phpmyadmin giving page not found error

I'm running wampserver.
I had a mysql server crash, and the wampmysqld service would not start up. Also, localhost/phpmyadmin did not show phpmyadmin but gave me a 403 error. I installed the mysql-addon for another mysql version. Then I went to the wampserver icon and did Mysql > Version > and selected the add-on version I'd just downloaded.
This helped, wampmysqld was able to start up, the wampserver icon was able to go green all the way, and my application is working. However, phpmyadmin is giving a 404 error. How do I fix this?
phpmyadmin.conf is:
Alias /phpmyadmin "c:/wamp/apps/phpmyadmin3.3.9/"
# to give access to phpmyadmin from outside
# replace the lines
#
# Order Deny,Allow
# Deny from all
# Allow from 127.0.0.1
#
# by
#
# Order Allow,Deny
# Allow from all
#
<Directory "c:/wamp/apps/phpmyadmin3.3.9/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
I changed c:/ to d:/ as per the location of phpmyadmin on my machine and restarted all services. But I'm still getting the same error.
You need to configure your apache2.conf to make phpMyAdmin works.
sudo nano /etc/apache2/apache2.conf
Then add the following line to the end of the file.
Include /etc/phpmyadmin/apache.conf
Then restart apache
/etc/init.d/apache2 restart
When you install a new phpmyadmin, or anything at all that refreshes the state of the apache.conf, there is usually need to retrace all previous manual inclusions in the config file.
Hence, given that when phpmyadmin is installed like in this tutorial, you added a line in the /etc/apache2/apache2.conf it becomes necessary to repeat that step:
Hence, running the command
sudo nano /etc/apache2/apache2.conf
and the including the following line at the end of the opened config file
Include /etc/phpmyadmin/apache.conf
usually solves this problem.
Remember to hit CTRL+O to save your changes, and then CTRL+X to close the open file.
Lastly, restart apache to let your new configuration take effect:
sudo systemctl restart apache2
That's it!
Start wamp or xamp make sure the icon color change to green for wamp. This time open it in another browsers not Internet explorer . it should work

Does MySQL included with MAMP not include a config file?

I can't seem to find the my.cnf or other config file for the MySQL that comes with MAMP. Does it not include one?
The MySQL server of MAMP (not PRO) will be started without any my.cnf file. But you can create your own my.cnf file.
Stop servers
Create a my.cnf file in /Applications/MAMP/conf/
Add your content in to my.cnf
Save my.cnf
Start servers
You do not have to put a complete configuration in the my.cnf file. You can just add parts of a configuration ... for example:
[mysqld]
max_allowed_packet = 64M
Some standard my.cnf variants can be found at /Applications/MAMP/Library/support-files/
Invoking mysqld --verbose --help | less on the MAMP mysqld binary reports:
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /Applications/MAMP/conf/my.cnf ~/.my.cnf
Copy one of the variants in /Applications/MAMP/Library/support-files/ to one of the locations in mysqld's search order above, and you should be good to go after restarting the daemon.
Since MAMP server generates my.cnf dynamically on MAMP server startup, it's best to use the following steps to add or edit the MySQL configuration:
Stop MAMP server
Goto Files > Edit Template > MySQL
Make the necessary changes and save
Restart MAMP
I tried this on MAMP PRO 3.5.
For MAMP 3.5 on Mac El Capitan, only this worked for me:
Stop servers
Create a my.cnf file in /Applications/MAMP/Library/
Add your content into my.cnf like
[mysqld]
max_allowed_packet = 64M
Save my.cnf
Start servers
Not required to change ownership of file, it should work. Verify by running SHOW VARIABLES in phpmyadmin and look for your changed setting.
No, it doesn't come with the my.cnf file
I found that MAMP PRO will create a my.cnf by default on startup under the MAMP/tmp directory if a ~/my.cnf is not provided ... grepping ps aux you may find the default location under /Applications/MAMP/tmp/my.cnf ...
ps aux | grep mysql
Which provided the following...
root 284 0.0 0.1 2435544 532 ?? Ss 12:00AM 0:00.06 /bin/sh /Applications/MAMP/Library/bin/mysqld_safe
--defaults-file=/Applications/MAMP/tmp/mysql/my.cnf
--port=8889 --socket=/Applications/MAMP/tmp/mysql/mysql.sock
--user=mysql --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid
--log-error=/Applications/MAMP/logs/mysql_error_log.err
--tmpdir=/Applications/MAMP/tmp/mysql/tmpdir
--datadir=/Library/Application Support/appsolute/MAMP PRO/db/mysql