Mysql – FreeBSD default MySQL basedir, port, etc., for the.cnf

freebsdmy.cnfMySQL

I'm working on a FreeBSD 9.2 server and have run mysqltuner.pl to check the memory and cache needs of MySQL. Now I need to add a my.cnf file to FreeBSD so it uses that instead of the auto cnf file.

I can copy the my-default.cnf this way:

cp /usr/local/share/mysql/my-default.cnf /usr/local/etc/my.cnf

and then my.cnf will load.

The my-default.cnf file shows these values (which will carry over to my.cnf):

# 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

# *the above innodb line I can set*

# *But where do I get the values below?*

# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....

Where do I get the values above? I know they must come from the current MySQL server, but how do I find these settings?

Should this question be at https://dba.stackexchange.com/ ?

Best Answer

You can get your current configuration by login to mysql and run query

SHOW VARIABLES;

To search specific configuration, you can use SQL syntax. For example to know current datadir use:

SHOW VARIABLES LIKE '%datadir%';

Reference: Official MySQL documentation