enable mysql query log - mysql

I am using wamp wampserver2.5-Apache-2.4.9-Mysql-5.6.17-php5.5.12-32b mysql version is 5.6.17. It provides mysql and php servers.
I want to track (see) the queries recently executed (from anywhere i.e a web page, desktop app or any service using mysql on mysqlserver.
I know "what to do" = > i have to enable query logging as told by http://dev.mysql.com/doc/refman/5.6/en/query-log.html
But i dont know "how to do" though i have seen How to enable MySQL Query Log?
but i am unable to find my.cnf anywhere. What i have is my.ini in wamp\bin\mysql\mysql5.6.17
As i use wamp so I am not familiar with mysql console. I want to know how (where) to set
general_log_file=/path/to/query.log

Using the WAMPServer menu system edit the my.ini file. WAMPServer uses a my.ini and not a my.cnf
(left click wampmanager) wampmanager->MySQL->my.ini
This will open the correct my.ini file with notepad.
Check for these parameters and if they dont exists add them under the section heading [wampmysqld] or if you are using 64bit WAMPServer the [wampmysqld64]
NOTE: If you are using the 64bit WAMPServer you may have to change [wampmysqld] to [wampmysqld64] as the 64bit release had a little bug in it and this section header was not set correctly. The filename may also be c:\wamp64 on 64bit WAMPServer systems.
log-output = FILE
general_log = 1
general_log_file=C:/wamp/logs/general-query.log
Save the file and then restart MySQL Server (restart WAMP in your case)
Check in the C:\wamp\logs folder for the new general-query.log file.

If 64bit version, be sure the log will be created in
"C:/wamp64/logs/general-query.log"
instead of "C:/wamp/logs/general-query.log".

Related

My SQL installed in `Program Files` and can't see the `my.ini` files

In my machine (Windows 10) two MySQl versions are needed. The Project "A" is running in XAMPP. When I've started my second project, I've stopped the first SQL services and installed MySQL 5.7. In that I need to set lower_case_table_names = 2 for the case sensitive method.
I google it, they say:
open your MySQL configuration file: [drive]\xampp\mysql\bin\my.ini
look up for: # The MySQL server [mysqld]
add this right below it: lower_case_table_names = 2
save the file and restart MySQL service
I know that it's for XAMPP only.
But I've installed MySQL in Program Files. Here I couldn't able to see C:\Program Files\MySQL\MySQL Server 5.7\bin\my.ini files. Then where should I set the lower_case_table_names = 2 value?
Thanks in advance.
In XAMPP use the "Control Panel" to find the mysql.ini config file.
In a regular Windows install of MySQL the .ini file sits in C:\ProgramData\MySQL\MySQL Server.

change root folder of the mysql database for wamp

I am aware that www is the root folder for the WAMP all sites content and its changeable.
How about wamp's folder for all its existing databases? Can we redirect its location as well? Are they even exist?
I tried to google it and surprising find no result of the folder location for databases in MySQL or wamp,
What I searched:
change root folder of the mysql database for wamp
By default WAMPServer puts all databases in wamp\bin\mysql\mysqlx.y.x if they are INNODB databases and wamp\bin\mysql\mysqlx.y.x\data for MYISAM databases and some parts of the INNODB databases.
MySQL is controlled by a file called my.ini or my.cnf but WAMPServer uses the my.ini file which is found by using the wampmanager menu system
left click wampmanager -> MySQL -> my.ini
or manually editing the file wamp\bin\mysql\mysqlx.y.x\my.ini. Stick to using the wampmanager menus.
The location of the databases is controlled by a parameter called datadir example datadir=d:/wamp/bin/mysql/mysql5.6.17/data
One word of warning, if you are using the WAMPServer 2.5 64bit version there is a minor bug in this file. The section header [wampmysqld] shoudl be chnaged to [wampmysqld64]
**But only if you are using the 64bit version of WAMPServer.
While you are in the my.ini file it is also a good idea to change this parameter which controls the language that error messages are shown in
lc-messages=fr_FR
to your prefered language Eg
lc-messages=en_GB

How do I change read-only variables in MySQL running on WAMP

I need to change the "ft_min_word_len" server variable in MySQL.
I have tried adding it to the "my.ini" folder my MySQL folder and restarted MySQL, however it did not seem to update the server variable.
I am running MySQL 5.6.17 on WAMP 2.5.
Any help is much appreciated.
If you are running WAMPServer 2.5 64bit there was a mistake in the my.ini file that may explain why it is not picking up your change!
Edit my.ini ( using the wampmanager menu system ), look for this in that file
[wampmysqld]
And change it to
[wampmysqld64]
This section header should match the service name used by MySQL which in the 64 bit version of Wampserver2.5 is wampmysqld64

XAMPP USB Lite - How to change or upgrade MySQL 5.5 to 5.6?

Since XAMPP supports only MySQL 5.5, I would like to upgrade the MySQL server to version 5.6 (beta) in the currently stable 1.7.7, or 1.8.1 version of XAMPP.
Can I do that? If so, how?
(Just to clarify it: coping and switching the mysql folder won't make it.)
I have found the perfect way of doing it without any side affects and also works perfectly with xampp control panel...
before you begin, make sure you backup your databases to files and also export all users to a file
be sure to stop mysql there is no need to uninstall the service
Step 1: Download the new version on MySQL install version or zip.(install version prefered since it is considerably smaller)
Step 2: Install MySQL to C:\TEMP. Install only the MySQL server
Step 3:Do not run advance options. do not let it install service. no configuration is required.
Step 4: Go to C:\TEMP, look for installation and copy the following folders "bin, include, lib, share, support-files". be absolutely certain not to copy data
Once copied, go to your xampp folder, rename mysql folder to mysql_old. create new mysql folder then paste the contents that were copied
Step 5: Go to mysql_old and copy the data folder and paste it into your new mysql folder as well
Step 6: go to the bin folder within mysql that is located within xampp and create a blank my.ini file.
If you are upgrading to version 5.6.11 which is what I did, then all you have to do is write a few commands which I have at the bottom of this instruction
step 7: click start next to MySQL on the xampp control panel and it should start normally assuming to you followed to instructions properly.
Once done, you can uninstall the mysql package that you had installed to C:\TEMP
Any questions or problems, message me or post back!
BY WAY, the key is having a proper my.ini file
here is mine:
[client]
port=3306
socket="C:/xampp/tmp/mysql.sock"
[mysqld]
port= 3306
socket = "C:/xampp/tmp/mysql.sock"
pid_file = mysql.pid
skip-federated
explicit_defaults_for_timestamp
basedir="C:/xampp/mysql"
datadir="C:/xampp/mysql/data"
tmpdir = "C:/xampp/tmp"
log-output = FILE
log-error = mysql_error.log
general-log
general_log_file = mysql_general.log
slow-query-log
slow_query_log_file = mysql_slow.log
default-time-zone = -5:00
long_query_time = 2
plugin_dir = "C:/xampp/mysql/lib/plugin"
server-id = 2
#ft_stopword_file = "C:/xampp/mysql/bin/mysql_ft_stopword_file.ini"
ft_min_word_len = 3
ft_max_word_len = 50
character-sets-dir = "C:/xampp/mysql/share/charsets"
character-set-server = utf8
collation-server = utf8_unicode_ci
innodb_ft_max_token_size = 50
innodb_ft_min_token_size = 3
innodb_ft_enable_stopword = off
key_buffer_size = 8M
query_cache_type = 1
query_cache_size = 4M
query_cache_limit = 4M
default-storage-engine = InnoDB
[mysql]
default-character-set=utf8
I followed all the steps listed above and I was able to start mysql NOT from the xampp control panel but from Windows Control Panel -> Systems and Security -> Administrative Tools -> Component Services (Or simply search for component services on windows search). Once you have launched component services, click "services". It will list all the services on your computer. Look for mysql, click on it and click "start". That did the magic for me!! Enjoy.
the safest and most xampp-compatible way, i did following for upgrading :
first of all, stop your existing Xampp processes like Apache and MySQL and other MySQL related Xampp installed services. just stop the services, DONT uninstall them.
1) look which MySQL-version you want/need to upgrade to. Some packages like MOODLE 1.7+ requires a minimum MySQL version ( f.e. 5.5.31 ).
2) download the Xampp installer which includes the MySQL version which you want to upgrade to. the list of Xampp version an which MySQL version they includes, you can find here.
3) install the new version of Xampp on another pc
4) on this new install of Xampp on the other pc, go to c:/xampp/mysql and COPY the following maps :
bin
include
lib
share
5) on your old xampp machine, rename the c:/xampp/mysql map to f.e. c:/xampp/mysql_backup and make a new empty map c:/xampp/mysql
6) now PASTE the previous COPIED maps from 4) above, in this new c:/xampp/mysql map.
7) go to c:/xampp/mysql_backup map and copy the BIN map, and past it in c:/xampp/mysql
8) compare and complete/modify a few settings ( like buffer sizes or DIR locations) in the new my.ini file which is located in c:/xampp/mysql/bin map with the old my.ini file which is in c:/xampp/mysql_backup/bin.
don't delete the c:/xampp/mysql_backup map too fast, errors can occur later on, so you can consult some files later on perhaps. consider it as a backup.
start PHP and MySQL through the Xampp control panel, and everything should work as before.
the advantage of this method, is that you use a MySQL build which is 100% compatible with Xampp CP and phpmyadmin.
Using a MySQL msi-installer can give some problems to get it working. the advantage though, is that you can upgrade it very easy in the future, using an updated MySQL msi-installer just with a few clicks, instead of copy-pasting maps and files ...
You can and you shouldn't encounter any problems. AFAIK whole XAMPP is build from blocks of separate services. MySQL resides (whole, with data, configuration, etc.) in mysql subfolder. I must admit, that I'm writing theoretically, cause I haven't been doing something like that (but I'm about to update phpMyAdmin and will use the same steps). But I would follow these steps:
Turn off everything about XAMPP (all servers you've started up).
If you have MySQL installed as service (tick "Svc" next to "MySQL" checked) -- uninstall it (uncheck).
Rename "mysql" folder inside XAMPP to "mysql_old" or something similar,
Create new "mysql" folder and install freshly new MySQL into it, using installer or guide provided by MySQL.
Configure, what you have to configure (inside MySQL), startup MySQL from XAMPP Control Panel or by other ways, install it as a service (mark "Svc" checkbox), if you wish so.
Check, if everything is OK. If yes, delete "mysql_old" folder from your XAMPP installation.
As for data migration (if you have any), you can do this by either exporting data from old MySQL (before installing new version, i.e. before executing above steps) using phpMyAdmin or similar tool and then importing it into new version of MySQL. Or you can consider a bruteforce mode, that is - copying whole contents of mysql_old/data folder to mysql/data folder. But no guarantee, this will work.

Change database files location in MySQL administrator?

I would like to change the database files location of MySQL administrator to another drive of my computer. (I run Windows XP SP2 and MySQL Administrator 1.2.8.)
--Under the startup variable --> General Parameters --> I changed Data directory: from C:/Program Files/MySQL/MySQL Server 5.0/data to D:/....., but after I stopped the service and restarted it, the following error appeared:
Could not re-connect to the MySQL Server.
Server could not be started.
Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
Has anyone else had this problem?
Normally it works like this:
shut down MySQL
change the [mysqld] and [mysqld_safe] datadir variable in the MySQL configuration
change the basedir variable in the same section.
move the location over
restart MySQL
If that doesn't work I have no idea. On linux you can try to move the socket to a new location too, but that shouldn't affect windows. Alternatively you can use a symbolic link on *nix what most people do I guess.
In Windows
Navigate to C:\Program Files\MySQL\MySQL Server 5.4\ and locate the my.ini file
Find the SERVER SECTION and go to approx line 76 and modify the datadir line to where you want your MySQL application data to be stored
Now navigate to C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server 5.4\data\ and copy and paste the mysql folder into your new location.
Restart the MySQL Server in Control Panel > Administrative Tools > Service
You also have to manually modify mysql's configuration (usually my.conf)
MySQL Administrator cannot be used for tasks like this. It is merely a tool for looking at MySQL servers, despite its name. Relocating data is described in many MySQL tutorials and in the manual IIRC. But basically it's just moving the data to a new location while the server is shut down and then correcting the paths in the servers config file.
After that you should be able to restart the server and connect MySQL Administrator to it.
Make sure you give the Network Service Full permissions in the security tab of Windows Explorer options. If the server can't read/write etc. to the selected folder the service will either not start or it will attempt a start and shut right down.