LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Change default location for MySQL (https://www.linuxquestions.org/questions/linux-software-2/change-default-location-for-mysql-4175620243/)

sbrown1038 12-24-2017 12:32 PM

Change default location for MySQL
 
I had 3 installations of MySQL on my Linux server (my laptop):

1. Downloaded from MySQL.org.
2. Installed and later removed with apt-get.
3. Installed with Ampps LAMP stack bundle.

My goal is to set up a Drupal 8 site. Since I was getting errors, I thought it best to remove the MySQL that was already there, so I did so with apt-get remove. Apparently, doing this left the downloaded install in an unusable state. Any app (Drupal and PHPMyAdmin, for example) that tries to use it gets an error:

Failed to connect to your database server. The server reports the following message: SQLSTATE[HY000] [2002] No such file or directory.


Trying to start the MySQL client from a command line, I get this:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)


If I include the full path to the Ampps copy of MySQL, the client works fine.

So my question is, how do I make the Ampps copy of MySQL the default so that applications that look for MySQL find that one instead of the other one?

Any help would be truly appreciated.

Steve

scasey 12-24-2017 02:32 PM

Either add the full path of the Ampps copy of MySQL to your PATH (in your ~/.bash_profile or ~/.bashrc, if using bash shells -- post shell you're using if not bash)
or
link to the Ampps copy pf MySQL in the directory your system expects to find it. Mine is in /bin
the link is probably the more universal solution if other users need access to mysql.

sbrown1038 12-25-2017 03:04 PM

SOLVED
 
As suggested, I added the full path of the Ampps installation to my .bashrc file. I also renamed mysql in the /usr/bin directory and created a link there to /usr/local/ampps/mysql/bin/mysql. At that point, I could get into the mysql client from any directory without including the ampps path. However, I still got the error message from the Drupal install. Since the error message mentioned /var/run/mysqld.sock, which didn't exist, I created a link for that to /usr/local/ampps/var/mysql.sock (no 'd'). The error message went away. I expect I'll run into other problems, but for now it seems I'll be able to get started with the Drupal site.

=== 12/28/2017 ADDITIONAL INFO ===

Whenever I rebooted, the link from /var/run/mysqld.sock to /usr/local/ampps/var/mysql.sock would disappear (as it's supposed to). To fix this, I added 2 lines near the top of /etc/init.d/mysqld (actually a link to the ampps startup file, /usr/local/ampps/mysql/bin/mysqlctl):

mkdir /var/run/mysqld
ln -s /usr/local/ampps/var/mysql.sock /var/run/mysqld/mysqld.sock

And with that, my "Frankenstein" LAMP stack seems to be working well. I've got my Drupal 8 site up and I can work with PHPMyAdmin.

==================================

Thanks for your help, Sean and Merry Christmas / Happy Holidays!

Steve


All times are GMT -5. The time now is 02:35 PM.