mysqlbinlog: unknown variable 'default-character-set=utf8mb4' - mysql

When launching mysqlbinlog it returns an error:
root#utils # mysqlbinlog --start-datetime="2021-12-05 13:13:00"
mysqlbinlog: unknown variable 'default-character-set=utf8mb4'
How to fix it?
Maybe, it related to the contents of /etc/mysql/mariadb.conf.d/50-client.cnf which is:
[client]
# Default is Latin1, if you need UTF-8 set this (also in server section)
default-character-set = utf8mb4
# socket location
socket = /var/run/mysqld/mysqld.sock
# Example of client certificate usage
# ssl-cert=/etc/mysql/client-cert.pem
# ssl-key=/etc/mysql/client-key.pem
#
# Allow only TLS encrypted connections
# ssl-verify-server-cert=on
# This group is *never* read by mysql client library, though this
# /etc/mysql/mariadb.cnf.d/client.cnf file is not read by Oracle MySQL
# client anyway.
# If you use the same .cnf file for MySQL and MariaDB,
# use it for MariaDB-only client options
[client-mariadb]
The server configuration is:
Server version: 10.3.31-MariaDB-0ubuntu0.20.04.1-log Ubuntu 20.04

character-set-server = utf8mb4
or
mysqlbinlog --no-defaults mysql-bin.000001

Another solution is to add the loose_ prefix to the failing option:
[client]
loose-default-character-set=utf8mb4
The loose prefix forces command line tools not to throw an error, if the option isn't supported.

Move the default-character-set=utf8 line below the [mysql] or [mysqld]
sections of your my.cnf file. mysqlbinlog reads variables under
[client], but not [mysql]. Your command-line client and/or browser
reads the [client] AND [mysql] sections of the config file.
BTW, mysqlbinlog can take a specified character set, if you use the
--set-charset=charset_name (>5.0.23) option.
source: https://forums.mysql.com/read.php?103,189835,192421#msg-192421

Related

MySQL service could not be started after changing my.ini

I have MySQL 8.0 running on Windows. I made some changes to my.ini (having eventually found it!) to change the character set. Stupidly I did not back it up first, and I used Notepad, which doesn't have multiple undo.
Now I get
The MySQL Service could not be started
The service did not report an error
There are no errors logged in the MYSQL log either.
I'm sure I've accidentally deleted an important line or something, but can't for the life of me find it. This is the section of my.ini that I changed:
[client]
# pipe=
# socket=MYSQL
port=3306
[mysql]
# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this
# file.
#
# server_type=2
[mysqld]
# The next three options are mutually exclusive to SERVER_PORT below.
# skip-networking
# enable-named-pipe
# shared-memory
# shared-memory-base-name=MYSQL
# The Pipe the MySQL Server will use
# socket=MYSQL
# The TCP/IP Port the MySQL Server will listen on
port=3306
# Path to installation directory. All paths are usually resolved relative to this.
# basedir="C:/Program Files/MySQL/MySQL Server 8.0/"
# Path to the database root
datadir=C:/ProgramData/MySQL/MySQL Server 8.0/Data
# The default character set that will be used when a new schema or table is
# created and no character set is defined
character-set-server=utf8
I've tried undoing what I did (though as I say, I may have accidentally changed something else), and using mysqld --initialize before trying to restart. I've checked permissions - all seem to be OK.
I found the answer. The problem wasn't to do with my changes at all, but because I had changed it in Notepad. When I opened the file in Notepad++ to check encoding, I noticed that the encoding was UTF-8-BOM.
I changed it to plain UTF-8 and MySQL now starts. I'm not sure if Notepad changed it, or just didn't encode the UTF-8-BOM correctly, but the main thing is that it starts.
Saving the file to ANSI will fix the issue.
I had a different problem but your solution helped me narrow down my solution.
Saved innodb_buffer_pool_size= 3G instead of innodb_buffer_pool_size=3G
That small spacing caused me a heart attack. After removing the space and saving it as UTF-8 file. It worked for me again

unknown variable 'general_log_file=/var/log/mysql/mysql.log'

I'm using MySQL / 10.1.29-MariaDB-6 on Kali Linux 2018 VM.
I have the following entry in mariadb.cnf, mysql.cnf, and 50-server.cnf.
general_log_file = /var/log/mysql/mysql.log
general_log = 1
The conf file shows that the following config files are used to determine options:
The MariaDB/MySQL tools read configuration files in the following order:
/etc/mysql/mariadb.cnf (this file) to set global defaults,
/etc/mysql/conf.d/*.cnf to set global options.
/etc/mysql/mariadb.conf.d/*.cnf to set MariaDB-only options.
~/.my.cnf to set user-specific options.
Logging IS working to the file specified, but whenever I try to type the following mysql command, I am met with the following error:
root#kali:/var/log/mysql# mysql -u root -p
mysql: unknown variable 'general_log_file=/var/log/mysql/mysql.log'
How to fix this error?
Check the sections of the config file(s) where general_log_file option is set. It must be [mysqld], or [server], or [mariadb] and alike, but it must not be [mysql] or [client] or alike. general_log_file is a server-only option.

MySQL Connection Refused

i've looked up every tutorial on how to fix this and nothing worked so far,
I'm getting this error
No connection could be made because the target machine actively refused it
i'm using linux centos7 mysql version
mysql Ver 14.14 Distrib 5.6.32, for Linux (x86_64) using EditLine wrapper
blow is my.cnf
also i had to create my own my.cnf as when i installed mysql it didn't have one located i put this into etc/my.cnf it's running the cnf as it's taken mysql out of strict mode.
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....
bind-address = 0.0.0.0
#skip-networking
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Ok, I am assuming that you have installed this on a completely different machine (as opposed to a Virtual Host on your Windows box).
You need to make sure that port 3306 is open on your DB server first and foremost. You can check this with a port checker (there are plenty of free ones online).
Then, with the user you are trying to connect with, you need to make sure that user has access from the origin IP address (i.e. the IP on your Windows machine). This can be done with the following code from the mysql prompt.
GRANT ALL PRIVILEGES ON <your db name>.* TO <your user>#<your ip> IDENTIFIED BY '<your password>';
A less secure option would be to allow all inbound IPs by using the % wildcard.
After this you need to run the following command.
FLUSH PRIVILEGES;
That should be it.

mysqldump unknown variable sql_mode error

Help requested on 'mysqldump' error
I'm in the hell figuring out why following error happens. So, please, anybody help me. My writing: A, B, C, D
s
A. Here is my.ini file
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
basedir = C:\mysql-5.6.27
datadir = C:\mysql-5.6.27\data
port = 3306
max_allowed_packet=16M
character-set-client-handshake = false
init_connect="SET collation_connection=utf8_general_ci"
init_connect="SET NAMES utf8"
character-set-server=utf8
collation-server=utf8_general_ci
skip-character-set-client-handshake
default-character-set=utf8
#bind-address = 0.0.0.0
#explicit_defaults_for_timestamp=1
[mysql]
default-character-set = utf8
[mysqldump]
#sql_mode=NO_AUTO_VALUE_ON_ZERO
========================== end of ini file
B. I executed the following command ==>
C:\mysql-5.6.27\bin> mysqldump -uroot -p --databases parkinglot > prugio.sql
C. Here is the response on my mysqldump
mysqldump: unknown variable 'sql+mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES'
D. For your reference, I upgraded mysql version from 5.6.24 to 5.6.27.
Thank you very much in advance.
I just found answer myself. I had my.ini in two plases. one in C drive and the other one in D drive. That caused the confusion. As soon as I renamed one of the my.ini, the problem didn't happen.

mysql 5.6 ubuntu 15.04 cannot find correct my.cnf file

I am attempting to move a mysql db onto an upgraded server with a newer version of ubuntu running (15.04), and after installing LAMP, I went to edit the bind address in the my.cnf file. The below is all I see in /etc/mysql/my.cnf. I added [mysqld] and the bind address = new address but nothing seems to allow my remote client to connect to this db. It is online and the ip address should be correct. What am i missing? Why is this my.cnf so bare?
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
stupid me, apparently in this version it is the mysqld.cnf under /etc/mysql/mysql.conf.d/. Oh well. Posting this in case anyone else has problems.....
In ubuntu 15.04 the MySQL Server configure file is in:
/etc/mysql/mysql.conf.d/mysqld.cnf
You can find bind-address here.Comment it, and restart your MySQL Server use :
service mysql restart
Then you can access your MysqlServer from other computer. If you don't, perhaps you need grant some right to the user you use.
You can see MySQL Server bind-address use:
netstat -tap | grep mysql
So you know whether the configure take effect.
Depending on your linux distro your my.cnf (as well as the rest of your data directory) may be in /var/lib/mysql folder.
You could also run the find command to look for the file: find -name 'my.cnf'.
I suggest running this command as root, in your root directory.
Once you have located the correct my.cnf file there will be a parameter under [mysqld] section that looks like this:
bind-address = 127.0.0.1
Comment this parameter out with a # and save the edited my.cnf file. Restart the Mysql server and you should be able to connect remotely from any IP as long as the user you are trying to connect with as the correct permissions and host(%).
You can check this by running:
select user, host from mysql,user;
and show grants for 'youruser'#'yourhost';
grants and privileges for Mysql.