Recently I moved my database to another host, and after setting it up, I can't connect to it from my application server using PHP or from anywhere from that matter except from the server itself.
PHP will return the following: Error!: SQLSTATE[HY000] [2002] No such file or directory
I also tested on this website: http://www.rainbowspuppiessunshine.com/tools/dbtest/index.php And the error returned was: Lost connection to MySQL server at 'reading initial communication packet', system error: 111
What I have already tried or checked:
So basically every advice ever given on the internet for these errors did not fix the problem.
Here is the my.cnf file:
[mysql]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld]
user = mysql
default_storage_engine = MyISAM
socket = /var/run/mysqld/mysqld.sock
pid_file = /var/run/mysqld/mysqld.pid
key_buffer_size = 2G
myisam_recover = FORCE,BACKUP
max_allowed_packet = 16M
max_connect_errors = 1000000
datadir = /database/database/mysql
log_bin = /var/lib/mysql/mysql-bin
expire_logs_days = 14
sync_binlog = 1
tmpdir = /database/database/mysqltmp
tmp_table_size = 2G
max_heap_table_size = 2G
query_cache_type = 1
query_cache_size = 64M
max_connections = 1500
thread_cache_size = 50
open_files_limit = 65535
table_definition_cache = 1024
table_open_cache = 5000
max_length_for_sort_data = 4096
innodb_flush_method = O_DIRECT
innodb_log_files_in_group = 2
innodb_log_file_size = 32M
innodb_flush_log_at_trx_commit = 1
innodb_file_per_table = 1
innodb_buffer_pool_size = 8M
log_error = /var/lib/mysql/mysql-error.log
log_queries_not_using_indexes = 1
Thank you in advance
Your PHP is misconfigured, and is looking for the mysql socket file in the wrong place. See mysql.default_socket in your php.ini and make SURE it EXACTLY matches the path specified in your my.cnf file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.