how can i save permanently settings of MySQL ?
i got MySQL from WAMP, and there is no my.cnf file, there is a my.ini file !
how can i set some global variable,
Drive:\wamp\bin\mysql\mysql5.5.8\my.ini
this is the place to save settings.
WAMP uses the my.ini file.
To get to your my.ini file, just click the WAMP tray icon and hover over the 'MySQL' menu, and click 'my.ini'.
Edit your my.ini file and under the [mysqld] section, add this:
setting-name=setting-value , example: event-scheduler=on
restart all services
You do not need to use quotes around either the setting or value.
Global system variables must be specified using the command line or SQL commands (runtime/session) or by configuration file (permanent).
I have had the same question because in WAMP we only have a my.ini file instead of my.conf.
Through a SQL statement, proceeded as follow:
mysql> SET global max_heap_table_size=524288000;
mysql> SET global tmp_table_size=524288000;
but when restarted the server, the query:
select ##global.tmp_table_size, ##global.max_heap_table_size
returned the old values by default.
Then edited my.ini file ading the following statements:
max_heap_table_size=524288000
tmp_table_size=524288000
and the changes were permanent.
Related
My OS: Mac Big Sur 11.4
MySQL Workbench Version 8.0.28
As I need to import bulk CSV files to MySQL, my goal here is to NOT receive NULL when run:
SHOW VARIABLES LIKE 'secure_file_priv';
I have tried this guide as it seems recent by:
Creating my.cnf in text editor
Inputing in my.cnf:
[mysqld] secure_file_priv = ""
Saving my.cnf in either /etc/ or /usr/local/mysql-8.0.28-macos11-x86_64/support-files
Restarting MySQL
But I still received NULL in secure-file-priv
Any suggestions on how to fix this problem is appreciated.
After researching, I was able to create my.cnf with secure_file_priv + path , connect Configuration file to my.cnf and import cvs files using LOAD DATA INFILE.
Here's how I did it:
A. CREATING my.cnf:
Create my.cnf file using text editor
In my.cnf, input the below and save on folder of choice (ie. Desktop):
[mysqld] secure_file_priv = "/usr/local/”
*When save, untick for If not extension provided, use “.txt” so your "Kind" of file is Document.
Move my.cnf file to /etc/
B. IN MYSQL WORKBENCH:
Tab ADMINISTRATION (top left)
Click Manage Server Connections (next to INSTANCES, screenshot can be found here)
Change Installation Type to: macOS (MySQL Package)
Next to Configuration file > Choose /etc/my.cnf
Test Connection to check. If succeed, Close.
Click Options File under INSTANCES to check if still “...not specified” (it shouldnt be)
Quit Workbench
RESTART SERVER by System Preferences > My SQL > Stop Server and then Start Server again
Open Workbench to check
`
SHOW VARIABLES LIKE 'secure_file_priv';
Expected result:
Variable_Name: secure_file_priv
Value: /usr/local/
`
C. IMPORTING:
Move my csv file to /usr/local/
Use
LOAD DATA INFILE '/usr/local/filename.csv' [...]
I have spent hours trying to figure this out but am seriously stuck. I installed the latest version of mysql today and some things in my website broke. I believe it has to do with strict settings, IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
I am trying to disable strict mode just to get my site working but it seems impossible. I have tried this in terminal but no luck.
sudo vim /etc/mysql/conf.d/disable_mysql_strict_mode.cnf
[mysqld]
sql_mode="IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
I have looked in every etc folder I can find and other various folders but can't see anything that resembles a .cnf file.
I can do it temporarily through phpmyadmin but if I close MAMP or restart my computer I have to do it again as the change isn't permanent.
MAMP Pro
Open MAMP Pro and check your Settings (⌘+,). Make sure Hide Dock Icon is unchecked. If required, uncheck the icon, quit MAMP and restart it.
Note: This is required to see the menu entries for MAMP. You can hide the Dock Icon again later.
Open the main window of MAMP Pro and via the menu go to File > Edit Templates > MySQL > (your version).
This opens a text editor with your MySQL configuration.
In the configuration file look for the line [mysqld] (note the d at the end!).
Right after this line, add a new line with the following text: sql_mode=""
Save the file, close it and restart your MySQL server.
MAMP (free)
By default MAMP free starts the MySQL server without a my.cnf file, i.e. it uses the default configuration which comes with the MySQL build. So you have to create a config file manually:
Quit MAMP (stop the servers)
Run following command in the terminal - it will open the config file inside your text editor app:
touch /Applications/MAMP/conf/my.cnf && open -t /Applications/MAMP/conf/my.cnf
When the file is empty, then add the following content:
[mysqld]
sql_mode=""
(When the file is not empty, then simply add the line sql_mode="" right after the line [mysqld])
Save the config file and close the text editor; restart MAMP and start the servers.
If you are running MySQL 8.x, try the following:
SET PERSIST SQL_MODE = "IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION";
Trying to find and edit the right my.cnf file can be the wrong strategy. For me the critical information from the MAMP PRO guide was:
You cannot edit my.cnf directly. You
must use the MAMP PRO interface to edit your my.cnf file. In the menu
go to File > Edit Template > MySQL > my.cnf.
For Free Mamp
Go to PhpMyAdmin > Variables Tabs
Find sql mode line and click on edit button
Replace the value with this "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
it works for me
Just to update this for the free version of MAMP 5, I found that MAMP will ignore a my.cnf file placed in the /Applications/MAMP/conf/ directory if the permissions are not set correctly. I ran this command to find that out...
/Applications/MAMP/Library/bin/mysql --verbose --help | grep -A 1 "Default options"
Which told me this.
mysql: [Warning] World-writable config file '/Applications/MAMP/conf/my.cnf' is ignored.
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /Applications/MAMP/conf/my.cnf ~/.my.cnf
Doing
chmod 755 my.cnf
Set it right.
Location of MySQL configuration file (ie: my.cnf) not specified
How can I fixed this thing?
I been trying to reinstall mysqlserver 5.5 / 5.7 and workbench countless of time. But I still not able to fix this issue.
I solved this problem. Step one: click here
Step two: and then click here to choose your path
Step three: my path is C:\ProgramData\MySQL\MySQL Server 5.7\my.ini
If you already know where your configuration file is located, but just don't know how to specify it in mySQLWorkbench, you can skip steps 1-3 and just follow step 4 in these instructions.
Step 1: Make sure which mysql is running (just in case you have multiple installations on your system) and how:
$ ps aux | grep mysql
may result in something like:
_mysql 120 0,0 3,4 5122736 565108 ?? Ss Fr01pm 61:05.93 /usr/local/mysql/bin/mysqld --user=_mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/usr/local/mysql/data/mysqld.local.err --pid-file=/usr/local/mysql/data/mysqld.local.pid
If, in this output, you see that mysqld has been started with the --defaults-file option, that option specifies the configuration file used by msql. If so, you have found the configuration file and can skip to step 4.
If not, check if this returns the same binary location as above command:
$ which mysqld
If not, then make sure you use the full path for mysqld from the first output in the following step.
Step 2: Ask mySQL which configuration files it is using:
$ mysqld --verbose --help | grep -A 1 "Default options"
should output something like:
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
Step 3: Check the given locations in that order. The first finding should be your mySQL configuration file.
Step 4: In mySQLWorkbench go to Database > Manage Connections, then select the connection, select tab System Profile, and enter the path and file name in Configuration File.
This should be it.
And if still nothing happens, you may have used the installer Package. If you have, then you must select the Installation Type from the drop-down to reflect that before you locate the configuration file.
Here's a screenshot that follows from the above screenshots
Also, there may not be a config file and you can create one here, then get out of the Options File, go back in and you will see all the options.
I changed my setting from Custom to MacOSx (MySQL Package) under: Database → Manage Connections → MySQL Connections → Select DB Connection → System Profile → Installation Type → (default setting) MySQL Package.
Change from custom to default setting:
Reconnect by testing connection:
For maria-db users
back up the original /etc/mysql/my.cnf
copy and rename /etc/mysql/mariadb.conf.d/50-server.cnf to /etc/mysql/my.cnf.
This would fix the problem.
Remember to revert changes after finish.
For those with Mac OS Catalina:
I did not have a my.cnf file. I went to /usr/local/mysql/
and created a directory named etc, which I did not have either.
Then, inside that directory, I created the file (my.cnf).
This is the link that helped me How to fix --secure-file-priv option error
for mysql 5.7 users and MAMP: just create /etc/my.cnf
macOS 13 and MySQL 8 current:
Open MySQL Workbench on your Mac. Connect into your localhost instance of MySQL.
Click the little wrench icon next to INSTANCE on the left pane above Startup / Shutdown.
Select macOS as System Type, macOS as Installation Type, and the rest will default into place. Copy the location it gives you for the my.cnf file.
Click Close
Now click Options File on the left. It will notice that you don't have a file and will show you default values.
Click the Apply... in the bottom right corner.
It will then ask you for a password of your current logged in user of your Mac to create and save the my.cnf file.
Now in the Finder use the keyboard combo of Command-Shift-G and copy in your location we copied early (i.e. /etc/my.cnf)
I'm trying to locate data folder of mysql server 5.7
When I run this query
SHOW GLOBAL VARIABLES LIKE 'datadir';
I got my data dir path, but when I actually go there in c drive its not there.
Checked all hidden properties, all are fine.
Any help ?
It could be hidden. Default datadir on Windows 10 is C:\ProgramData which is normally hidden.
This link describes initializing the data directory on Windows or UNIX-like OSs.
For Windows
Because you have problems with finding the data directory I suggest you define it yourself.
First you have to make sure the following lines are in my.ini file:
[mysqld]
basedir=C:\\Program Files\\MySQL\\MySQL Server 5.7
datadir=D:\\MySQLdata # here you could put
The second line points to your MySQL Server installation. The third line to wherever you want your data directory to be. After saving the file. You could call following command:
C:\> bin/mysqld --defaults-file=C:\my.ini --initialize
With C:\my.ini pointing to your my.ini file. Hope this helps you
I an currently using mysql server 5.6 in windows 10. while using mysql, an error keeps appearing that goes as something like this "the following column does not have a default value" i read on the internet that i can solve this problem if i change the sql_mode. It is currently set to
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
I took this from "my-default.ini" file in "mysql server 5.6" folder. I read several other answers that say that if you want to permanently change your sql_mode, you should do it through the "my-default.ini" file. So what i did was, i run my notepad as administrator, then i browsed to open "my-default.ini" file that is found in:
c:\programs files (x86)\mysql\mysql server 5.6\my-default.ini
when i opened the file, i modified the last line:
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
to
sql_mode=
then i saved the file, closed it. then by using task manager i restarted my sql sever:
task manager >> services >> mysql56
This is the whole process that should permanently modify my sql_mode. when i look in my "my-default.ini" file, the last line is still modified. but if i log into mysql through the command line and view my sql_mode with the following code:
select ##sql_mode;
I get that my sql_mode is
STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
I want all this to be removed (permanently) in order for my error to disappear. IF i try to modify the sql_mode from the command line by using:
set ##global.sql_mode="";
It worked, but when i restarted MySQL, everything was back as it was before.
Can someone please tell me what i am doing wrong? and if there is another way to solve this problem.
UPDATE: Sorry, forgot you were using Windows 10. I'm not sure how to deal with this issue in Windows but maybe try copying my-default.ini to my.ini and changing that setting. Sorry for confusion.
Not sure if you can set your sql_mode to nothing but try changing the value in your /etc/mysql/my.cnf file. If that folder/file doesn't exist, create it and try setting sql_mode under [mysqld] like this:
[mysqld]
sql_mode=
I just did this same thing only I set the sql_mode to NO_ENGINE_SUBSTITUTION.
If you have MySQL Workbench installed, check the Server Status for the base directory of your instance. You should find a my.ini file there that keeps your changes.
sql_mode need to add to file /etc/init.d/mysql as a argument to start like:
$bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" --sql-mode="" $other_args >/dev/null 2>&1 &
Restart MySQL database server to apply new config.
In MYSQL 8 and ubuntu server 20.xx I had to add:
sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTIO
To file
/etc/mysql/mysql.conf.d/mysqld.cnf
In order that the setting stay persistent after server restart
Disclaimer:
this was the only place it actually worked, I have no idea what's the good practice where to add these custom settings but it 'ain't stupid if it works'. Somebody can tell me.
I tried the other options I found on forums:
my.cnf did not work creating
custom cnf did not work
adding it to mysql.cnf did not work