LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   I have mysql connect error sometimes when trying to submit a form on a Open Suse 11 (https://www.linuxquestions.org/questions/linux-server-73/i-have-mysql-connect-error-sometimes-when-trying-to-submit-a-form-on-a-open-suse-11-a-689515/)

Murattash 12-10-2008 03:20 AM

I have mysql connect error sometimes when trying to submit a form on a Open Suse 11
 
Dear All,

I am hosting my website on Open Suse 11 and using php, mysql and apache. I have installed all packages through Yast. My problem is that, on my website there is a form created by using PHP, and users submit data using this form to mysql server and results are shown on a different page. Most of the time users can submit using this form but I have received some e-mails saying that they get "can not connect to mysql" error. It is fairly new and there are not many users using the website however it is very annoying to receive such e-mails. I checked on different forums and tried many recommnedations however none of them fixed the problem. I have changed the settings of mysql configuration file to use more memory and connections but still no luck.. Please advise if you have any opinion ?

tanveer 12-11-2008 03:41 AM

Not many users means how many? For example, I have an internal web server with over 5000 users(qps:129) and it doesn't show anything like connection error.

What is your HW configuration, mysql version, PHP, what settings you changed in mysql?

"can not connect to mysql" is it an error auto generated by mysql or your coding output.

Murattash 12-12-2008 03:05 AM

--- PHP.INI----------------

[MySQL]
mysql.allow_persistent = On
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port =
mysql.default_socket =/var/lib/mysql/mysql.sock
mysql.default_host =
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = 120
mysql.trace_mode = On
[MySQLi]
mysqli.max_links = -1
mysqli.default_port =
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off
-------------------------------------------



--------my.cnf-----------------------------

[client]
#password = your_password
port = 3306
socket = /var/lib/mysql/mysql.sock
[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
skip-locking
old_passwords=1
key_buffer = 512M
max_allowed_packet = 10M
max_connect_errors=99999
table_cache = 1200
sort_buffer_size=16M
net_buffer_length=256
read_buffer_size = 16M
read_rnd_buffer_size = 16M
myisam_sort_buffer_size = 256M
skip-name-resolve
query_cache_size = 64M
query_cache_limit = 16M
query_cache_type = 1
max_user_connections=999
max_connections=750
wait_timeout=240
connect_timeout=180
skip-networking

server-id = 1

skip-host-cache

[safe_mysqld]
log-error=/var/lib/mysql/mysqld.log

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
[isamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 4M
write_buffer = 4M

[myisamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 4M
write_buffer = 4M

[mysqlhotcopy]
interactive-timeout

[mysqld_multi]
mysqld = /usr/bin/mysqld_safe
mysqladmin = /usr/bin/mysqladmin
log = /var/log/mysqld_multi.log
-----------------------------------------------------------------

my php.code
$username = "root";
$pw = "*******";
$dbname = "******";

$db = mysql_connect("localhost", $username, $pw) or die(mysql_error());
mysql_select_db($dbname,$db) or die(mysql_error());

$queryInsert1 = "INSERT INTO headers VALUES (..... )";

mysql_query($queryInsert1) or die ('Error connecting to mysql');

$queryInsert2 = "INSERT INTO topics VALUES(.....)";
mysql_query($queryInsert2) or die ('Error connecting to mysql');

-------------------------------------------------------------------------------------
Hi tanveer,

Above is my php.ini and my.cnf settings. Yesterday I noticed that in php.ini "socket= " entry was null so I just changed it to "socket= /var/lib/mysql/mysql.sock". As I mentioned before I don't get this error but some users of my website does. At the moment I have around 50 visitors to my website per day. After this recent change I e-mailed to one user who got this error to try it again but I haven't got any reply yet.

My server is using Open Suse 11.0 and it has 1.5 GB Ram and two p4 3.0 ghz processors. I have configured everything through YAST. I am on php 5 and mysql 5 but not sure what is exact version numbers.

The error they get is I think the one in the code "Error connecting to mysql" not a system error.. So the problem I guess should somewhere within this code...



Hope you can have a better understanding of my configuration now..


Thanks


All times are GMT -5. The time now is 12:15 AM.