change root folder of the mysql database for wamp - mysql

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

Related

I can't find the file "my.cnf" or "my.ini"

I installed version 8 of MySQL and I can't find the configuration file
I was reading and everyone says that it is inside the "MySQL Server x.0" folder, but in my case it does not appear, neither inside the "etc" or "bin" folder
How I found mine was like this;
mysqld --help --verbose | grep my.cnf
I guess you are on Windows because of the "MySQL Server x.0" folder name (on Mac & Linux, this folder name does not contain spaces by default).
No configuration file is created after a standard installation. You may create one if you have the need to specify any options. Otherwise every option has a default setting built into the MySQL Server.
On Windows, the MySQL Server searches several locations for the configuration file, so you can put the file in any of those locations.
See documentation for a list of the locations the server searches for the configuration file on Windows:
https://dev.mysql.com/doc/refman/8.0/en/windows-create-option-file.html
https://dev.mysql.com/doc/refman/8.0/en/option-files.html
Remember that after you edit the configuration file, you need to restart the MySQL Server. It reads the configuration options only when the server starts.
On Windows my.ini file will be auto generated when you install MySQL server. It will be located in a hidden directory ProgramData.
C:\ProgramData\MySQL\MySQL Server 8.0
In order to view these files you may need to show hidden items. To do that
Open file explorer > View > Tick Hidden Items

Use XAMPP-phpmyadmin database of windows in Linux XAMPP

I was on windows and using XAMPP(installed somewhere else than C:/ )
Now i have moved on to LINUX and installed LAMPP.
So, i have this XAMPP folder from windows and i copied the project files from htdocs and now i need the database which i didn't exported while i was on windows.
I tried to copy the phpmyadmin folder from the old XAMPP folder but couldn't get it to work.
So how can i access the previous OS phpmyadmin to use my existing databases -
using linux (MINT - rosa-cinnamon)
Thanks in Advance !
If you want to move databases between hosts - especially when there are differences in the MySQL daemon version, operating systems (-versions) or storage schema - you should create a MySQL dump at host A and import it on host B: http://dev.mysql.com/doc/refman/5.7/en/mysqldump-sql-format.html
If this is no option for you anymore, you can try to move the old MySQL data directory (Configured in my.ini on windows, somewhere in the xampp directory) to the location where the new MySQL daemon stores its data files (Normally configured at /etc/mysql.my.cnf). A few more hints on this:
Ensure to modify the file permissions on the data files at the new location that the MySQL daemon can work with them.
On Windows, MySQL table names are case insensitive. On Linux they are case sensitive. Keep that in mind, if your application complains about missing tables.
And of course: Test this with backups only!

enable mysql query log

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".

MySql configuration file does not exist where WorkBench says so

I'm new to MySql. I have downloaded and installed MySql 5.6 together with the latest version of Workbench (6.2). Workbench says my configuration file is in
C:\Program Files\MySQL\MySQL Server 5.0\my.ini
This folder does not exist. I have
C:\Program Files\MySQL\MySQL Server 5.6
And inside this folder there is an .ini file called my-default.ini. How can I find the correct .ini file so I can change my variables?
The name and path used by MySQL Workbench by default is taken from a template. There are several templates for various server versions and platforms with typical config file locations. However, they may not always work. On Windows however, with standard installations (which are extremely common), there are only very few variations. The simplest way to have the correct config file stored in the connection settings is by changing the installation type in the System Profile settings for a connection:
The sample config file my-default.ini is just that, an example. The installer should have created a concrete config file in the ProgramData MySQL folder for your server, which is what MySQL Workbench will also use by default.
For someone wants to find the menu answered above,
It can be found when you right click on a connection instance box of your MySQL workbench home and go to edit connection.
I know this question posted 5 years ago, but I had looked for the menu as well and finally find it. I hope I can add a comment but I cannot due to the reputation;)

MySQL my.ini location

I have already seen
http://dev.mysql.com/doc/refman/4.1/en/mysql-config-wizard-file-location.html
how to know mysql my.cnf location
and
http://dev.mysql.com/doc/refman/5.1/en/option-files.html
But I am still stuck with the ages old question!
"Where is my my.ini"
I am using windows server 2008 with mysql 5.5.28. I installed the service using mysqld --install and I am able to use the mysql server using sqlyog. But unfortunately I am not able to find my.ini in installation directory or not in c:\ neither in c:\windows nor in data_dir query show variables like "mysql_home" returned nothing as well.
Any suggestions?
my.ini LOCATION ON WINDOWS MYSQL 5.6 MSI (USING THE INSTALL WIZARD)
Open a Windows command shell and type: echo %PROGRAMDATA%. On Windows Vista this results in: C:\ProgramData.
According to http://dev.mysql.com/doc/refman/5.6/en/option-files.html, the first location MySQL will look under is in %PROGRAMDATA%\MySQL\MySQL Server 5.6\my.ini. In your Windows shell if you do ls "%PROGRAMDATA%\MySQL\MySQL Server 5.6\my.ini", you will see that the file is there.
Unlike most suggestions you will find in Stackoverflow and around the web, putting the file in C:\Program Files\MySQL\MySQL Server 5.6\my.ini WILL NOT WORK. Neither will C:\Program Files (x86)\MySQL\MySQL Server 5.1. The reason being quoted on the MySQL link posted above:
On Windows, MySQL programs read startup options from the following
files, in the specified order (top items are used first).
The 5.6 MSI installer does create a my.ini in the highest priority location, meaning no other file will ever be found/used, except for the one created by the installer.
The solution accepted above will not work for 5.6 MSI-based installs.
Enter "services.msc" on the Start menu search box.
Find MySQL service under Name column, for example, MySQL56.
Right click on MySQL service, and select Properties menu.
Look for "Path To Executable" under General tab, and there is your .ini file, for instance, "C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin\mysqld.exe" --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.6\my.ini" MYSQL56
I've found mine in
\ProgramData\MySQL\MySQL Server 8.0\
(It is a hidden folder)
You can type win+R and write %PROGRAMDATA% to access that folder, or just enable show hidden folder.
You have to look I the folder C:\Program Files\MySQL\MySQL Server 5.5 but there is a problem. When you perform an MSI install of MySQL, my.ini is not created. There will be sample .ini files in that folder. In order to use one of them, say my-medium.ini, you need to do the following before a MySQL restart:
cd C:\Program Files\MySQL\MySQL Server 5.5
copy my-medium.ini my.ini
net stop mysql
net start mysql
Once, you do this, my.ini can be read by C:\Program Files\MySQL\MySQL Server 5.5\bin\mysql.exe.
Start MySQL Workbench, then Server -> Options File and look at bottom of the window; it will say something like "Configuration File: C:\ProgramData\MySQL\MySQL Server 5.6\my.ini"
(And note the subtle difference between "ProgramData" and "Program Files" - easy to gloss over if you're looking for a quick answer.)
Answered for only MySQL Workbench users,
You can find the my.ini file in windows at this location-
C:\ProgramData\MySQL\MySQL Server 5.6
the ProgramData folder is a hidden folder, so make the according setting to see that folder.
And open my.ini file as an administrator to edit and then save that.
In my case, the folder ProgramData was hidden by default on windows 7, so I was unable to find my.ini file.
After selecting show hidden files and folders option, I was able to find the my.ini file at the location: C:\ProgramData\MySQL\MySQL Server 5.6.
Display hidden files and folders on windows 7:
Right-click the Windows Logo button and choose Open Windows Explorer.
Click Organize and choose Folder and Search Options.
Click the View tab, select Show hidden files and folders and then clear the checkbox for Hide protected system operating files.
Click Yes on the warning and then click OK.
Press the windows key > type services > press enter > Look up mysql in the list > right click > properties > Path to Executable will have the location of the defaults file right below it (my.ini)
it is there at C:\Program Files\MySQL\MySQL Server 5.5 there are various .ini files with small, medium & large names. generally medium is used or it depends on your requirement.
programData is hidden folder so you have to change the option from setting to show hidden folder and then make the change in my.ini file present in that.
Be sure to update the correct my.ini file because it can waste a lot of your time if you keep updating wrong file.
You can look into service to see which my.ini is configured in this service.
Open your run console
type: services.msc
look for: mysql
right click
properties
where is written "path to executable", click and move the cursor to the right until you see the directory of my.ini, it's written "defaults-file-".
to reach it manually on your explore folders you have to enable the visualization of hidden elements (explore folder>top menu>visualize>visualize hidden elements)
as explained by this video
https://www.youtube.com/watch?v=SvCAa2XuQhg
on Windows if MySQL is install as a service you can change the binpath of the service. For example
sc config MySQL57 binPath= "\"C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld.exe\" --defaults-file=\"<myini path>" MySQL57"
space after binpath is important. You must escape double quotes
MySQL and MariaDB
According to the documentation of both MySQL and MariaDB you need to run mysql with --help --verbose to know the location of the my.ini file
Go to the command or terminal
cd yourMySQLBinDirectory
mysqld --verbose --help
You will see large output but first few lines will show the order the server is looking for the file. I got the following response. It will be different for your computer or server.
Default options are read from the following files in the given order:
C:\WINDOWS\my.ini C:\WINDOWS\my.cnf C:\my.ini C:\my.cnf D:\Databases\mariadb-10.3.30-winx64\my.ini D:\Databases\mariadb-10.3.30-winx64\my.cnf D:\Databases\mariadb-10.3.30-winx64\data\my.ini D:\Databases\mariadb-10.3.30-winx64\data\my.cnf
I met with the same problem when I did MSI install of MySQL and there were no my-medium.ini files too when I tried the above steps. Only installing the ZIP file of MySQL helped me. So, I suggest you to uninstall the MSI installed folder and reinstall using the ZIP file.
For MySql Server 8.0 The default location is %WINDIR% or C:\Windows.
You need to add a "my.ini" file there.
Here's a sample of what I put in the ini file.
[mysqld]
secure_file_priv=""
Make sure to restart the MySQL service after that.