Where to put my.ini/my.cnf file for MySQL configuration?
Posted by: funkyfrank (179.43.144.---)
Date: August 02, 2015 04:33PM

Trying to configure mysqldump command from C:\wamp\bin\mysql\mysql5.6.17\bin to the following:

mysqldump -u db_username -p db_name (will add direction and path later..)

So I by looking at the my.ini file in C:\wamp\bin\mysql\mysql5.6.17 I learned that:

# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is C:\mysql\data) or
# ~/.my.cnf to set user-specific options.

OK.

So now for the mysqldump command to work without putting the password in the command line I can pass the password to MySQL via the configuration file I think.

So in the my.ini file I put:

# The following options will be passed to all MySQL clients
[client]
password = my_password
port = 3306
socket = /tmp/mysql.sock

and later down the line

[mysqldump]
user = my_username
password = my_password
quick
max_allowed_packet = 16M

OK.

So then I saved this file once as my.ini and tried putting it in the following locations:

C:\wamp\bin\mysql\mysql5.6.17
C:\wamp\bin\mysql\mysql5.6.17\data
C:\wamp\bin\mysql\mysql5.6.17\data\mysql
C:\wamp\bin\mysql\mysql5.6.17\bin

restarted WAMP, executed the command

mysqldump -u db_username -p db_name

but always get:


C:\wamp\bin\mysql\mysql5.6.17\bin>mysqldump -u my_username -p fabermaticdb
Enter password:
mysqldump: Got error: 1045: Access denied for user 'my_username'@'localhost' (using password: NO) when trying to connect

C:\wamp\bin\mysql\mysql5.6.17\bin>

OK.

So I thought it talks about my.cnf instead of my.ini.

OK.

So I go back to Notepad++ and save the my.ini file as my.cnf file with the changes above, leave everything else like it is and also try all of the 4 locations given above and still get that same error.

So, please, where do I put this my.ini or my.cnf file for MySQL to accept the password from inside the WAMP installation instead of asking me interactively what the password is?

Thanks for any help with this.

Best Regards

Version of Operating system? Windows 7 Ultimate 64bit
Version of Wamp Server installed? 2.5 32bit
Version of Apache you are running? 2.4.9
Version of MySQL you are running? 5.6.17
Version of PHP you are running? 5.5.12
What colour is your WampManager icon? Green
Host file localhost 127.0.0.1

New to WAMP?
Read this please: [forum.wampserver.com]

Options: ReplyQuote
Re: Where to put my.ini/my.cnf file for MySQL configuration?
Posted by: RiggsFolly (---.as43234.net)
Date: August 02, 2015 05:20PM

Frank,

Ok

Point1. DONT EVER EVER EVER, Duplicate my.ini all over the place.
It is impossible to maintain and support, and is just a BAD IDEA.


Simple solution, that takes into account the posibility you may one day use WAMPServers ability to have more than one version of MYSQL installed and be able to maintain the switchability.

Create a batch/command file called mysql_path.cmd

echo off

if %1.==. GOTO ERROR

PATH=%PATH%;c:\wamp\bin\mysql\mysql%1\bin
echo
echo -----------------------------------------------
mysql -V
echo -----------------------------------------------
echo
GOTO EndPHP

:ERROR
echo -----------------------------------------------
echo Parameter 1 should be something like 5.4.13 to use mysql5.4.13
echo -----------------------------------------------
:EndPHP

Copy this file into one of your existing folder that is ALREADY on your PATH so it can be found and run from anywhere.


Now you can open a command windows and just run
>mysql_path 5.6.17

And it will add the correct folder to the Windows PATH so you can run anything in the MYSQL/BIN folder from anywhere.



Point 2
Adding the default userid and password to the my.ini file is also a bad idea
Now anybody that walks up to your PC is an MYSQL admin on your machine.

It may sound trivial if you are just a single guy in his bedroom, who never see's anybody else.

That feature I am fairly sure was invented so you could give a default LOW LOW LEVEL access to anybody knowing that the account it would use COULD DO NO HARM



Point3. Leave the mysql ini file as my.ini

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote


Sorry, only registered users may post in this forum.