I am using Tableau BI with MongoDB BI Connector to connect to the MongoDB database server. I have executed one MySQL query from the Tableau, which shows the following error
Error Code: 2013. Lost connection to MySQL server during query
For this error, I am trying to increase the net_read_timeout property value in the MongoDB BI Connector and as per the document, we can use the following command to update the system variable setting, after connecting the MongoDB BI with the MySQL client.
mysql --protocol tcp --port 3304 -e "SET GLOBAL net_read_timeout = 100"
But this command doesn't change the 'net_read_timeout' property value and it reflects the old one
mysql> show variables like 'net_read_timeout';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| net_read_timeout | 30 |
+------------------+-------+
Could anyone please suggest me how to update the system settings of MongoDB BI Connector using the MySQL client? Thanks in advance.
I faced the same problem recently. It's my solution:
Add the timeout settings(socketTimeoutMS, connectTimeoutMS) into the connection string(uri) for MongoDB.
They can help you to control the timeout of the connection!
Example:
#The configuration file of BI Connector
# ...
mongodb:
net:
uri: "<your-mongodb>:27017/?socketTimeoutMS=360000&connectTimeoutMS=360000"
# ...
I hope this will help!
Related
I am trying to use OUTFILE on Ubuntu 20.04 and getting this error:
MySQL server version: 8.0.21
Code:
mysql> select * into OUTFILE '/home/yash/Desktop/data2.txt' from ticket;
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
I tried many solutions but it didn't work on Ubuntu 20.04
If anyone can give a solution for Ubuntu 20.04 and MySQL 8.0.21 then it will be appreciated.
You can use
SHOW VARIABLES LIKE "secure_file_priv";
to see the directory that MySQL thinks that it is secure to load or save files.
You have now two options:
Move your file to the directory specified by secure-file-priv.
Disable secure-file-priv. This must be removed from startup and cannot be modified dynamically. So you have to change it in my.conf
In my.con you should find secure-file-priv= and change it to
[mysql]
secure-file-priv='/home/yash/Desktop/'
So that your desktop will become a save directory.
And you can disable the secure file option, which is not recommended by
[mysql]
secure-file-priv=''
As per your question you want to store the result of the query in a text file try 'tee' MySQL command
Try this in your MySQL prompt
tee /home/yash/Desktop/data2.txt;
select * from ticket;
Are you using any shell script or connecting MySQL DB from the terminal?
If not working then disable "secure_file_priv" in mysqld.cnf then restart.
set secure-file-priv = "" in mysqld.cnf file and the check SHOW VARIABLES LIKE "secure_file_priv"; and you get the below sample output
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| secure_file_priv | |
I have a database created in Lightsail (not RDS, just Lightsail>Databases>Create database). I am trying to increase its max_connections number from 150 to 500 by connecting to it remotely, but I am getting the following error:
Access denied; you need (at least one of) the SUPER or SYSTEM_VARIABLES_ADMIN privilege(s) for this operation
Is there a way for me to achieve this on Lightsail?
Database instance info:
High availability MySQL database (8.0.11)
2 GB RAM
1 vCPU
80 GB SSD
It sound like you are attempting to set the parameter through SQL?
For lightsail databases, you need to follow these instructions and use AWS CLI: https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-updating-database-parameters
(if I'm wrong, please let us know what command you are running to generate the error you are seeing above)
AWS RDS and lighsail wil automatically inject your proper amount of max_connections based on your memory installed. With 2 gigs, you get around 66*2=132
It will just overwhelm even RDS if you make too many connections, as they require more RAM for each one.
"parameterName": "max_connections",
"parameterValue": "{DBInstanceClassMemory/12582880}"
mysql> show variables like "max_connections";
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 66 |
+-----------------+-------+
# pip3 install awscli --upgrade --user
# .local/bin/aws lightsail get-relational-database-parameters --relational-database-name <your given name>
# .local/bin/aws lightsail update-relational-database-parameters --relational-database-name <your given name> --parameters "parameterName=explicit_defaults_for_timestamp,parameterValue=0,applyMethod=pending-reboot"
which is required for MySQL 5.7
OR for your situation
# .local/bin/aws lightsail update-relational-database-parameters --relational-database-name <your given name> --parameters "parameterName=max_connections,parameterValue=500,applyMethod=pending-reboot"
If your region is us-west-2a, then remove the "a" from the .aws/config
[default]
region = us-west-2
output = json
I am not able to connect a MySQL server remotely.
The connection seems to be ok because with telnet [ip] [port] I get response:
4.1.3b-beta-nt-max▒ <0v '[uZ,? B {efSLa $, Q4N
When executed by command line or by MySQL Workbench 6.3
mysql -u [user] -p -h [host]
I get the same error:
ERROR 2027 (HY000): Malformed packet
It is a mysql client bug, I've searched about it and it is a old auth switch request. Your client it is out of date, using a old protocol communication, now, if it is a Workbench problem too your just the Client, you need to update or downgrade the MySQL Client first and try to run it alone.
Here, it is the same question with a more complete answer:
https://dba.stackexchange.com/questions/135343/server-responds-with-empty-packet-during-session-negotiation-resulting-in-client
And, for the new Auth protocol, on connection phase:
https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_connection_phase.html
You must upgrade the "old_password" hashed password:
SET PASSWORD FOR 'existinguser'#'localhost' = PASSWORD('existingpass');
So you can login in an "old" MySQL server, using a recent Workbench version
If you need to connect to pre-4.1 MySQL servers from later MySQL versions (5.7+), you will need to use "--skip-secure-auth" option from the client. And the client version cannot be newer than v5.7.4 because this option had been removed in 5.7.5. You can download version 5.7.4_m14 from mysql's archive website. For example,
$ mysql -uuser -p -hserver --skip-secure-auth
I had the same error trying to connect to a MariaDB server with the MySQL client mysql-client. I solved it by installing mariadb-client (that overwrites the mysql binary, so use the same command to connect).
I did face this issue for normal select query. It was weird that when I was using small-case 's' in the query statement, it was giving me the same error. The I figured out that this happens as internally it is trying to retrieve the data from mysql cache.
It was not because of the case of 's' in the select query.
//Returned Error
select * from foo;
//This worked fine
Select * from foo;
//This also worked fine
select SQL_NO_CACHE * from foo;
From this I was able to conclude that it was the issue as it was using Cached data.
I've faced the same issue with latest MySQL Client (>5.7) while trying to connect lower versions of MySQL like 5.1.xx.
To avoid this issue (ERROR 2027 (HY000): Malformed packet), create a user with latest password authentication.
ex:
Login to MySQL 5.1.xx server and execute..
mysql> create user 'testuser'#'xx.xx.xxx.%' identified by 'testuser_Secret1';
Check if you have old_passwords enabled, then disable it for that session.
mysql> show session variables like 'old_passwords';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| old_passwords | ON |
+-----------------+-------+
mysql> set session old_passwords = 0;
mysql> GRANT select on test.* TO 'testuser'#'xx.xx.xxx.%' identified by 'testuser_Secret1';
Verify password that should begin with "*SOMETHING1123SHOWNBELOW3034".
mysql> select user,host,password from mysql.user where user = 'testuser';
+-----------+---------------+-------------------------------------------+
| user | host | password |
+-----------+---------------+-------------------------------------------+
| testuser | xx.xx.xxx.% | *053CB27FDD2AE63F03D4A0B919E471E0E88DA262 |
+-----------+---------------+-------------------------------------------+
Now try logging from MySQL 5.7.xx Client and try to establish a connection to MySQL 5.1.xx server.
[testuser#localhost]# mysql -V
mysql Ver 14.14 Distrib 5.7.31, for Linux (x86_64) using EditLine wrapper
[testuser#localhost]# mysql -hxx.xx.xxx.xxx -u testuser -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1528853
Server version: 5.1.73-log Source distribution
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
For the people that has this error when the execute the query (not when connecting to DB), the problem is the cache configuration in database.
You can find the bug description here:
https://bugs.mysql.com/bug.php?id=86318
The solution:
disable the cache configuration:
query_cache_limit = 0
query_cache_size = 0
query_cache_type = 0
In the long term there are no negative repercussions, since the latest versions of MySQL no longer support this feature. With little data the cache works correctly, but in large quantities it generates a bottleneck.
More info about the cache removed from mysql 8.0:
https://mysqlserverteam.com/mysql-8-0-retiring-support-for-the-query-cache/
i solved this issue. i was facing this issue in my PHP 7.2. First i created a new user and upgrade it in my script. Then i upgrade PHP 7.2 to 7.3. And it worked. :)
I have MySQL Community Server version 5.7.17 running on Centos 6, everything comes with clean install, Centos 6 installed with "minimal" options, MySQL installed by official yum repo.
When I start MySQL server, the log "/var/log/mysqld.log" showing:
[Note] Access denied for user 'UNKNOWN_MYSQL_USER'#'localhost' (using password: NO)
It appears at the last line of the log, I tried to:
mysql> select * from mysql.user;
I can only see "root" and "mysql.sys" which comes by default, may I know what is the user 'UNKNOWN_MYSQL_USER'#'localhost'? is that something new in the version 5.7.17?
Thanks.
Nothing to worry about :)
You are receiving this message because someone/something tried to access MySQL server, but connection failed. You can reproduce this behaviour by attempting to connect to MySQL with wrong user and/or password and watch the error log file.
In your case, looks like it's the /etc/init.d/mysqld itself trying to test if MySQL server is up and running.
TIMEOUT="$STARTTIMEOUT"
while [ $TIMEOUT -gt 0 ]; do
RESPONSE=`/usr/bin/mysqladmin --socket="$socketfile" --user=UNKNOWN_MYSQL_USER ping 2>&1`
By default, in MySQL 5.7 the error log verbosity is set to 3 (errors, warnings and notes), this is why you're seeing this message in the error log file.
mysql> show variables like 'log_error_verbosity';
+---------------------+-------+
| Variable_name | Value |
+---------------------+-------+
| log_error_verbosity | 3 |
+---------------------+-------+
I think it's just Mysql script to make sure your Mysql server db secure or not. If your log doesn't show this line, it mean they can access to db with 'UNKNOWN_MYSQL_USER'#'localhost' without password.
I have a Linux machine (on 10.0.0.10) which I deployed my Play app to using:
activator dist
I have a Windows machine (on 10.0.0.51) running MySQL.
The database has 3 user accounts set up root#localhost, db_user#localhost, db_user#% all users have all permissions (it's just for testing).
I can access the db from the Linux machine using the mysql shell:
[neil#localhost ~]$ mysql -u db_user -p -h 10.0.0.51
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.12 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| test_db |
| mysql |
| performance_schema |
| sakila |
| test |
| world |
+--------------------+
8 rows in set (0.04 sec)
mysql>
Where test_db is the test database I set up on the Windows machine.
However when I try to run the Play application I get the following:
[neil#localhost ~]$ ~/TEST_APP-1.0-SNAPSHOT/bin/test_app
Play server process ID is 5908
[error] c.j.b.h.AbstractConnectionHook - Failed to obtain initial
connection Sleeping for 0ms and trying again. Attempts left: 0.
Exception: java.net.ConnectException: Connection
refused.Message:Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago.
The driver has not received any packets from the server.
Oops, cannot start the server.
Configuration error: Configuration error[Cannot connect to database
[db_user]]
at play.api.Configuration$.play$api$Configuration$$configError
(Configuration.scala:94)
...
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago.
The driver has not received any packets from the server.
...
Here is the db config in my application.conf:
db.db_user.driver=com.mysql.jdbc.Driver
db.db_user.url="jdbc:mysql://10.0.0.51:3306/test_db?allowMultiQueries=true"
db.db_user.user=db_user
db.db_user.pass="password"
db.db_user.partitionCount=3
db.db_user.maxConnectionsPerPartition=20
db.db_user.minConnectionsPerPartition=5
db.db_user.acquireIncrement=5
It is worth noting that this configuration works when I am running the app in dev mode on Windows. But I do not know what's wrong on the Linux box and I have run out of things to try. (note I tried this with all firewalls turned off and got the same issue).
UPDATE
Within the play application I use:
public static final String DB_USER = "db_user";
...
JdbcTemplate jt = new JdbcTemplate(DB.getDataSource(DB_USER));
So I shouldn't have to use db.default.etc... in the conf? Is this not correct?
UPDATE 2
I don't know how I missed this but there was something else further down in the stack trace that is indicative of the problem (the stack trace is quite long so I didn't want to list the whole thing, maybe I should have):
Caused by: java.net.ConnectException: Connection refused
So... the server is listening on port 3306, on the windows server running netstat -an yields:
TCP 0.0.0.0:3306 0.0.0.0:0 LISTENING
TCP [::]:3306 [::]:0 LISTENING
The firewall is turned off (I know... just for testing).
And MySQL is accepting connections from the CLI.
I've just had a brain wave though.... The application.conf was generated on windows... I wonder if I need to run dos2unix on the config file which would be why it cannot find "db_user".
UPDATE 3
No :(
You need to use db.default in conf.
from JavaDatabase
I think the correct key to specify the password is not pass, but password:
db.db_user.password="password"
Also you can try to use db.default.* and DB.getDataSource(), but I guess that will not make much difference...