Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Red Hat, Fedora Core, Linux Mint, CentOS
Posts: 12
Rep:
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?
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.
Distribution: Red Hat, Fedora Core, Linux Mint, CentOS
Posts: 12
Original Poster
Rep:
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):
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.