Cannot start mysql transaction in php fork - php

I have problem when start mysql transaction in child process with php pcntl_fork. The error message is:
PDO::beginTransaction(): send of 22 bytes failed with errno=32 Broken pipe
How to start transaction in child process with pcntl_fork
Thank you

If someone is struggling with this issue, here is the fix:
Try changing/setting up wait_timeout in your mysql my.cnf config file:
wait_timeout=3600
This config file is located in the /etc/mysql/my.cnf (Ubuntu/Debian) and /usr/local/mysql/my.cnf (OSX).
Restart mysql server and it should work.

Related

Heroku Worker Caching

I'm having trouble getting my worker process to update in Heroku. I have a worker dyno set in my Procfile that is connected to a Redis instance; I cannot see changes that I make to this file after deploying.
I've tried:
Resetting the dyno using heroku ps:restart worker.1 -a [appname]
Restarting all dynos using heroku ps:restart -a [appname]
Changing the contents of the file so the size is different
Changing the Procfile to point to a different PHP file
Nothing works. It looks like it picked up some of my changes overnight (maybe during reboot?) but I can't force it to pick up the changes... any ideas?
Logs to the rescue... I had an issue with my required include file paths, which was causing the build to fail. It was defaulting to the last successful build, which is why it looked like it was caching.
I was able to find this by watching the logs during the build:
heroku[worker.1]: Starting process with command `php bin/worker.php`
heroku[worker.1]: State changed from starting to up
heroku[worker.1]: Process exited with status 255
app[worker.1]: PHP Warning: require_once(../vendor/autoload.php): failed to open stream: No such file or directory in /app/bin/worker.php on line 9
app[worker.1]: PHP Fatal error: require_once(): Failed opening required '../vendor/autoload.php' (include_path='.:/app/.heroku/php/lib/php') in /app/bin/worker.php on line 9
heroku[worker.1]: State changed from up to crashed
Once I solved the build errors it no longer 'cached' and everything worked properly.
The include path that worked:
require_once(__DIR__ . '/../vendor/autoload.php');

Unable to connect mysql and getting socket error

I have installed xampp in my linux server. But during connection in command prompt i am getting below error. Please help me to fix the error.
linux-pott:/opt/lampp/var/mysql # mysqladmin -u root -p status
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket'/var/run/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysql/mysql.sock' exists!
I had similar problem on a CentOS VPS. If MySQL won't start or keeps crashing right after it starts, try these steps:
1) Find my.cnf file (mine was located in /etc/my.cnf) and add the line:
innodb_force_recovery = X
replacing X with a number from 1 to 6, starting from 1 and then incrementing if MySQL won't start. Setting to 4, 5 or 6 can delete your data so be carefull and read http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html before.
2) Restart MySQL service. Only SELECT will run and that's normal at this point.
3) Dump all your databases/schemas with mysqldump one by one, do not compress the dumps because you'd have to uncompress them later anyway.
4) Move (or delete!) only the bd's directories inside /var/lib/mysql, preserving the individual files in the root.
5) Stop MySQL and then uncomment the line added in 1). Start MySQL.
6) Recover all bd's dumped in 3).
Good luck!

MySQL: Still can't LOAD DATA LOCAL INFILE '/path/to/file.txt' INTO TABLE test FIELDS TERMINATED BY '\n'

Using Ubuntu Server 14.04 x64 / PHP 5.5.9-1ubuntu4 (cli) w/ FPM / MySQL InnoDB version 5.5.35
I've created a PHP script that downloads a text file from a remote server and then attempts to import it with the LOAD DATA LOCAL INFILE '/path/to/file.txt' INTO TABLE test FIELDS TERMINATED BY '\n'.
I've gone through the process of modifying the php.ini file:
[MySQL]
; Allow accessing, from PHP's perspective, local files with LOAD DATA statements
; http://php.net/mysql.allow_local_infile
mysql.allow_local_infile = On
I've modified my.cnf (both [mysql] and [mysqld] entries):
local-infile=1
local-infile
I've run MySQL from the terminal and then issue:
SET GLOBAL local_infile = 'ON';
I've manually started and stopped MySQL with:
sudo /etc/init.d/mysql start --enable-local-infile
After each of these commands I can run SHOW GLOBAL VARIABLES LIKE 'local_infile'; and it always says the value is ON. I have no problem whatsoever executing my LOAD DATA command from MySQL prompt but if I try to run the LOAD DATA stored in a PHP file it errors out with:
The used command is not allowed with this MySQL version
From what I've read, there seems to be a few who suggest to recompile PHP with "--with-mysql=/usr" but that seems like a real sledge hammer approach to me, maybe I'm wrong. I can issue ANY MySQL query except for that that from a PHP file. What am I doing wrong?
You have to write twice the following line into the file /etc/mysql/my.cnf
sudo gedit /etc/mysql/my.cnf
then under paragraph [mysql]
and paragraph [mysqld]
add the following line :
local-infile=1
then save the file
then restart

MySQL Database won't start in XAMPP Manager-osx

I downloaded XAMPP about a month ago and it was working just fine. Today I installed a voice recognition software and then restarted my computer. Ever since, MySQL won't start in my manager-osx application. It doesn't throw me an in the application log. This is what it says:
Stopping all servers...
Stopping Apache Web Server...
/Applications/XAMPP/xamppfiles/apache2/scripts/ctl.sh : httpd stopped
Stopping ProFTPD...
Checking syntax of configuration file
/Applications/XAMPP/xamppfiles/proftpd/scripts/ctl.sh : proftpd stopped
Restarting all servers...
Starting MySQL Database...
Starting Apache Web Server...
/Applications/XAMPP/xamppfiles/apache2/scripts/ctl.sh : httpd started
Starting ProFTPD...
Checking syntax of configuration file
/Applications/XAMPP/xamppfiles/proftpd/scripts/ctl.sh : proftpd started
Both my ProFTPD and my Apache Web Server are running. MySQL isn't.
When I go to phpmyadmin, it throws me this error message.
#2002 - No such file or directory
The server is not responding (or the local server's socket is not correctly configured).
Please help me. I have no idea what to do.
UPDATE:
After looking around the internet a bit, I found a similar problem a user had with MAMP, another user recommended killing the mysql process, what ever that means. Could this be a fix to my problem?
UPDATE 2:
I found the answer to my problem but I can't answer it yet. So here's the answer:
1) Open terminal and type
sudo su
and then put in your password
2) Then type
ps aux | grep mysql
(just copy and paste this)
3) You will need to get the process id of mysql. There should be number near the top, something like 739 or 8827
4) Kill the process using
kill -9 {process id}
this should look something like this: kill -9 739
5) Restart MySQL in manager-osx
This should work:
sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
Minimal Guide
1.
sudo killall mysqld
2.
manager-osx > start mysql
If that didn't work...
sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
Google the error...
Examples:
Error:
ERROR! The server quit without updating PID file (/Applications/XAMPP/xamppfiles/var/mysql/<computername>.local.pid)
My Solution:
In /Applications/XAMPP/xamppfiles/etc/my.cnf change user = <uid> s that <uid> is uid from id command.
$ id
uid=...
$ vim /Applications/XAMPP/xamppfiles/etc/my.cnf
...
If these commands don't work for you:
sudo killall mysqld
sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
Try this:
For XAMPP 7.1.1-0, I changed the port number from 3306 to 3307.
Click on Manage Servers
Select MySQL Database
Click on Configure on your right
Change your port number to 3307
Click OK
Close your Control Panel and relaunch it.
You are now good to go.
check the err log on your /Applications/XAMPP/xamppfiles/var/mysql/ with filename like your_machine_name.local.err, if you find something like: "Attempted to open a previously opened tablespace. Previous tablespace ... uses space ID"
the following works for me:
edit file:
/Applications/XAMPP/xamppfiles/etc/my.cnf
find the [mysqld] section, add one line:
innodb_force_recovery = 1
then run
sudo /Applications/XAMPP/bin/mysql.server start
everything is ok again.
and then the last step:
edit the my.cnf again and remove the line you just added :
innodb_force_recovery = 1
and restart mysql again. Otherwise all your tables will be read only
Try running these two commands in the terminal:
sudo killall mysqld
sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
For me the following worked: Change permission into 'read only' for 'everyone' to the file /Applications/XAMPP/xamppfiles/etc/my.cnf. Then start MySQL from XAMPP manager.
close XAMPP control
sudo killall mysqld
sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
it happened to me. and
sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
not work for me.
so, i reinstall the xampp, then fix it.
attention:
reinstall the xampp, will not delete mysql data, no need to worry about that.
I first couldn't manage to kill mysql daemon with the commands posted here. So I remembered my linux times and did the following:
I monitored the running processes by running top in one terminal window. Then I killed mysqld via sudo killall mysqld (screw the PID ;-) ) in another and restarted via sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start.
There's been a lot of answer, but I think I found what is causing it, at least for me. It looks like if you put your computer to sleep (or it falls asleep on its own), when it reopens, it tries to open the the mysql process again. At one point I looked at my activity monitor and I had 5 instances running - killing all of them and then starting mysql works.
sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
This worked for me.
I had success with easy killing all active mysql processes in Monitor Activity tool:
1) close XAMPP control
2) open Monitor Activity
3) select filter for All processes (default is My processes)
4) search for: mysql
5) force quit all the mysql
6) relaunch XAMPP control and launch apache again
Enjoy
try these two line from terminal
sudo killall mysqld
sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
on
macOs High Sierra
if mysql is not getting started from manager- oxs and have tried direct command i.e
sudo /Applications/XAMPP/bin/mysql.server start
too than
go to path edit
/Applications/XAMPP/xamppfiles/etc/
find file :
my.cnf
edit it
under the [mysqld] section, add following line:
innodb_force_recovery = 1
after it save and run or can be done from manager-osx
sudo /Applications/XAMPP/bin/mysql.server start
it should start the mysql.
once its run you need to again
edit the
my.cnf
file and remove the line just added
innodb_force_recovery = 1
stop and start mysql again. by command
sudo /Applications/XAMPP/bin/mysql.server start
or
by manager-osx
it will be working fine.
It can cause because of the software you installed or may be any other software which is using the same port 3306. This 3306 port is used by the Mysql in XAMPP. Similar kind of problem I faced for Apache. I was running skype and trying to run the XAMPP but the skype uses the same port as Apache so it was not working. Then I sign out from skype then the port was free and the apache started. So you should look for the software in you laptop which is blocking or making busy this port. Free that port by closing the software and then run XAMPP and It will work.
What I did was the following: In XAMPP Control Panel I edited the my.ini file of configuration of MySql and changed the port from 3306 to 3307 and it worked, hope it helped!
Edit: after you save this changes be sure that the service is off and then restart the service. I had this same problem when I installed MySQL, it's just the port.
I encountered this problem just now. I checked log file and found it is caused by the server was not shutdown correctly. So I found this http://rivenlinux.info/how-to-recover-innodb-corruption-for-mysql/ and add a simple configuration "innodb_force_recovery = 1" in [mysqld] in my.cnf. Then the problem was solved.
The log file is located /Applications/XAMPP/xamppfiles/var/mysql and it named accroding to your server name. Just link this XXX-MacBook-Pro.local.err
All the answers stated above in relation to changing the port number are in this situation the best way to solve this problem since you need your voice recognition software to coexist with MAMP. However, you must remember that changing this port number is going to affect all you subsequent connections to MySQL (i.e, terminal,php code,phpmyadmin,etc). Hence It would be advisable to change the port on which the voice recognition software runs. Hope this was helpful.
:)
if you are getting this error
.............ERROR! The server quit without updating PID file
Try this
Go to /Applications/XAMPP/xamppfiles/var/mysql/
if there is no file with the name Your_Username.local.pid
Your_Username should replace with your Mac Username
Create a file with this name
Then try
sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
its worked for me
It had the same problem, all I did was give read-only permissions for ALL users (system included) and all items included in the following folders:
/Applications/XAMPP/xamppfiles/etc
/Applications/XAMPP/xamppfiles/sbin
and relaunch XAMPP control and launch mysql server again
or
sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
I have same problem and get this error in hostname.err in directory /Applications/XAMPP/xamppfiles/var/mysql
2016-09-06 15:32:45 140735322399488 [Note] Plugin 'FEEDBACK' is
disabled. 2016-09-06 15:32:45 140735322399488 [Note] Heuristic crash
recovery mode 2016-09-06 15:32:45 140735322399488 [Note] Please
restart mysqld without --tc-heuristic-recover 2016-09-06 15:32:45
140735322399488 [ERROR] Can't init tc log 2016-09-06 15:32:45
140735322399488 [ERROR] Aborting
2016-09-06 15:32:48 20004 mysqld_safe mysqld from pid file
/Applications/XAMPP/xamppfiles/var/mysql/hostname.pid ended
Then I removed tc.log and It works fine after restart mysql through manager-osx
This could be due to the fact that another instance of mysqd is already running in your mac-book-pro (MacOs-10). It's next to impossible to kill/pkill mysqld or ....I tried that route many times, with out any success. Finally the following worked for me :
launchctl unload -w /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
wait a few minutes and check with
ps -ef|grep mysqld
It should be gone!
It might be the possibility that your voice recognition software has a installer of mysql internally and when u installed this software, it has installed mysql too and added it to the service and this mysql service starts once your system starts. So now u r having two mysql servers (one from voice recognition software and second is from XAMPP) that's why killing the previous process (mysql service) solved your problem. But this is not a permanent solution, you have to repeat it every time when ever you start your machine. So better is to find out that mysql server (service) and change its port no. OR change settings so that mysql service should not start when your machine start (but might be your voice recognition software won't work properly)
I hope it will help you.
Cheers
You seem to have found a work-around by killing the process, but make sure you check for free space on your MySQL partition. If your logs or db files are consuming all your drive space, mysqld will not start.
Restarting the computer, or using the 'kill' commands listed above solve the problem. AS for preventing it from happening, I've found this occurring anytime my computer goes to sleep. The port is obviously kept reserved, and then on wake, mysql tries to reconnect to that port, but can't. This could be your problem also.
I am running XAMPP 5.6.3-0 for OS X Yosemite 10.10.2 and ran into the same issue twice, the first time was with Mavericks. With a bunch of different solutions to the issue with MySQL Database not starting using Manager App I wanted to confirm what had worked for me. The workaround that always worked and forced MySQL to start was by opening Terminal and using:
sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
I had the Manager App open and started ProFTPD and Apache and then ran the sudo command.
The other suggestion by wishap that worked was to locate /Applications/XAMPP/xamppfiles/etc/my.cnf file and change the permissions for "everyone" to Read only.
The other problem I had that seems to be another issue with many solutions is the problem after everything is started then entering localhost which brings me to the xampp splash screen and then nothing. The only thing that worked for me, to at the very least, to access the phpMyAdmin page is by entering localhost/phpmyadmin
I hope this helps others reading through a bunch of threads for an answer.
Regards,
Erik
Try this, sudo service mysql stop it will stop any other mysql services and then restart xampp
Just Click on Managed Servers Tab in XAMPP MANAGER , Now select MySQL Database, Click on configure on right side.
Change port from 3306 to 3307 and it will work.
It had the same problem, all I did was give read-only permissions for all users and all items included in the following folders:
/Applications/XAMPP/xamppfiles/etc
/Applications/XAMPP/xamppfiles/sbin
Well, sometime there is just ERROR! message is shown in mysql comment on terminal.
Then, just reinstall (overwrite) XAMPP, then it can be solved.

how to start zoneminder server

i install the zoneminder as per their instruction give by zone minder.After installation they gave a command to start zomeminder server
"zmpkg.pl start" but when i use this i got this error .
Warning, overriding installed ./zm.conf file with local copy
Bareword "ZM_PATH_LOGS" not allowed while "strict subs" in use at /usr/share/perl5/ZoneMinder/Debug.pm line 265.
Compilation failed in require at /usr/share/perl5/ZoneMinder.pm line 34.
BEGIN failed--compilation aborted at /usr/share/perl5/ZoneMinder.pm line 34.
Compilation failed in require at /usr/bin/zmpkg.pl line 45.
BEGIN failed--compilation aborted at /usr/bin/zmpkg.pl line 45.
Zoneminder requires a web server and a background task:
service httpd start
service zoneminder start
From Start ZoneMinder
Look if there is something wrong with SQL dump import
In my case, in installation manual for Ubuntu 14.04 it is asked to import database dump with
MySQL -uroot -p < /usr/share/zoneminder/db/zm_create.sql
this failed and halted due to error with creation of 'Logs' table. I then edited the SQL file to add
DROP TABLE IF EXISTS `Logs`;
before
CREATE TABLE `Logs` (
and then imported the dump successfully. The zm service then started correctly without errors

Categories