[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Cannot find my.cnf file

Posted on 2008-11-09
13
Medium Priority
?
2,976 Views
Last Modified: 2013-12-15
Hi,

I have just set up a new installation of MySQL 5.0.63. I am reading some tutorials on securing the installation. The tutorials are referring to a main config file called my.cnf which I am not able to find. I run # find / -name my.cnf; and nothing comes up. I have looked in the main installation directory  /usr/local/apache/mysql and nothing, as well as, in the /etc directory there is nothing.

Please help me with this issue in setting up the file in the correct place with the correct references.

Thank you!

D
0
Comment
Question by:designitm
  • 7
  • 4
  • 2
13 Comments
 
LVL 88

Expert Comment

by:rindi
ID: 22917688
Normally it is in /etc/mysql/. How did you install MySQL? What distro? If you installed via your distro's package manager, the configuration would also have created that file, but if you installed some other way that isn't necessarily the case.
0
 

Author Comment

by:designitm
ID: 22917734
I installed it through source files and compiled it myself with these settings: ./configure --prefix=/usr/local/apache/mysql

The source files were obtained from mysql.com, for Linux, on a CentOs 5.+ system.

I had found the mysql.server script which I am now trying to set up as the service start up script when my systems boots. I am getting this error and "Starting MySQL. ERROR! Manager of pid-file quit without updating file." which I am not sure if it associates to my previous question or start a whole new one.

Thanks

D
0
 
LVL 88

Expert Comment

by:rindi
ID: 22917775
I would install MySQL via yum, except if you need that particular version (I don't know which version is standard with CentOS). Then all your configuration files should get created automatically.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:designitm
ID: 22917786
I had found the error problem. I had changed the mysql user from mysql to webmysql which gave errors. Now it is mysql and it runs, but I would like to change the mysql.pid file and place it in another location, as well as, finding the my.cnf file for setup?

Thanks,

D
0
 

Author Comment

by:designitm
ID: 22917791
I would do it with yum for simplicity, but then I am not learning how to install this properly from source.
0
 
LVL 88

Expert Comment

by:rindi
ID: 22917819
You can always stop MySQL and then just delete the PID file if it doesn't remove itself (stopping the daemon will also normally delete the PID). The location of the PID file is defined in the my.cnf file. As mentioned before, the file should normally be inside etc/mysql.
0
 

Author Comment

by:designitm
ID: 22918007
I guess the problem is, how does the mysql server know to retrieve the my.cnf file, if I make it in the /etc/ directory?

Thanks,
D
0
 
LVL 88

Expert Comment

by:rindi
ID: 22918042
If you want to find out lowlevel config details and info, then you should rather move from CentOS to Gentoo. Gentoo is a distro that compiles all apps from source, and it usually also includes the necessary how-to's and info about why etc. You will learn most that way.

http://gentoo.org
0
 

Author Comment

by:designitm
ID: 22918423
Thank you!

I will look into Gentoo. Would you know though how we tell the mysql server to use the my.cnf file?

Thanks D
0
 
LVL 26

Accepted Solution

by:
Umesh earned 2000 total points
ID: 22919185
For a binary distribution, look for the files in or under your installation directory. If you have a source distribution, look in the support-files directory. You can rename a copy of a sample file and place it in the appropriate location for use as a base configuration file. Regarding names and appropriate location, see the general information provided in

Filename                                      Purpose
/etc/my.cnf                                   Global options
SYSCONFDIR/my.cnf                   Global options
$MYSQL_HOME/my.cnf               Server-specific options
defaults-extra-file The file specified with --defaults-extra-file=path, if any
~/.my.cnf User-specific options

SYSCONFDIR represents the directory specified with the --sysconfdir option to configure when MySQL was built. By default, this is the etc directory located under the compiled-in installation directory. This location is used as of MySQL 5.0.21. (From 5.0.21 to 5.0.53, it was read last, after ~/.my.cnf.)



NO matter if you don't find such file then you can create your own file and place it under shown in above.. Typical option would be

Here is a typical global option file:

[client]
port=3306
socket=/tmp/mysql.sock

[mysqld]
port=3306
socket=/tmp/mysql.sock
key_buffer_size=16M
max_allowed_packet=8M

[mysqldump]
quick

The preceding option file uses var_name=value syntax for the lines that set the key_buffer_size and max_allowed_packet variables.

Here is a typical user option file:

[client]
# The following password will be sent to all standard MySQL clients
password="my_password"

[mysql]
no-auto-rehash
connect_timeout=2

[mysqlhotcopy]
interactive-timeout

To tell MySQL server to use optional file.. No need to tell this to mysql once its see the file is in standard location then it will use it.. bit still you want to know then below is the procedure



For example

mysqld_safe --defaults-file=/etc/my.cnf
0
 

Author Closing Comment

by:designitm
ID: 31514879
Awesome!
0
 

Author Comment

by:designitm
ID: 22920554
Hey, I would like to know if you can help me one more time:

I have re-installed mysql with these setting on the CentOs system:

--- install mysql ---

      yum install ncurses-devel

      ./configure --prefix=/usr/local/mysql --with-mysqld-user=mysql --localstatedir=/usr/local/mysql/data --with-unix-socket-path=/var/run/mysql.socket --with-openssl --with-vio
      
      --- install the default database information ---
      # /usr/local/mysql/bin/mysql_install_db
      
      --- transfer files and ensure permissions are the same as other service scripts in /etc/init.d/ directory ---
      # cp support-files/mysql.server /etc/init.d/mysql      

      --- create a user for this server that has limited access to any section but its own ---
      # groupadd mysql
      # useradd -d /usr/local/mysql/data -g mysql -c "MySQL Server Account" -c /bin/bash mysql
      # passwd mysql
      # tail -1 /etc/passwd
      # passwd -l mysql
      # usermod -s /bin/false mysql
      # grep mysql /etc/shadow
      # grep mysql /etc/passwd

# chown -R mysql DATADIR
# chgrp -R mysql DATADIR
# chmod -R go-rwx DATADIR



When starting the system with the mysql.server file I get

[root]# Connection to designitroom.com closed by remote host.

and an error file that looks like this:

081110 05:57:12  mysqld started
081110  5:57:12  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.
081110 05:57:12  mysqld ended


Any ideas?

Thanks

D
0
 
LVL 26

Expert Comment

by:Umesh
ID: 22920620
It seems you posted this question already.,....

Clearly a permission issue..

perror 13
OS error code  13:  Permission denied

Try this..

#chown -R mysql:mysql /usr/local/mysql/data


It seems you granted the rights

# chown -R mysql DATADIR
# chgrp -R mysql DATADIR
# chmod -R go-rwx DATADIR


BTW wots DATADIR? and wots the results of

# ls -l /usr/local/mysql/data



Also, can you post InnoDB specific settings(full my.cnf would be fine) from my.cnf?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
I have written articles previously comparing SARDU and YUMI.  I also included a couple of lines about Easy2boot (easy2boot.com).  I have now been using, and enjoying easy2boot as my sole multiboot utility for some years and realize that it deserves …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Suggested Courses
Course of the Month19 days, 17 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question