MySQL CLI Client shows data as Hex - mysql

My MySQL CLI client when connecting to a database is automatically showing the data as hex
Connecting in CLI using mysql -u user -p'password' -h host -P port --ssl-mode=DISABLED
To turn this off I have to run it with the --skip-binary-as-hex option to see the data properly
Need help understanding what is causing this is getting enabled by default.
This issue does not exist for other users logging into the same database and is not an issue for me I connect through a DB tool, it occurs only on CLI

Prior to MySQL 8.0.19, the issue which you are facing did not exist. binary-as-hex client option is enabled by default from MySQL 8.0.19 Command Line Client.
Run status or \s in MySQL Command Line Client. You will notice a line about binary data like this:
Binary data as: Hexadecimal
You can refer these links for more information:
https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_char
https://dev.mysql.com/doc/refman/8.0/en/mysql-command-options.html#option_mysql_binary-as-hex

Related

MySQL Workbench 8.0.28 export issue on MacOS 12.3 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 11 months ago.
Improve this question
Up until recently I was using MySQL Workbench 8.0.20 without any issues till I upgraded my MacOS to 12.3 after which the Workbench software itself stopped working. I then upgraded my Workbench version to 8.0.28 (latest version at the time of writing).
But after updating to the new version, I initially had issues connecting to my remote databases. I was getting the following error -
Got error: 2026: SSL connection error: error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol when trying to connect
But I was able to solve that one by setting the 'Use SSL' option under the SSL tab for the connection to 'No'.
The next issue though is now I am not able to perform exports on the server using mysqldump. The Workbench software is trying to run the following command -
Running: /Applications/MySQLWorkbench.app/Contents/MacOS/mysqldump --defaults-file="/var/folders/fd/jt76prtj4z35dqd6y1y1_jcw0000gn/T/tmppuwxrtig/extraparams.cnf" --host=host.db.com --port=3306 --default-character-set=utf8 --user=logicspice --protocol=tcp --single-transaction=TRUE --column-statistics=0 --skip-triggers "database"
after which I'm getting a similar issue -
mysqldump: Got error: 2026: SSL connection error: error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol when trying to connect
Is there an update I can do to a certain configuration file for either mysqldump or MySQL Workbench that will disable the use of SSL when trying to use mysqldump?
Your assistance would be much appreciated as this issue is causing delays in my development work. Thanks!
Summary of system -
Operating system - MacOS Monterey 12.3
Processor - 2.4 GHz 8-Core Intel Core i9
MySQL Workbench version - mysql-workbench-community-8.0.28-macos-x86_64.dmg
MySQL version - 5.6.10 (MySQL Community Server (GPL)) on AWS RDS
Exporting a MySQL or MariaDB database
To export the database, the mysqldump command is used from the console. Once the backup is done, the generated file can be easily moved. To start exporting the database you have to execute the following:
mysqldump -u username -p database_name > data-dump.sql
username : Refers to the name of the database user.
database_name : Must be replaced by the name of the database you want to export.
data-dump.sql : Is the file that will be generated with all the database information.
That command will not produce any visual output. So, to make sure that the SQL copy has been performed correctly, you can inspect the generated file to make sure that it is a SQL copy. To do this you can use the following statement:
head -n 5 data-dump.sql
That command should return something like this:
-- MySQL dump 10.13 Distrib 5.7.16, for Linux (x86_64)
--
-- Host: localhost Database: database_name
-- ------------------------------------------------------
-- Server version 5.7.16-0 ubuntu 0.16.04.1
It is also possible to export one or more tables instead of the entire database. To do this, you must indicate in the command the selection you want to make.
mysqldump -u username -p database_name table_name_1 table_name_2 table_name_3 > data-dump.sql
In this case, it is important to take special care with the relationships between the different records. When importing, only those tables that have been selected will be overwritten.
Importing a MySQL or MariaDB database
To import a MySQL or MariaDB dump, the first thing to do is to create the database into which the import will be done. To do this, if you do not have any database manager, you have to connect to the database server as "root" user.
mysql -u root –p
This will open the MySQL or MariaDB shell. You will then be able to create the database.
mysql> CREATE DATABASE new_database;
If everything went well, you will see something like this:
Query OK, 1 row affected (0.00 sec)
Once created, you have to exit this shell by pressing CTRL+D. Once you are in the normal command line, it will be time to launch the command that will perform the database import.
mysql -u username -p new_database < data-dump.sql
username : Is the name of the user with access to the database.
new_database : Is the name of the database where the import will be performed.
data-dump.sql : Is the name of the file containing all the sql statements to be imported.
If any errors occur during the import process, they will be displayed on the screen. As you can see, exporting and importing a MySQL or MariaDB database is a very simple process.
Note : All this is done with Ubuntu in a terminal but in MAC it is exactly the same .
Another solution : In case you still get that error I have found assuming you are using OpenSSL and not ysSSL.
Refer to the MySQL configuration variable ssl_cipher. ssl_cipher
Configure a list of ciphers including pseudo-encryption #SECLEVEL=1
For example :
ssl_cipher = "DHE-RSA-AES128-GCM-SHA256:AES128-SHA:#SECLEVEL=1"
If you need a more permissive but still secure encryption list.
"EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH:ECDHE-RSA-AES128-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA128:DHE-RSA-AES128-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA128:ECDHE-RSA-AES128-SHA384:ECDHE-RSA-AES128-SHA128:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA128:DHE-RSA-AES128-SHA128:DHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA384:AES128-GCM-SHA128:AES128-SHA128:AES128-SHA128:AES128-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4:#SECLEVEL=1"
taken from https://cipherlist.eu/ could do the job.

Failed to connect to a remote MySQL database via an Ubuntu server

I'm trying to connect to a remote MySQL database via an Ubuntu server using a command like:
mysql -u oooo -p -h ooo.ooo.oo.oo
Then it just returned:
mysql: unknown variable 'log=/var/log/mysql/logfile.log'
I've checked that the file 'logfile.log' does not exist and I have no idea what is the next step.
Search your machine for a file named my.cnf. That file will probably contain your offending variable. Comment it out.

Where can I run a mysql command line under Azure to fix "The used command is not allowed with this MySQL version (1148)"

I have a MySQL database which is hosted in Azure, and I have MySQL Workbench installed on my laptop. I want to do some importing from a CSV file located in my laptop, but whenever I try to that, I get an error message saying:
The used command is not allowed with this MySQL version
I did some online searching, and I found out that I need to run the following command:
mysql -u myuser -p --local-infile somedatabase
But, I don't know where I have to run it, and how, while as I said my database is hosted in Azure.
mysql is just the commandline executable of the MySql client. And most probably it is even part of the MySql workbech - just check the MySQL Workbech working folder. But the result will not be different is my guess.
The best way you can manage Import/Export for MySQL is to use a Free Tier WebSite and Install the phpMyAdmin extension.

skip-secure-auth option not working with mysqldump

I am trying to export a mysql schema from remote server to local but geting the following error:
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysqldump --skip-secure-auth -h x.y.z.d -uatulya -p'root' t_tcadmin |mysql -u root -proot t_tcadmin
mysqldump: unknown option '--skip-secure-auth'
Warning: Using a password on the command line interface can be insecure.
Without the --skip-secure-auth it connects but I get error 2049.
So I want to use this option to skip secure auth but it is giving the above error. Could anyone suggest.
Thanks..
If you are in a pinch, dealing with an older server where updating the passwords to the newer method is not an option (say, MySQL Server v5.0.95) and attempting to migrate the data to a newer system - without modifying the fragile older system, you may need to temporarily downgrade your local mysql client to 5.5 for myasqldump to be able to talk to the older server. As of 5.6 it is possible to use the MySQL client to connect to it - using --skip-secure-auth in the command, but mysqldump will not accept that flag. And, in MySQL 5.7+ it is impossible to connect to a server that uses the older password storage method at all.

How can I correct MySQL Load Error

I'm not quite sure a similar question to this was closed by I'm trying to execute the following MySQL program.
mysql -e "load data local infile \
'/tmp/ept_inventory_wasp_export_04292013.csv' into \
table wasp_ept_inv fields terminated by ',' \
lines terminated by '\n' ;"
at the bash command line and get this error
ERROR 1148 (42000) at line 1: The used command is not allowed with this MySQL version
How can I work around this problem?
I am actually running this command from a Python program, but pulled the command out to try fiddling with it at the bash command line.
I've seen how I can modify my.cnf (local-infile), but I do not want that global a change if I can avoid it.
Here's the MySQL version.
mysql Ver 14.14 Distrib 5.5.31, for debian-linux-gnu (i686) using readline 6.2
The workaround for this is to modify the command line mysql -e to pass in the --local-infile=1 argument like this:
mysql --local-infile=1 -u username -p `
Then run the LOAD DATA LOCAL INFILE command again.
As documented under Security Issues with LOAD DATA LOCAL:
To deal with these problems, we changed how LOAD DATA LOCAL is handled as of MySQL 3.23.49 and MySQL 4.0.2 (4.0.13 on Windows):
By default, all MySQL clients and libraries in binary distributions are compiled with the --enable-local-infile option, to be compatible with MySQL 3.23.48 and before.
If you build MySQL from source but do not invoke configure with the --enable-local-infile option, LOAD DATA LOCAL cannot be used by any client unless it is written explicitly to invoke mysql_options(... MYSQL_OPT_LOCAL_INFILE, 0). See Section 20.6.6.49, “mysql_options()”.
You can disable all LOAD DATA LOCAL statements from the server side by starting mysqld with the --local-infile=0 option.
For the mysql command-line client, enable LOAD DATA LOCAL by specifying the --local-infile[=1] option, or disable it with the --local-infile=0 option. For mysqlimport, local data file loading is off by default; enable it with the --local or -L option. In any case, successful use of a local load operation requires that the server permits it.
If you use LOAD DATA LOCAL in Perl scripts or other programs that read the [client] group from option files, you can add the local-infile=1 option to that group. However, to keep this from causing problems for programs that do not understand local-infile, specify it using the loose- prefix:
[client]
loose-local-infile=1
If LOAD DATA LOCAL is disabled, either in the server or the client, a client that attempts to issue such a statement receives the following error message:
ERROR 1148: The used command is not allowed with this MySQL version
local-infile needs to enabled on both the server and the client. You can accomplish this by adding local-infile = 1 to the appropriate section in each end's my.cnf (Unix) or my.ini (Windows) file. For example, on the client:
[client]
local-infile = 1
You can also enable this at runtime on the server by setting the system variable local_infile:
SET GLOBAL local_infile=1;
However, you still need to enable it on the client. You can do this at runtime by adding a command-line parameter to the mysql command:
mysql --local-infile=1 ...
If you're using Amazon Web Services RDS, you can configure the server setting by editing or creating a Parameter Group. Look for the local_infile parameter. You may need to restart your server after applying the changes.
My guess is that your MySQL server does not have LOAD DATA LOCAL enabled. See this section of MySQL documentation:
If LOAD DATA LOCAL is disabled, either in the server or the client, a client that attempts to issue such a statement receives the following error message:
ERROR 1148: The used command is not allowed with this MySQL version
Here is link to the page I got this from:
http://dev.mysql.com/doc/refman/5.5/en/load-data-local.html