I am trying to get my web server to connect to my remote database (Mysql).
The connection is happening in my web application which is built on yii2.
I have created all user details, GRANTED all privileges and allowed connections from ALL hosts (%) (Progressively in troubleshooting this).
Now I can connect from home using HeidiSQL or using Mysql Workbench without issue.
I have even created a blank yii2 site at home and it works instantly, but uploading the site to the web server instantly gives the same issue.
Database Exception – yii\db\Exception
SQLSTATE[HY000] [2003] Can't connect to MySQL server on '46.105.111.111' (110)
↵
Caused by: PDOException
SQLSTATE[HY000] [2003] Can't connect to MySQL server on '46.105.111.111' (110)
in /home/xxxxxxx/xtest.xxxxxxxx.tv/vendor/yiisoft/yii2/db/Connection.php at line 602
I have run netstat on the db server:
I have been through the etc/mysql/my.cnf
<pre>[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 7999
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
#bind-address = *
key_buffer = 16M
max_allowed_packet = 64M
thread_stack = 192K
thread_cache_size = 8
myisam-recover = BACKUP
query_cache_limit = 1M
query_cache_size = 16M
expire_logs_days = 10
max_binlog_size = 100M
max_connections = 65535
open-files-limit = 65535
max_connect_errors = 65535
innodb_buffer_pool_size = 1G
table_open_cache = 1000
innodb_flush_log_at_trx_commit = 0
innodb_flush_method = O_DIRECT
tmp_table_size = 256M
max_heap_table_size = 256M
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[mysql]
[isamchk]
key_buffer = 16M</pre>
I have looked at the iptables:
I am totally bedazzled as having read about 20 pieces of information about mysql security, i get the feeling its a permissions issue.
I have even tried using my own PDO Wrapper, so i a, 99% sure its not a Yii2 issue, would really appreciate any help.
Hopefully I have provided enough info as I got a downvote previously.
many thanks for the help.
It turns out that the web host was actually blocking the outgoing port for the connection.
The output error from yii being database error, nievly led me to think the issue was at the database end.
Simple logic when you read back the question.
I would say to anyone that finds this question, remember with a connection issue that communication is two way, check both ends of the connection.
Related
I've just learnt the basics of MySQL to allow me to upload tables onto my Wordpress site through wpdatatables. However, I can't for the life of me work out how to get a remote access connection working. There is plenty of literature and forum posts out there to help with this and I've tried a number of way but I haven't had any success.
I've created privileges for a user called morts81 using the code below:
GRANT ALL PRIVILEGES ON *.* TO 'morts81'#'%' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Then I've opened up the my.cnf file to ensure that the bind.address line is removed, however, I don't have a bind.address line so I imagine that isn't an issue.
# The MySQL server
[mysqld]
user = mysql
port=3306
socket = /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
skip-external-locking
key_buffer = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
Then finally I try and check the connection from inside the wpdatatable plug-in for Wordpress and I get the following error:
I've also tried replacing localhost in the wpdatatables input with 127.0.0.1 which seems to be recommended on some forums but I get a separate error then:
Would appreciate any help on what I'm doing wrong here.
The socket you specified is different in your config file to start the mysql server. If you can connect to the socket as shown in first error message, use the below socket configuration
socket = /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
For the 2nd error, see if your mysql server is accessible from the server/service datatables is running on.
I am trying to import a old Vbulletin database but always getting this error
ERROR 1114 (HY000) at line 4734: The table 'session' is full
this database backup size is 2GB and my server have 8GB ram. I tried to add innodb_data_file_path=ibdata1:10M:autoextend and innodb_file_per_table to my.cnf but not solved my problem.
my complete my.cnf
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[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
skip-external-locking
bind-address = 127.0.0.1
key_buffer = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
myisam-recover = BACKUP
#max_connections = 100
#table_cache = 64
#thread_concurrency = 10
query_cache_limit = 1M
query_cache_size = 16M
expire_logs_days = 10
max_binlog_size = 100M
innodb_data_file_path=ibdata1:10M:autoextend
innodb_file_per_table
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[mysql]
[isamchk]
key_buffer = 16M
!includedir /etc/mysql/conf.d/
I am very familiar with Vbulletin database schema and tables. I have converted dozens of VB sites to Innodb storage engine.
The reason that you are getting that error is because the session table is a Memory table. The session table(s) must have been quite full when you took this backup that you are trying to restore. That, coupled with your overhead IO during the import, is filling up your RAM. However, for VB to work properly, you do not actually need this table to be a Memory table.
In order to get around this you can convert your session table to InnoDB.
I would open the .sql file up in a text editor (if possible) and change where it says ENGINE = MEMORY for your session table to InnoDB, or use string replace:
sed -i 's/MEMORY/INNODB/g' yourfilename.sql
I have never really played around with mysql settings before, but on our new linux cloud server it appears that mysql is eating up all the memory till it crashes, then it cannot restart as there is no more memory to restart the service, I have to reboot the cloud server.
So I was looking at how I could tame the memory usage, and after reading about key_buffer_size (and another setting I cannot recall of the my head) I had a look at the my.cnf file, and there is nothing with this setting on it. My my.cnf is as follows...
[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/mysql.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
datadir = /var/lib/mysql
[mysql]
!includedir /etc/mysql/conf.d
Without the key_buffer_size set... will it just keep eating up memory till it runs out? Shouldn't this setting be set?
Cheers
The default for key_buffer_size is 8M per http://dev.mysql.com/doc/refman/5.0/en/server-parameters.html
However, I would ask that you set these first (and restart MySQL) and see if the problem persists.
key_buffer = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
query_cache_limit = 1M
query_cache_size = 16M
If after those settings are used, the problem persists, then it's likely not a configuration issue, but something deeper.
Additionally, see these:
https://dba.stackexchange.com/questions/31182/mysql-slowly-uses-memory-until-it-starts-to-use-swap
https://dba.stackexchange.com/questions/7400/why-does-mysql-use-all-of-memory-and-goes-into-swap-when-doing-lots-of-delayed-i
Thanks kinds for the advice!
Turns out it was the innodb_buffer_pool_size. It was set to high for my machine. I have adjusted it as well as optimized how much memory Apache uses. Everything seems to be running better and there is a bit of memory headroom. Hope that fixes it.
I would like to access to my MySQL DB through local network which is installed by Wamp(2.2e) server.
I managed to access phpMyAdmin from other local computer so I can view the content of the DB, but I would like to use the data from it by other application.
I turned off my firewall just for testing on my "server" and my "client" machine as well.
I cannot telnet to the DB (telnet "local network IP of my server" 3306) from my client machine.
on my server netstat -an shows the MySQL DB:
Proto | Local Address | Foreign Address | State
TCP | 0.0.0.0:3306 | 0.0.0.0:0 | Listening
I have add users("client" local network ip, "server" local network ip) to the database with all of the permissions.
On the "server" machine I can telnet to its own MySQL DB by using its local network IP after I add it to the DB users table as well.
Here is my my.ini file without the comment lines:
[client]
port = 3306
socket = /tmp/mysql.sock
[wampmysqld]
port = 3306
socket = /tmp/mysql.sock
key_buffer = 16M
max_allowed_packet = 1M
table_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
basedir=c:/wamp/bin/mysql/mysql5.5.24
log-error=c:/wamp/logs/mysql.log
datadir=c:/wamp/bin/mysql/mysql5.5.24/data
skip-federated
log-bin=mysql-bin
binlog_format=mixed
server-id = 1
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[isamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[myisamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
[mysqld]
port=3306
I have tried a few things already which did not work:
skip-name-resolve at mysqld
bind-address=0.0.0.0 (it is the same as the default) at mysqld
bind-address="local network IP" at mysqld did not do any difference
I was rewriting other files as well, but I guess I need to do changes here(my.ini) to access to the database on local network.
I my wamp server is in offline mode just now, as I can access to phpMyAdmin I thought I should be able to access to the database with left it offline. I tried it in online mode as well, did not do any difference.
I spent quite a bit of a time solving the problem but unfortunately I have no more ideas. Every suggestions, ideas will be appreciated.
So I kind of Figured it out.
I am using Kaspersky endpoint security on my development machine. For some reason it is running weird on it (the restrictions managed my a central server, computers on the same group as me acting normal; responding for the rules as they should). It was not enough to disable my firewall I needed to disable whole kaspersky then I was able to telnet to the MySQL port from an other machine.
So if firewall rules added to "normal" machines (not my weird one), client and server as well; Wamps MySQL DB was accessible in local network without any other changes.
I know it is rather a special case but I hope it still could help for some one.
I don't know if this problem is specific to my set up but when I add the line
log = /var/log/mysql.log
to the mysqld section of a copied my-large.cnf file and try to restart the mysql server I get the error
Starting MySQL. ERROR! The server quit without updating PID file (/var/lib/mysql/centos-server.pid).
I've created the file /var/log/mysql.log, set its owner and group to mysql and set the permissions on /var/log to 777 (for the moment)
I'm on centos, with mysql 5.6.5 m8 (the development release).
This is a snippet of the my.cnf file
[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
skip-external-locking
key_buffer_size = 256M
max_allowed_packet = 1M
table_open_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8
log = /var/log/mysql.log
Seems like the log directive is outdated and my.cnf requires the directive
general-log = 1
If specified like this the log file will be created in a default location (which on centos is /var/lib/mysql/centos-server.log)