Page 1 of 1

Could not connect to mysql server

Posted: Wed May 13, 2015 5:22 am
by Bif
How to connect this error. Could not connect to MySQL server

Re: Could not connect to mysql server

Posted: Wed May 13, 2015 5:45 am
by skurudo
Your mysql service work?
What - service mysql status - say? (in centos mysqld)
if mysql stopped, try to start again.

Re: Could not connect to mysql server

Posted: Wed May 13, 2015 10:37 am
by prajya
Could not connect to mysql server
Me too, restart server can temporary solve this problem, but when past 1 week i will meet this problem again, can you help me ?

My server is Ubuntu 14.04.1 RAM 512 MB, 1 Core CPU,

Thank you very much

This is my MSQL Logs

150512 20:46:43 [Note] Plugin 'FEDERATED' is disabled.
150512 20:46:43 InnoDB: The InnoDB memory heap is disabled
150512 20:46:43 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150512 20:46:43 InnoDB: Compressed tables use zlib 1.2.8
150512 20:46:43 InnoDB: Using Linux native AIO
150512 20:46:43 InnoDB: Initializing buffer pool, size = 128.0M
150512 20:46:43 InnoDB: Completed initialization of buffer pool
150512 20:46:43 InnoDB: highest supported file format is Barracuda.
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
150512 20:46:43 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
150512 20:46:43 InnoDB: Waiting for the background threads to start
150512 20:46:44 InnoDB: 5.5.43 started; log sequence number 22991236
150512 20:46:44 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
150512 20:46:44 [Note] - '0.0.0.0' resolves to '0.0.0.0';
150512 20:46:44 [Note] Server socket created on IP: '0.0.0.0'.
150512 20:46:44 [Note] Event Scheduler: Loaded 0 events
150512 20:46:44 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.5.43-0ubuntu0.14.04.1' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Ubuntu)
150512 22:15:18 [Note] Plugin 'FEDERATED' is disabled.
150512 22:15:18 InnoDB: The InnoDB memory heap is disabled
150512 22:15:18 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150512 22:15:18 InnoDB: Compressed tables use zlib 1.2.8
150512 22:15:18 InnoDB: Using Linux native AIO
150512 22:15:18 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
150512 22:15:18 InnoDB: Completed initialization of buffer pool
150512 22:15:18 InnoDB: Fatal error: cannot allocate memory for the buffer pool
150512 22:15:18 [ERROR] Plugin 'InnoDB' init function returned error.
150512 22:15:18 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
150512 22:15:18 [ERROR] Unknown/unsupported storage engine: InnoDB
150512 22:15:18 [ERROR] Aborting

150512 22:15:18 [Note] /usr/sbin/mysqld: Shutdown complete

Re: Could not connect to mysql server

Posted: Wed May 13, 2015 11:02 am
by skurudo
What's your server configuration? Memory, cpu?
Show please your mysql config.

Re: Could not connect to mysql server

Posted: Wed May 13, 2015 11:52 am
by prajya
/usr/local/vesta/conf/mysql.conf
HOST='localhost' USER='root' PASSWORD='password' CHARSETS='UTF8,LATIN1,WIN1250,WIN1251,WIN1252,WIN1256,WIN1258,KOI8' MAX_DB='500' U_SYS_USERS='' U_DB_BASES='6' SUSPENDED='no' TIME='05:49:16' DATE='2015-05-02'

/etc/mysql/my.cnf
[client]
port=3306
socket=/var/run/mysqld/mysqld.sock

[mysqld_safe]
socket=/var/run/mysqld/mysqld.sock

[mysqld]
user=mysql
pid-file=/var/run/mysqld/mysqld.pid
socket=/var/run/mysqld/mysqld.sock
port=3306
basedir=/usr
datadir=/var/lib/mysql
tmpdir=/tmp
lc-messages-dir=/usr/share/mysql
log_error=/var/log/mysql/error.log
max_connections=200
max_user_connections=30
wait_timeout=30
interactive_timeout=50
long_query_time=5
innodb_file_per_table

!includedir /etc/mysql/conf.d/


/root/.my.cnf
not see this file

You want another files, information ?

Re: Could not connect to mysql server

Posted: Wed May 13, 2015 12:22 pm
by skurudo
Nope, it's fine. On your server mysql eat too much memory, you don't have so much ;-)
You need tune your config and use smaller settings. Like this config:

Code: Select all

# From mysql 5.5 low memory use 231M
#####
 
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
symbolic-links=0
max_connections=70
max_user_connections=30
wait_timeout=10
interactive_timeout=50
slow_query_log = 0
long_query_time= 5
log-queries-not-using-indexes
slow_query_log_file=/var/log/mysql/log-slow-queries.log
 
key_buffer_size = 8M
myisam_sort_buffer_size = 4M
join_buffer_size = 512K
read_buffer_size = 512K
sort_buffer_size = 1M
table_cache = 2048
thread_cache_size = 128
max_allowed_packet = 16M
query_cache_limit = 2M
query_cache_size = 8M
tmp_table_size = 16M
 
#innodb_use_native_aio = 0
innodb_file_per_table
innodb_buffer_pool_size = 8M
 
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

Re: Could not connect to mysql server

Posted: Fri May 15, 2015 1:40 am
by prajya
I replace this code in my /etc/mysql/my.cnf, i can see more free memory,but i can not connect to mysql server, what something wrong ? i need to do anything more ? my host have 3 websites.

Thank you very much.

Re: Could not connect to mysql server

Posted: Mon Jun 01, 2015 1:04 pm
by skurudo
What error you get? In site error log or mysql log?