I’m working on
Mysql 5.6.46. I wanted to maneuver the default datadir location to an encrypted partition and I modified my default /and many others/my.cnf file accordingly:
# For recommendation on find out how to change settings please see # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html [mysqld] # # Take away main # and set to the quantity of RAM for a very powerful information # cache in MySQL. Begin at 70% of whole RAM for devoted server, else 10%. # innodb_buffer_pool_size = 128M # # Take away main # to activate a vital information integrity possibility: logging # adjustments to the binary log between backups. # log_bin # # Take away main # to set choices primarily helpful for reporting servers. # The server defaults are sooner for transactions and quick SELECTs. # Modify sizes as wanted, experiment to seek out the optimum values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M datadir=/NEW_FOLDER/mysql socket=/NEW_FOLDER/mysql/mysql.sock # Disabling symbolic-links is really useful to stop assorted safety dangers symbolic-links=0 # Really helpful in commonplace MySQL setup #sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES sql_mode="" [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid [client] port=3306 socket=/NEW_FOLDER/mysql/mysql.sock
After restarting, I confirm that I can hook up with Mysql by writing:
mysql -u <USERNAME> -p, no concern there.
What my concern is has to do with when my CGI-based server is making an attempt to entry the DB. I get the error:
Error connecting to database: Cannot hook up with native MySQL server by socket '/var/lib/mysql/mysql.sock' (2) which doesn’t make a lot sense to me for the reason that default socket listing has modified.
I regarded into the Apache error log and I see this:
DBI join('testuser:localhost','testdb',...) failed: Cannot hook up with native MySQL server by socket '/var/lib/mysql/mysql.sock' (2) at /srv/www/TestSite/perl-lib/Database.pm line 31.
I’m going to line 31 and I see this:
my $dsn = "DBI:mysql:testdb:localhost"; $dbh = DBI->join($dsn, 'testuser', 'testpasswd') or throw Portal::DatabaseError("Error connecting to database: $DBI::errstr");
The best way I see it, Apache is making an attempt to entry Mysql however it can’t use the
mysql.socket from the brand new default
mysql datadir location. Any concepts what to do?