MySQL database causes a high CPU to solve
Server Environment Liunx AS4 + PHP5 + Mysql5 + Apache 2
When I use the TOP command to query the system performance, I find that the CPU often reaches 100%
I thought it was a DDOS attack...I installed a firewall (it didn't work)
Started to find out if it is a system problem from the liunx system again, (it didn't work)
Occasionally found an article from the Internet, someone also encountered such a problem, but did not point out a specific solution,
But it reminded me that it's not a system problem or a program problem!
This time I started to filter the PHP code, and occasionally found that the code written by many brothers only had "normal" connections , there is no Close!
I installed all the pages and closed the database, and found that the CPU has been kept between 1%~10% (normal)
So remind everyone not to be a little lazy when writing PHP programs, causing low-level errors such as system overflow!
I'll write it down here, a little problem took me almost an afternoon to do this! It's also a lesson!
Paste some commonly used functions of mysql, please keep in mind! Other types of databases draw inferences from one example!
mysql_affected_rows--get the number of rows affected by the previous MySQL operation
mysql_change_user--change the logged in user on an active connection
mysql_client_encoding--returns the name of the character set
mysql_close--close MySQL connection
mysql_connect--open a connection to the MySQL server
mysql_create_db--create a new MySQL database
mysql_data_seek--move pointer to internal result
mysql_db_name--get result data
mysql_db_query--send a MySQL query
mysql_drop_db--drop (drop) a MySQL database
mysql_errno--returns the numeric encoding of the error message from the last MySQL operation
mysql_error--returns the textual error message generated by the last MySQL operation
mysql_escape_string--escape a string for use in mysql_query
mysql_fetch_array--Fetch a row from the result set as an associative array, or a numeric array, or both
mysql_fetch_assoc--get a row from the result set as an associative array
mysql_fetch_field--get column information from the result set and return it as an object
mysql_fetch_lengths--get the length of each output in the result set
mysql_fetch_object--get a row from the result set as an object
mysql_fetch_row--get a row from the result set as an enumerated array
mysql_field_flags--get the flags associated with the specified field from the result
mysql_field_len--returns the length of the specified field
mysql_field_name--get the field name of the specified field in the result
mysql_field_seek--set the pointer in the result set to the specified field offset
mysql_field_table--get the name of the table where the specified field is located
mysql_field_type--get the type of the specified field in the result set
mysql_free_result--free result memory
mysql_get_client_info--get MySQL client information
mysql_get_host_info--get MySQL host information
mysql_get_proto_info--get MySQL protocol information
mysql_get_server_info--get MySQL server information
mysql_info--get information about the most recent query
mysql_insert_id--get the ID generated by the previous INSERT operation
mysql_list_dbs--list all databases in MySQL server
mysql_list_fields--list fields in MySQL results
mysql_list_processes--list MySQL processes
mysql_list_tables--list tables in a MySQL database
mysql_num_fields--get the number of fields in the result set
mysql_num_rows--get the number of rows in the result set
mysql_pconnect--open a persistent connection to the MySQL server
mysql_ping--Ping a server connection, reconnect if not connected
mysql_query--send a MySQL query
mysql_real_escape_string--escapes special characters in strings used in SQL statements, taking into account the connection's current character set
mysql_result--get result data
mysql_select_db--select MySQL database
mysql_stat--get the current system status
mysql_tablename--get table name
mysql_thread_id--returns the ID of the current thread
mysql_unbuffered_query--send an SQL query to MySQL without fetching and caching the resulting rows
order lipitor 10mg generic & lt;a href="https://lipiws.top/"& gt;atorvastatin canada& lt;/a& gt; buy atorvastatin 20mg for sale
Bjikpl
2024-03-07