identify mysql problem - php

I've write a web-application in PHP which has 30 tables+views. From time to time my application doesn't work and think this is related to the mysql db.
Unfortunately I can't see the errors from the browser on that server because php.ini says so. Also when I try to connect to mysql db using phpMyAdmin the connection fails when I try to select my DB.
How can i see which is the problem to my mysql DB. It works from time to time but I don't understand why.

You could look in the MySQL error log - it's under /var/log/mysqld.log on my setup...
Your PHP errors may be getting sent to another log file - try the Apache / IIS error log (global or for the particular vhost, depending on your config for Apache - I can't say for IIS) or to the system log - /var/log/messages

Related

Wordpress Error Establishing Database Connection

I have reinstalled phpAdmin (due to another issue) and updated wp-config with the correct names for DB, user name, password, etc, but now I cannot access the wordpress site (www.enablie.co.uk, www.enablie.co.uk/wp-admin or http://www.enablie.com/phpmyadmin).
I have tried adding the repair code
define('WP_ALLOW_REPAIR', true);
But still cannot access via : http://www.enablie.co.uk/wp-admin/maint/repair.php.
I am also getting this error when trying to access sql -
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
On Chrome is is showing a basic version of the site (broken styles) when not logged in, but get the EEDC as soon as try to log in. On Safari I have the EEDC immediately.
I assume I have just done something stupid, but most errors seem to suggest naming errors in the config file which I know is not the case. I have also checked the db still exists via mysql to ensure that there is not a problem there.
I assume that the re-install removed something from the overall settings that I now need to manually reconfigure, but I can't find any guidance that points me where to look so would appreciate some help on what I need to change. Much appreciated!
I rebooted by instance and that seemed to fix the issue.

Where is /usr/local/lib on online server

I have a server hosted on 000webhost.com
In the file manager there is a public_html folder where I store my website files, but no \usr folder.
Generally I could just access this file through the command line or terminal but this is not the case on this server. Unless there are command line tools that I simply couldnt find (I know it is a linux server);
I ran phpinfo() and the configuration file path was in usr/local/lib but I have no idea how to access that.
Any ideas? Thanks in advance.
Go to http://www.000webhost.com/faq.php look at the section on connecting to MySql. Your solution is likely there.
Here is a synopsis:
If you cannot connect to MySQL server, there could be some causes:
- Incorrect MySQL hostname.
Never use 'localhost' as your MySQL hostname! You can find your MySQL hostname by logging on to members area, entering control panel and clicking on MySQL icon.
- Incorrect MySQL username / password or database name.
You can find / setup MySQL username and database by clicking on MySQL icon from control panel. And you can change MySQL password by clicking on phpMyAdmin icon.
- Database failed to setup.
In a very rare cases MySQL database can fail to setup. To confirm this, please try to enter phpMyAdmin for any database. If you see database there, that means it setup was successful. And if you get access denied error by trying to enter phpMyAdmin, please delete the database and setup the same MySQL database again.
Please note that always you must give about 1 minute for any changes to apply on server.
If you still unable to connect to MySQL you check if it is server or your script problem in this way: if you can enter phpMyAdmin and see you database there, that means everything is working fine on our side. It's a problem with your PHP script.

How to start wamp?

I am unable to start wamp, .pid file deleted from location wamp\bin\mysql\mysql5.5.8\data, because of which unable to connect phpmyadmin, it's showing 2002 error, Please guide about how to start wamp.
The .pid file is recreated each time MySQL starts.
Mine looks like wamp\bin\mysql\mysql5.5.8\data\MACHINE_NAME.pid
Deleting it should not cause MySQL to fail on restart, so there must be another problem. Look at the mysql error log and if that does not tell you anything useful, look at the Windows Event Viewer, MySQL writes to the event viewer even before it tries to open and use its error.log file. There may be something in there that tells you what the problem is.
You can go to the Control Panel of the system and then remove the wamp server after you choose a new wamp server.

MYSQL queries not executing or not showing errors

Just installed a nginx server with ubuntu 11.04 and after loading my php program i was writing i noticed that no MYSQL queries run. I get no errores, either from PHP nor MYSQL.
The user my PDO connection uses has all priviledges.
When i change the host to any value, i do not get any error either.
I believe mysql is not showing any connection error. How do i check it's enabled? Just checked mysql.conf and i see nothing related to error reporting. Also looked php.ini and all error options are enabled, i also enabled it in-code.
I have no clue, it's useless to work with no kind of error reporting!
Thanks!
Where are your error logs for nginx? Have you looked in those? Is mysql running? Try service mysql status. PHP should still give you an error though if it can't connect to the database. How do you know the queries are not running? What I mean is, what are the symptoms? Maybe the queries are running but your input is bad?
Most important is to try to isolate the problem. 1) Use curl -v http://your_server to make sure nginx is actually serving the pages. 2) Set up a phpinfo.php file in the root web directory with <? phpinfo(); ?> and check the mysql settings and verify where log files for php are being written 3) Try installing phpmyadmin and see if you can connect to the database using that.
Each one of the above eliminates at least 1 of the elements (your program, PHP, nginx, mysql), helping you to narrow down the cause of your problem.
EDIT: Additional instructions for item 2. You are looking for the php error_log setting. If it is not set, the errors should go to stderr, which in this case I think would be your nginx log files (true at least for apache). You could also check that error_reporting is set to some reasonable value (try error_reporting=E_ALL for now). You can set both of these in your php.ini file, or in your program. See the manual in section PHP Error Handling Runtime Configuration. I would do a sanity check by triggering an error in my program at the beginning of the program and making sure the error shows up in the log file:
trigger_error('Want to be a rock star test message', E_USER_WARNING);
If you see your message, you've got the right log file and you should find your other errors (if any - mysql might not be the problem, could be bad input as I mentioned before).

phpmyadmin problem

can anyone solve this problem as per new to php
i have jsut installed wampsever 2.1 i am getting this error
my opertating system is windows 7 64 bit
phpmyadmin #2002 - the server is not responding (or the local mysql server's socket is not correctly configured)
The error message is pretty much self-explanatory: your MySQL configuration doesn't match that of php and/or phpmyadmin, or mysql isn't running.
You should do the following:
Make sure MySQL is running
Check phpinfo() for parameters of mysql extension
Check that config.inc.php in phpmyadmin has proper configuration directives

Categories