MySQL server has gone away #2006 - Azure server and using PHP - php

I have trouble with this query:
create temporary table IF NOT EXISTS vt_tmp_u2275(id int(11) primary key) ignore (SELECT 2275 as id) UNION (SELECT vt_user2role.userid AS userid FROM vt_user2role INNER JOIN vt_users ON vt_users.id=vt_user2role.userid INNER JOIN vt_role ON vt_role.roleid=vt_user2role.roleid WHERE vt_role.parentrole like 'H1::H4::H43::H401::H249::H250::H251::H776::H252::H544::H687::H794::H253::H360::H441::H442::%') UNION (SELECT groupid FROM vt_groups where groupid in (2841,2842,2843,2844,2845,2846,2847,2848,2864,2897,2903,2904,2908,2909,2910,3325,3372,3374,3377,4255,4379,4402,4541,4548,4740,4791,4792,4803,4805,4912,4953,4964,4966,4969,4970,4973,4982,4984,4985,4995,5004,5009,5010,5011,5017,5018,5023,5026,5033,5034,5041,5042,5043,5045,5047,5048,5050,5051,5055,5060,5062,5064,5065,5066,5072,5074,5078,5080,5086,5088,5099,5116,5130,5211,5213,5252,5293,5298,5300,5305,5309,5310,5313,5327,5331,5333,5343,5363,5364,5373,5415,5418,5420,5423,5424,5438,5448,5451,5453,5468,5491,5492,5513,5544,5601,5606,5611,5744,5905,5938,6023,6031,6032,6033,6034,6035,6038,6041,6042,6046,6056,6064,6065,6069,6070,6072,6079,6091,6092,6100,6101,6105,6113,6129,6153,6154,6155,6156,6158,6162,6164,6165,6166,6167,6171,6172,6173,6175,6177,6178,6183,6190,6201,6203,6204,6205,6207,6210,6212,6218,6219,6221,6225,6231,6248,6258,6259,6261,6264,6265,6266,6267,6268,6269,6270,6271,6274,6275,6276,6277,6279,6280,6281,6282,6293,6298,6311,6312,6313,6314,6315,6317,6319,6320,6323,6324,6325,6327,6328,6329,6330,6334,6355,6364,6391,6392,6394,6395,6399,6400,6404,6405,6407,6408,6409,6411,6412,6415,6424,6428,6430,6431,6432,6433,6435,6436,6443,6447,6449,6864,6867,6868,6869,6875,6880,6883,6884,6885,6942,6954,6959,6961,6966,6967,6969,6972,6978,6980,6981,6987,6989,6992,6994,6997,6998,7001,7003,7006,7007,7012,7013,7017,7022,7030,7031,7037,7038,7041,7044,7045,7046,7048,7052,7056,7057,7067,7070,7078,7079,7088,7090,7092,7093,7096,7100,7101,7102,7103,7108,7109,7115,7116,7117,7119,7120,8215,8525,8528,8725,8739,8927,9161,9162,9258,9259,9296,9331,9459,9460,9499,9504,9505,9563,9569,9570,9571,9669,9671,9700,9730,9754,9788,9859,9936,9957,10089,10196,10197,10673,10764,10781,10798,10805,11552,11553,11618,11627,11697,11807,11822,11824,11825,11826,11837,11838,11840,11841,11878,11903,11904,11920,11921,11922,11962,11964,11982,11984,12020,12021,12022,12032,12052,12053,12069,12104,12105,12113,12134,12141,12142,12144,12145,12175,12176,12184,12190,12206,12207,12208,12217,12246,12248,12249,12273,12303,12320,12325,12357,12374,12394,12409,12422,12438,12455,12511,12518,12632,12638,12671,12700,12752,12756,12757,12758,12763,12766,12772,12775,12780,12799,12800,12801,12812,12828,12833,12836,12837,12854,12884,12896,12900,12902,12930,12931,12992,12993,12994,13021,13028,13029,13035,13086,13095,13139,13162,13173,13182,13183,13196,13197,13207,13209,13213,13214,13268,13269,13297,13298,13302,13322,13323,13324,13337,13340,13342,13355,13357,13359,13380,13404,13405,13406,13407,13420,13421,13422,13423,13428,13429,13430,13432,13435,13449,13450,13451,13459,13460,13461,13462,13463,13466,13481,13482,13572,13611,13612,13626,13627,13643,13658,13659,13665,13683,13691,13692,13693,13699,13700,13701,13720,13721,13722,13728,13729,13743,13757,13758,13759,13761,13770,13771,13803,13809,13810,13812,13813,13814,13816,13845,13864,13865,13883,13884,13885,13886,13887,13893,13894,13895,13896,13913,13914,13962,13981,14038,14048,14050,14057,14058,14066,14068,14070,14076,14077,14092,14094,14099,14104,14126,14147,14152,14159,14167,14168,14176,14177,14178,14189,14190,14195,14196,14202,14204,14231,14238,14239,14240,14241,14243,14270,14271,14272,14292,14293,14303,14306,14318,14319,14320,14328,14337,14338,14340,14341,14342,14343,14374,14375,14376,14380,14384,14385,14389,14394,14406,14407,14412,14416,14417,14418,14419,14420,14421,14422,14423,14424,14425,14426,14427,14428,14429,14430,14431,14432,14433,14434,14435,14436,14437,14438,14439,14440,14441,14442,14443,14444,14445,14446,14448,14449,14450,14451,14452,14454,14455,14456,14462,14463,14465,14466,14467,14469,14479,14489,14492,14493,14494,14495,14496,14497,14499,14500,14503,14505,14507,14508,14514,14515,14519,14522,14525,14526,14527,14528,14542,14543,14547,14549,14553,14558,14559,14562,14608,14609,14615,14626,14627,14628,14632,14634,14638,14642,14667,14675,14684,14687,14691,14704,14705,14708,14711,14742,14747,14748,14759,14760,14761,14766,14767,14840,14841,14849,14858,14868,14869,14876,14879,14881,14882,14904,14907,14911,14912,14917,14918,14928,14953,15016,15050,15056,15060,15062,15073,15074,15081,15083,15086,15088,15092,15095,15101,15109,15110,15111,15140,15141,15142,15143,15144,15146,15149,15150,15166,15167,15176,15193,15194,15195,15199,15209,15220,15221,15223,15228,15247,15248,15249,15250,15251,15268,15269,15270,15271,15272,15273,15275,15278,15305,15320,15324,15365,15366,15388,15389,15390,15405,15415,15416,15430,15431,15432,15433,15436,15453,15454,15455,15461,15472,15473,15474,15480,15481,15500,15501,15520,15521,15522,15547,15557,15558,15559,15560,15561,15569,15576,15577,15578,15579,15589,15590,15591,15592,15593,15594,15607,15608,15615,15616,15617,15618,15623,15624,15625,15627,15628,15650,15662,15663,15682,15688,15689,15690,15717,15720,15721,15722,15723,15724,15732,15734,15735,15758,15772,15786,15788,15800,15801,15802,15803,15804,15805,15817,15818,15819,15839,15840,15863,15864,15865,15883,15884,15885,15886,15897,15907,15915,15917,15918,15937,15938,15949,15951,15958,15959,15960,15973,15975,15976,15983,15984,15985,15986,15988,15996,15997,16007,16008,16009,16015,16016,16029,16037,16045,16046,16047,16053,16062,16063,16072,16074,16075,16076,16077,16085,16089,16095,16115,16116,16120,16123,16127,16129,16130,16131,16135,16136,16154,16155,16158,16159,16160,16166,16167,16173,16174,16175,16176,16177,16178,16179,16180,16192,16193,16200,16210,16211,16213,16214,16215,16216,16217,16237,16238,16239,16240,16247,16254,16255,16276,16277,16278,16286,16294,16296,16299,16313,16317,16337,16344,16372,16386,16389,16390,16391,16415,16441,16446,16458,16467,16468,16469,16470,16474,16489,16490,16491,16507,16508,16509,16522,16523,16524,16525,16526,16527,16529,16559,16641,16642,16645,16646,16647,16648,16649,16650,16652,16653,16669,16671,16678,16679,16680,16683,16694,16695,16697,16698,16702,16709,16710,16711,16712,16713,16729,16730,16731,16732,16745,16746,16747,16761,16762,16766,16841,16862,16865,16878,16893,16904,16905,16906,16907,16930,16931,16932,16946,16947,16960,16961,16964,16992,17003,17004,17014,17015,17021,17022,17023,17041,17048,17049,17050,17051,17058,17059,17073,17092,17112,17120,17124,17134,17135,17136,17138,17139,17160,17172,17175,17181,17182,17186,17187,17196,17198,17200,17210,17230,17244,17246,17249,17261,17264,17265,17279,17286,17309,17314,17326,17327,17328,17333,17334,17335,17339,17349,17350,17351,17352,17353,17355,17371,17373,17376,17377,17397,17398,17399,17406,17407,17408,17412,17424,17426,17427,17437,17438,17449,17450,17451,17452,17453,17466,17467,17488,17489,17490,17491,17514,17515,17516,17521,17535,17536,17567,17569,17581,17601,17635,17640,17650,17653,17655,17656,17659,17672,17695,17700,17702,17742,17744,17764,17766,17771,17772,17781,17783,17792,17795,17797,17798,17799,17832,17833,17858,17859,17881,17888,17904,17905,17959,17960,17961,17966,17967,17990,17995,17997,17998,18000,18014,18052,18057,18058,18059,18064,18076,18077,18079,18083,18113,18114,18115,18116,18117,18123,18124,18125,18140,18145,18149,18151,18152,18153,18176,18188,18193,18199,18206,18207,18208,18218,18219,18221,18222,18223,18225,18241,18244,18249,18250,18252,18266,18267,18268,18269,18270,18271,18273,18285,18286,18287,18292,18293,18295,18304,18307,18308,18321,18323,18325,18329,18331,18332,18341,18342,18343,18345,18358,18359,18360,18365,18369,18370,18371,18372,18373,18374,18375,18392,18395,18397,18401,18420,18421,18422,18428,18476,18482,18485,18497,18501,18514,18515,18522,18523,18524,18525,18526,18527,18528,18535,18536,18537,18538,18539,18545,18546,18560,18561,18562,18563,18564,18567,18568,18569,18570,18572,18574,18575,18576,18577,18578,18582,18584,18595,18596,18603,18604,18623,18624,18628,18629,18630,18631,18640,12901,13436,14093,15087,15391,15392,15397,15556,15562,15733,16212,16442,16555,17378,17568,17634,17654,17678,17791,17831,18031)
Error: MySQL server has gone away
Code: 2006
Code is 2006 so I found online it is CR_SERVER_GONE_ERROR. I tried to resolve this issue, but without succession...
Here are some server related settings:
MySQL 8.0:
wait_timeout: 2147483
innodb_lock_wait_timeout: 1073741824
lock_wait_timeout: 31536000
net_read_timeout: 31536000
net_write_timeout: 31536000
interactive_timeout: 31536000
max_allowed_packet: 1073741824
tmp_table_size: 134217728
max_join_size: 18446744073709551615
PHP 7.2:
default_socket_timeout: 60000
mysqli.reconnect: On
post_max_size: 128000M
upload_max_filesize: 128000M
max_execution_time: 60000
max_input_time: 60000
memory_limit: 128000M
Values are extremely high for debugging reasons. Hint could be that, when I edit query and remove only one groupid from there, error disappears and everything works as expected.
When I run query in adminer without using application, query passes even without editing.
I am using SSL MySQL connection to Azure MySQL server 8.0.15 / tried also MySQL 5.6, same trouble.
When running this query on local dev environment, app works fine. As a driver for DB connection, I'm using adodb mysqli driver.
I also tried to compare server settings of both MySQL and PHP on local and beta server, it wasn't useful. Now I think trouble could be somewhat around that SSL connection to database. But I don't know what to search for...
Please help, I am out of ideas right now...
UPDATE
So I tried to turn off the SSL enforcing on Beta server in Azure portal and change connection on app - not to use the SSL connection.
App loaded results without error. So yes, problem is related to SSL connection with MySQL server.

Related

Error connecting to SQL Server using PDO in PHP [duplicate]

My Ubuntu vagrant Laravel Homestead set up has been configured to connect to MSSQL. Randomly it's starting throwing the following error on every query going to the MSSQL database (on a Windows server).
Any ideas? I can't find much info re:this available on Google.
I restarted PHP and confirmed SQLSRV modules are loaded.
SQLSTATE[IMSSP]: An unsupported attribute was designated on the PDO object. (SQL: select top 10 * from [orders] where [ordertype] = SO order by [orderdate] desc)
Check this issue report PDO::ATTR_PERSISTENT is not supported. Also they are reporting problems with PDO::ATTR_ERRMODE so check your connection for these two parameters.

Laravel: An unsupported attribute was designated on the PDO object. MSSQL on Ubuntu

My Ubuntu vagrant Laravel Homestead set up has been configured to connect to MSSQL. Randomly it's starting throwing the following error on every query going to the MSSQL database (on a Windows server).
Any ideas? I can't find much info re:this available on Google.
I restarted PHP and confirmed SQLSRV modules are loaded.
SQLSTATE[IMSSP]: An unsupported attribute was designated on the PDO object. (SQL: select top 10 * from [orders] where [ordertype] = SO order by [orderdate] desc)
Check this issue report PDO::ATTR_PERSISTENT is not supported. Also they are reporting problems with PDO::ATTR_ERRMODE so check your connection for these two parameters.

After snapshot boot : Informix Client -23101 / Oracle instant client -28759

Not to waste your time, I'll describe what I had && what I have now. My apps are written on php. They live on redhat6 server with nginx + apache web servers. We store data in MySQL DB, but we have lots of imports from Oracle and IBM Informix DB's, & mssql. For Oracle & Informix I have installed clients && compiled libraries pdo_oci.so & pdo_informix.so . For a few months they were working as expected.
But a week ago, admins made a snapshot of out virtual server, and reloaded it. Now only MySQL and mssql connectors work, and Oracle & IBM clients thows errors.
Oracle : -28759
Failed : SQLSTATE[HY000]: pdo_oci_handle_factory: ORA-28759: failure to open file (/usr/local/src/php-5.3.3/ext/pdo_oci/oci_driver.c:579)/opt/project/www/test.php149
IBM Informix : -23101
Failed : SQLSTATE=HY000, SQLDriverConnect: -23101 [Informix][Informix ODBC Driver][Informix]Unspecified System Error = -23101./opt/project/www/test.php146
Well, as official documentations says, Informix error is connected with the lost env variables of DB_LOACALE & CLIENT_LOCALE...etc.
This is strange, because all this time I was using this string for my connections :
$dbh = new PDO ("informix:host=example.ru; database=some_db; server=db_net; CursorBehavior=0; DB_LOCALE=en_US.57372; CLIENT_LOCALE=en_US.57372;", "db_login", "pass");
I tried to set up this env variables for apache (httpd) , but this error still accures. Now I have this variables set after server reboot, but no success. May be I'am doing something wrong or at the wrong place or user name...
About Oracle , documentation says that it is connected with files loading:
And the web doc says that it is mostly ssl error and is connected with the trouble of the client, that can not find SSL Wallet files. I Have TCPS secure connection to Oracle DB with wallet, and I remember that it was a real trouble to make Instant client to look at the right place. More than that, I have client tracing enabled, but it is writing log only when I use sqlplus directly from terminal. When I run my php scripts, I got only errors and no log.
Questions:
How to enable Informix variables correctly, or how to resolve this
issue in different way.
How to enable "net tracing" for oracle, to
see what he is looking for?
How to store this variables for future
reboots/reloads/snapshots...etc. ?
People. Enable tracing of all what is possible and use "strace" command to check where programm is failing!!!
Thanks to Luís Marques! I found gls in my logs and tried to make link for it.. to real IBM/informix/gls... than another msg trouble acured.../ I made soft link from /usr/informix to my real /opt/IBM/informix and all connections successfully woke up!
Thank you man. You really helped me to finish this trouble. I post this as ansver but will accept yours as thanks to you! =)
This may be related to file / dir permissions rather than env variables.
The oracle error seems to indicated that it can no longer open/read the files it requires.
The informix -23101 error can also be caused by the driver being unable to read GLS files required for locale support.
Does the apache user have access to the Informix Client SDK directories and files?

MSSQL+ODBC+PHP = 0 rows in result

I'm using remote MSSQL base via php + linux ODBC. All was fine, but today i wrote query with SET + PIVOT and got error:
[unixODBC][FreeTDS][SQL Server]SELECT failed because the following SET options have
incorrect settings: 'ANSI_NULLS, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL,
ANSI_WARNINGS, ANSI_PADDING'. Verify that SET options are correct for use with indexed views
and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or
XML data type methods and/or spatial index operations.
I tried to write SET ANSI_NULLS ON etc but it wont works, there is 0 fields in result.
The same query executed directly on server via MSSQL studio works perfectly.
Any idea where can be a problem?
Thanks.
UPDATE:
freetds.conf
[syserver]
host =192.168.1.200
port = 1433
tds version = 7.0
AnsiNPW=YES
QuotedID=YES
odbc.ini
[sy_odbc]
Driver = FreeTDS
Description = ODBC connection via FreeTDS
Trace = No
Servername = syserver
Database = Insy
odbcinst.ini
[FreeTDS]
Description = TDS driver (Sybase/MS SQL)
Driver = /usr/lib/odbc/libtdsodbc.so
Setup = /usr/lib/odbc/libtdsS.so
CPTimeout =
CPReuse =
FileUsage = 1
Before I got tds version=6.0, and after changing it up to 7.0 all errors such ANSI_NULLS gone, but I still have 0 rows in result. AnsiNPW=YES and QuotedID=YES do nothing for me. If try to change version to 8.0 in result of simple query i have ??????????. TDS_version=7.0 in odbc.ini also do nothing.
My query here.
And my connection string is: $conn=odbc_connect('sy_odbc','t','t');
Update 2:
Some of my php pages stop working when i had changed TDS_version to 7.0 or 7.2, so i return it back to 6.0.
Connection string as you proposed don't work for me. At all. (I'm using mine more than year, and it was fine, before that issue)
Here is errorlog for problem query with 6.0 version (here we have ANSI_NULLS etc warnings)
Here is errorlog for problem query with 7.0 version (There is no warnings, but 0 rows in result)
There are two more things I can think of Sergii:
1) Your connection string. The manual says your connection string should look like this:
$conn = odbc_connect('Driver={sy_odbc};Server=192.168.1.200;Database=Insy', $username, $password);
So I'd give that a try first and see if it helps.
2) Any time you are having problems with ODBC connections you should turn on logging so you can capture error messages. To do this add the following lines to your /etc/odbcinst.ini file:
[ODBC]
Trace = yes
TraceFile = /tmp/odbc.log
If your query still doesn't work, edit your question and add the output from the odbc.log file (assuming there are error messages in it).

phpmyadmin using mysqli connects, but my php using mysqli errors out

This is driving me nuts! I am getting the classic "Can't connect to local MySQL server through socket '/var/run/mysql4d/mysql4d.sock' (13)".
Everything I've dug up so far tells me my setup should be OK (eg, defining the sockets in php.ini and my.cnf, etc). Worse... phpmyadmin works with the same un/pw I am using in my own php. So obviously it's possible to connect, but I am screwing it up
I tried reverse-engineering the connection from phpmyadmin, but gave up it as too convoluted after a couple hours.
Can anyone offer some advice?
My configuration: Ubuntu 9.10 (Karmic), Apache 2.2, PHP 5.2.6, MySQL 4.1.22 (for legacy app reasons).
my.cnf (/var/lib/mysql4/my.cnf):
[client]
port = 3306
socket = /var/run/mysql4d/mysql4d.sock
[mysqld]
port = 3306
socket = /var/run/mysql4d/mysql4d.sock
php.ini (/etc/php5/apache2/php.ini):
[MySQL]
mysql.default_socket = /var/run/mysql4d/mysql4d.sock
[MySQLi]
mysql.default_socket = /var/run/mysql4d/mysql4d.sock
Same problem using mysql instead of mysqli, btw.
EDIT:
I should mention that I have installed mysql4 alongside the ubuntu default install of php & mysql for use with a legacy application and it is this installation that I am having trouble connecting with. I tried this:
ini_set('mysql.default_socket', '/var/run/mysql4d/mysql4d.sock');
and now the connection goes thru, but all queries return empty sets. (cries in frustration)
This sounds like a permission problem in /var/run/mysql4d/mysql4d.sock. What user are you running this as? Are the permissions o.k. on file system level?
If you Google for the error messages, you'll find a lot of people who had this and it was always a permission issue, sometimes due to an activated SELinux. Check this thread for a few possible solutions.

Categories