The default log error verbosity is 3 for mysql 5.7. I'm trying to set this to a level of 2 in the cnf file but I'm not sure of the syntax.
The GLOBAL variable log_warnings sets the level for verbosity which
varies by server version. The following snippet illustrates:
SELECT ##log_warnings; -- make a note of your prior setting
SET GLOBAL log_warnings=2; -- setting above 1 increases output (see server version)
log_warnings as seen above is a dynamic variable.
Configuration file changes in cnf and ini files might look like the
following.
[mysqld]
log_error = /path/to/CurrentError.log
log_warnings = 2
Please see the MySQL Manual Page entitled [The Error Log][] especially
for Flushing and Renaming the Error Log file, and [Error Log
Verbosity] with versions related to log_warnings. The GLOBAL variable
log_warnings sets the level for verbosity which varies by server
version. The following snippet illustrates:
SELECT ##log_warnings; -- make a note of your prior setting
SET GLOBAL log_warnings=2; -- setting above 1 increases output (see server version)
log_warnings as seen above is a dynamic variable.
Configuration file changes in cnf and ini files might look like
the following.
[mysqld]
log_error = /path/to/CurrentError.log
log_warnings = 2
Please see the MySQL Manual Page entitled The Error Log
especially for Flushing and Renaming the Error Log file, and Error Log
Verbosity with versions related to log_warnings.
MySQL 5.7.2 expanded the warning level verbosity to 3 and added the GLOBAL log_error_verbosity. Again, it was introduced in 5.7.2. It can be set dynamically and checked as a variable or set via cnf or ini configuration file settings.
As of MySQL 5.7.2:
[mysqld]
log_error = /path/to/CurrentError.log
log_warnings = 2
log_error_verbosity = 3
Change yours to 2 if you want, above.
You can dynamically set, and check, respectively, with:
SET GLOBAL log_error_verbosity=2; -- set it
SELECT ##log_error_verbosity=2; -- sanity check, view it
yet this will be reset to cnf or ini file settings upon server restart.
I will try to improve our Docs page on that.
How to set the Configuration file (cnf or ini, Linux or Windows, respectively).
The my.cnf and my.ini files reside in the basedir. If they do not exist, you can create them, else they will use defaults baked into the server. Often there is a stubbed out file in basedir, not active, named my-default, as a template. Use that to create the real my.cnf or my.ini. Issue a
SELECT ##basedir;
to find the location where my.ini (Windows) or my.cnf (Linux) should reside. Note, you will need to have sufficient rights to modify these files. In Windows, for instance, I need to run Notepad as Administrator to write such a file.
The following are a few commands issued to confirm a change to my.ini (for Windows, my.cnf for Linux) having set log_error_verbosity to 2. Note this is after a server restart which would have used those ini or cnf changes:
I show the use of basedir because that is where your ini or cnf file must exist depending on your operating system.
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 wanted to disable some options in the MySql server strict mode, but for some reason I'm not even able to find its configuration file (my.cnf)
Currently installed MySql:
Ver 14.14 Distrib 5.7.20, for macos10.12 (x86_64)
Output generated by
mysql --help
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
But there is no such file as my.conf
I had done some research work on SO but none of the advises has worked for me.
What I'm supposed to do?
There are defaults built into MySQL. The configuration file(s), if any, override the defaults.
Note that the config files are not looked at except during startup. So, editing or creating such a file has no effect until you restart mysqld.
If you mess up the syntax, mysqld will not start. Then you need to find the error, either during startup, or in a log file. (Or you could ask here "what is my syntax error".)
As for the location, and name, of the config files that will be used:
$ mysql --help
gives you the list for mysql, but perhaps you need it for the server, so try
$ mysqld --help --verbose
gives you long output; maybe 50 lines from the top, you should see something like:
Usage: mysqld [OPTIONS]
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf
You asked about my.conf; was that a typo?
Regardless, If those files are missing, you can create them, make them readable by mysql, and put things into it preceded by [mysqld] so that the server will see them.
Personal override
Regardless of what is in the defaults and/or config files, you can add to the last file given. In the examples above that is 'hidden' .my.cnf in your home directory. All you need to do is create a few lines:
[mysql]
some_setting = somevalue
[client]
some_setting = somevalue
That helps for the "mysql" commandline tool and/or other clients (maybe).
But if you need to make changes to the server mysqld, it needs to be in one of the other files. Again, the minimum is something like
[mysqld]
some_setting = somevalue
Note the mysqld to refer to the server. And remember to restart the service.
Another note: If you see (in an existing config file), !includedir ..., then go to that directory to find any number of further files. You could add your own file, say z.cnf (so it would be picked last) with the two (or more) lines as indicated above.
If you have installed Mysql 8 or Above using the package installer from mysql website, then follow what i did
Create the config file in your home directory vim ~/.my.cnf
Do open System preferences in mac
Then Select the configuration file you created on the option.
The content in this website says.
I had the urgent need to configure some specific stuff in MySQL 5.7 on my developer machine, a MacBook Pro running Mac OS Sierra. Unfortunately, I did not find a my.cnf file that could be customized anywhere?
Internet research showed that MySQL Database Server on Mac OS runs without a my.cnf config file by default, simply started with default values.
Luckily, it is pretty simple to customize the MySQL Server installation by creating and editing a custom my.cnf file like this:
sudo cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
Then edit / customize the /etc/my.cnf file as required and restart your MySQL Server.
Or you can refer to this answer
You could try:
$ locate mysql | grep my.cnf
It should reveal the location(s) if it exists.
I'm using the Mysql Server version: 10.1.21-MariaDB on Windows 7, and when I run the flollowing command SHOW VARIABLES LIKE 'have_symlink'; I get :
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| have_symlink | NO |
+---------------+-------+
So I want to enable them.
What have I tried ?
running : mysql --symbolic-links yields the following error :
mysql: unknown option '--symbolic-links'
I've searched for location where a config file might be present so I looked for my.cnf and my.ini in the following locations :
%WINDIR%\my.ini %WINDIR%\my.cnf \my.ini \my.cnf %APPDIR%\mysql\my.ini %APPDIR%\mysql\my.cnf %APPDIR%\mysql\data\my.ini %APPDIR%\mysql\data\my.cnf to not find any file then I've created the following option file to be used when starting the server my.cnf with the following command :
[mysqld]
symbolic-links
I've made sure that in Windows:
Local to local symbolic links are enabled.
Local to remote symbolic
links are enabled.
So what am I doing wrong and how to make the have_symlink variable have a value of yes ??
EDIT:
I've restarted the server after the change to the my.cnf file, but without success
EDIT 2:
for the first mentioned error, it is because --symbolic-link is a server rather than client option, so I would type mysqld --symbolic-links and that relieves me of searching any option file, because the command line specified options take precedence.
You've got to do two things:
Put symbolic-links=1 in the configuration file (.cnf) under [mysqld].
Restart the MySQL Server.
After restarting, the have_symlink value should be yes.
Beware: Disabling symbolic-links is recommended to prevent assorted security risks (reference).
You appear to be running MySQL 10
symbolic-links is deprecated as of MySQL 8
https://dev.mysql.com/worklog/task/?id=8392
Symbolic links is defacto disabled on most MySQL distributions, because sample
configuration files contain:
symbolic-links=0
Since symbolic links allow MySQL to write data to any effective location on the
operating system, it creates two issues:
1) MySQL may be tricked into writing to locations it is not supposed to
2) MySQL may write to a location that has privileges that are too loose, and may
be tampered with by other users on the operating system.
(MySQL mitigates risk #1 by not overwriting existing files, but the risk still
remains as an attack vector.)
We therefore decided:
1) Change the compiled default to OFF (aligning with the defacto default)
2) Deprecate and remove this functionality in a future release.
Deprecation of --symbolic-links includes deprecating have_symlink.
I've been trying to set up two databases as master & slave.
I followed the famous guide here:
https://dev.mysql.com/doc/refman/5.1/en/replication-howto-existingdata.html
But no luck on my slave server,
The issue I'm having is setting the server-id variable.
No matter where I define it (I looked into all the possible cnf files that might allow me to define the variable)
I tried to define it like so:
[mysqld]
server-id = 2
I also tried setting it by using SET GLOBAL server_id but obviously, it didn't save the setting.
when I do:
SHOW VARIABLES LIKE 'server_id'
It returns
server_id 0
Among the cnf files I've looked into are:
etc/mysql/mysql.conf.d/mysqld.cnf
etc/mysql/mysql.conf.d/mysqld_safe_syslog.cnf
etc/mysql/conf.d/mysql.cnf
etc/mysql/debian.cnf
etc/mysql/mysql.cnf
usr/my.cnf
usr/my-new.cnf
usr/etc/my.cnf
My MySQL server is running on Ubuntu.
And if it matters, I start it by typing:
service mysql start
I'd love to know where else I could look to fix this issue.
Thanks a bunch!
Additional Notes:
MySQL Ignoring the global conf file
I received this warning a couple of times and it disappeared when I returned the chmod to 644 on the etc/mysql folder, although every thing stated above was attempted using both 644 and 777 permissions, with 644 the warning disappears.
I know it's to late, but for those who will make the mistake.
It's server_id and not server-id:
[mysqld]
server_id = 2
For me it worked by renaming the from /etc/mysql/conf.d/my.cnf to /etc/mysql/conf.d/my.ini
I'm not sure of the exact reason for that (feel free to edit this answer and add to it).
I tried out various combinations:
Keeping the variable as: server-id and server_id
Keeping the group/section as: [mysql] and [mysqld]
Renaming the file to: my.cnf , mysqld.cnf, mysql.cnf, my.ini
You can keep trying various combinations out of the above options, it should definitely work. :)
What if there are more than one my.cnf files on my server?
Which configuration file will be looked by MySQL?
Assuming one runs mysql under linux, there the option-files will be read in that order:
the file specified by option --defaults-file=/PATH/TO/my.cnf while startup of mysqld
/etc/my.cnf
/etc/mysql/my.cnf
SYSCONFDIR/my.cnf (usually sysconfdir is /etc)
$MYSQL_HOME/my.cnf
the path set by --defaults-extra-file=/PATH/TO/my.cnf
~/my.cnf (your homedir, usually used for mysql-client configuration)
Also keep in mind that there are three options which change this behavior in MySQL:
-defaults-file=/PATH/TO/my.cnf - only read that option-file
-defaults-extra-file=/PATH/TO/myextra.cnf - read all global option-files, then this
-no-defaults - ignore every option-file and start with default
Please also refer to the docs on option-files: MySQL-Docs
The one specified on the command line that starts the mysqld process, or if no configuration file is specified, the default location. On Linux it is in /etc. I don't know where the Windows default is, but you can look in the documentation.