?
Solved

Mysql move - won't work

Posted on 2014-03-08
8
Medium Priority
?
540 Views
Last Modified: 2014-03-09
I added a second hard drive to my VM.  The OS is Centos 5.x  My msyql database WAS located at /var/lib/mysql and I created a directory called /data/ that points to the new drive.  I moved all the files...created the mysql:mysql ownership...changed the my.cnf to show the new path:
[client]
socket = /data/mysql/mysql.sock

[mysqld]
port = 3306
datadir = /data/mysql



BTW...the mysqld DOES start.  I can log on using the command line.  Just not the webserver.


Restarted server...tested connection to mysql...but I still get this from my web pages...

Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in xxxxxxxxxxxxxxxxxx
I cannot connect to the database because: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

There has to be something still pointing to the /var/lib/mysql folder.  Anyone able to help?
0
Comment
Question by:Gabriel7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 39915453
PHP has it's own MySQL drivers.  On one of my hosting companies, they are using "/var/lib/mysql/mysql.sock ".  On two others they are using "/var/run/mysqld/mysqld.sock".  Run 'phpinfo()' to see where your install is looking.
<?php
phpinfo();
?>

Open in new window

0
 

Author Comment

by:Gabriel7
ID: 39915455
Shows this...
/var/lib/mysql/mysql.sock

Where I'm trying to move from.

How do I?
0
 

Author Comment

by:Gabriel7
ID: 39915462
Oddly enough, when I start the service it creates a file in the /data/mysql folder called msyql.sock.  When I shut down the service, it kills the file.  The file size is 0.

srwxrwxrwx 1 mysql mysql
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 39915479
I looked on my Ubuntu system and I don't see where you can change the location for the PHP MySQL drivers.  I'm sure there's a way but I can see what it is.
0
 

Author Comment

by:Gabriel7
ID: 39915482
Its not the drivers I'm looking to change.  Its the database.  I've already moved the databases...moved it to /data/mysql from /var/lib/mysql

Everything seems good...except...I can't get a page to load without that error...and I can't get phpinfo to show the correct path.  It still shows /var/lib/mysql.

if I do a ps -ef | grep mysql...the results show /data/mysql
0
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 total points
ID: 39915496
Sorry but no, it's the PHP drivers that have that location which is why you are seeing it in 'phpinfo()'.  I believe they have been compiled with that path and nothing you've done so far has had any effect on them.

However, there are lines in 'php.ini' for MYSQL_SOCKET and for MYSQLI_SOCKET .  If you put your new location in those lines (which are normally blank) and restart Apache, you might get what you're looking for.  Make sure you are changing the 'php.ini' that Apache uses for PHP.
0
 

Author Comment

by:Gabriel7
ID: 39915502
Dave...you were so right.  The relief you gave me...I can not tell you.  Thank you for your help and your patience!!!!  My system is working!!!
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 39915510
You're welcome, glad to help.
0

Featured Post

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question