Since migrating to a new Mac a few weeks ago, I have happily set up MAMP and MAMP Pro on my new machine, migrated my local website folders and at some point I must have pointed my databases to the right location to get the majority of my local websites working.
The problem came when I tried to run one of my local web applications and got an internal server error (it couldn't find the database).
I do have a backup of all my database folders from my old Mac (with all the .frm, .myd, .myi) files but I can no longer seem to find the correct location for the new databases.
I am currently using MAMP Pro and in the /appsolute/MAMPPRO folder there are no databases and yet most of my database-dependent sites are running without issue.
I guess my question is, "How can I find where localhost is searching for/ saving databases to so that I can re-add my old database folders?"
If anyone has any clue to this, would be much appreciated.
As far as I know, on OS X MySQL binnaries are installed in usr/local/mysql/bin. So if you want to use the MySQL command-line interface you should type in your terminal:
/usr/local/mysql/bin/mysql -h yourHost -u yourUser -p
(If you are working on localhost substitute yourHost with localhost or 127.0.0.1)
If your MySQL distribution is installed elsewhere, check the documentation and input the appropriate path. Check the documentation for your MAMP stack... or, if you want to do it the hard way, you can look the path "by hand" with this:
ls -lR / | grep -i 'mysql'
(if the list is too long, then press ctrl+c to stop it)
Once you enter the MySQL command-line interface, enter this query to see the path of the data folder:
show variables like 'datadir';
MAMP is using this mysql database:
/Applications/MAMP/db/mysql
MAMP PRO is using this databse:
/Library/Application Support/appsolute/MAMP PRO/db/mysql
not too sure if this helps, but your databases should be in either dir
Related
I just got a new laptop (an M1 Macbook running Mac OS Big Sur) and I'm having a time getting one of my projects set up locally; two large components of this project are a MySQL database and a PHP webapp, and on my machine I've got both running through non-VM XAMPP (version 8.0.8) - though technically, XAMPP only has MariaDB, not MySQL (but I've never noticed an issue).
One part of the webapp generates a dynamic .csv using MySQL's INTO OUTFILE... functionality. However, once MySQL outputs the file, the PHP script needs to read it and manipulate it before downloading it to the browser, so the user running the PHP script needs write access.
The script is located at /Applications/XAMPP/project/webapp/download.php, and everything was set to all-access with sudo chmod -R 777 project/ (I know, bad practice, but this is just for development).
exec('whoami') tells me that the script is running under the daemon user from XAMPP's Apache server. The script is owned by myusername with a group of admin containing root and myusername.
When generated, the files from MySQL are owned by user _mysql with group admin, with permissions -rw-r--r--, i.e. 644. So, when this script runs, it generates the file but I get the following PHP warning upon a call to file_put_contents() after reading / working with file data:
Warning: file_put_contents(/Applications/XAMPP/xamppfiles/htdocs/project/webapp/XXXXXXXXXX.csv):
Failed to open stream:
Permission denied in /Applications/XAMPP/xamppfiles/htdocs/project/webapp/download.php on line 26
I'm at a loss on how to get anyone but the mysql user writing to this file. The kicker is that my old machine - a 2013 Macbook Pro running Mojave - doesn't have any noticeably different configuration, and it works (it does use XAMPP 7.4.6 instead, but other than using PHP 7 instead of 8 the differences seem marginal). I've noticed there, the MySQL-generated files have -rw-rw-rw- permissions, so the admin group (or I guess everyone, as I don't believe daemon belongs to the admin group on there) can write to it - I just can't get my new computer to do it.
Aside from general fiddling of permissions (I'm no wizard with this kind of stuff), messing with groups, etc., all I've really tried is setting the UMASK MySQL environment variable in mysql.server and mysqld_safe; didn't seem to have any effect, and config changes like that make me leery given that my old computer needed none of it. And for the record, though not sure it's relevant - the secure_file_priv variable in MySQL is set to blank and root / localhost combination have file privileges; generating the file itself is not a problem.
How can I get things going without changing a line of code? It's clear the issue lies somewhere in my configuration. Not sure if it's worth mentioning, but I do have another installation of MySQL from homebrew...could there be some conflict there? That being said, my old computer also had another MySQL instance as well, but installed off the MySQL website.
I'm trying to create a dynamic drop down list by requesting data from my database using MAMP.
One of the tutorials I have tried has been talked about already and my version of the code is the same. Dynamic dropdown list with PHP & MYSQL
Although I am under the impression MAMP has a SQL server, I thought the problem was because I didn't have MySQL installed on my computer so I downloaded it, to no avail.
I went into my Task Manager and tried looking for "MySQL service" although I couldn't find the exact tag I did see MySQL Writer is running, but the Browser and Agent INFLOW is not and refuse to start.
I went here into my computer ( c://windows/system32/drivers/etc.host ) and took off the #s that were before
127.0.0.1 localhost
::1 localhost
making sure each remained on a separate line, I restarted my computer but I still can't seem to connect.
Any suggestions on how I may be able to fix this? I am extremely new to PHP and even newer to MySQL so, if possible, please try to keep any solutions simplified so I can follow along.
Not sure what the issue actually was but I ditched MAMP and installed XAMPP and everything seems to be working now.
Total beginner to the world of MySQL and PHP (using MAMP).
Very simple question which I can not seem to find the answer to anywhere.
I have created a MySQL database (called user_info) in terminal under the 'root' user on 'localhost' with all permissions/privileges granted, when I access PhpMyAdmin as root user on localhost (which is what it says under the database server pane) I can't see the database I created in terminal in the left hand pane or under the databases tab of PhpMyAdmin ?
The question is really whether the databases created in terminal should reflect in the databases section in PhpMyAdmin or is this a total mis-understanding of the way it all works on my part ?
Any advice or explanation would be greatly appreciated !
Kind regards
It looks like you have two MySQL installations on your Mac. MAMP comes with MySQL and it looks like you also installed another MySQL outside of MAMP. This explains the two different data directories -- the MAMP MySQL is using /Applications/MAMP/db/mysql/ and the other installation is using 'usr/local/mysql/data/`.
Pick one to keep and remove the other one. You can force your client to connect to whichever one you want, by specifying the port or socket each one is using to listen for connections, but unless you have a specific reason for wanting to run two MySQL instances, it's going to be less confusing to remove one. Just make sure you don't have any stored data that you wish to save (or export/dump it to SQL first).
I came across the same issue when playing with MAMP.
And I finally find out that I have two MySQL installations on my Mac, just like Issac said.
One is installed individually, under /usr/local/mysql, and the other is installed together with MAMP, under /Applications/MAMP/Library/bin
So to see what is seen in phpmyadmin, I need to connect with the MAMP one.
hope this helps.
I really feel like I have done an exhaustive search on this matter, found similar issues and have tried a number of things without success, so I am for the first time posting a question here:
I do a lot of web pages/web programming (PHP/jQuery mostly) and host these pages on my digital library department's Drupal/Ubuntu Server. I just code them and post them via Dreamweaver, as I don't have much use for the Drupal front end. I just need the server for my pages.
Anyway, I am wanting to make some PHP pages that can connect to our library catalog, so I have been working from the command line of the Drupal/Ubuntu server. I installed unixODBC, had some troubles, installed FreeTDS, set up the drivers and the DSN.
Finally...
I was able to get a connection to our catalog via tsql and run a query.
I made a basic PHP script to test the connection:
It works from the Ubuntu command line of the server (connection successful).
It doesn't work when I load it in a browser. I get the dreaded:
Warning: odbc_pconnect(): SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in /var/www/mydirectory/mytestpage.php on line 15
UPDATE: I installed a test Ubuntu Server in a partition on my laptop, where I started clean, installed Apache2/PHP5(with mssql and odbc modules, etc)/FreeTDS, etc. I got a tsql connection. I made the basic PHP script and ran it successfully from the command line. Then I navigated to the php page from a browser and it worked! I still need to get this to happen on the Drupal server version, but now I have at least narrowed down the issue to something on the Drupal server.
I searched and found such possible causes as:
File permissions, which I think I got corrected, but no go
That maybe I had set up a User DNS and not a System DNS which I tried my best to correct with the proper "odbcinst" command options
That maybe php needs to be running in CGI mode instead of as a module. But that seemed unlikely from what I read. And I am not sure how that would affect Drupal. (There are limits to the system wide changes I should make here.)
A number of people said it was SElinux blocking Apache from displaying the page in the browser, but temporarily disabling SElinux didn't work.
Thanks for any assistance!
Check you have enabled the mssql.so etc at the following location
/etc/php5/apache2/php.ini, you will be having another at /etc/php5/cli/php.ini
in ubuntu php.ini will be maintained separately for cli & mod_php apache configuration
If you are going to test your odbc sources on the commandline, I would advise you use the isql utility instead of tsql. isql uses the DSN you defined in odbc.ini to connect to the database, while tsql connects directly to your database.
If it works with isql, it should work on your webpage as well.
Also check the Drupal/Ubuntu Server files /etc/odbc.ini (your DSN sources) and /etc/odbcinst.ini (TDS Driver settings) to see if they match the ones on the working Ubuntu installation.
My guess is it has something to do with the php. ini file. On my Ubuntu system I've got 2.
One in /etc/php5/apache2/php.ini
And one in /etc/php5/cgi/php.ini
The values in the apache2 path will need to be adjusted to allow the connection. Unfortunately outside of that I'm not too much use as I use MySQL and Mongo
Copy your php.ini from work server to non-work server, add make needed environment variables accessible before starting your web server, and make sure your web-server has full access to your odbc and odbcinst ini-files. And so, using mssql knowledge base or help.
I am developing a site in vertigoserver. Now I need to test the webpage in webserver.
I am using the webserver Host-Europe VirtualServer 3.0.
Now what are the steps I need to upload the PHP pages?
What is the software needed to upload MySQL queries?
Are there any tutorials or suggestions?
This seems like basic stuff, but I'll give you some pointers!
Upload the pages with an FTP client or similar. If you have shell access, tools like rsync can make this easier.
You've probably got some sort of web based front end for MySQL like phpMyAdmin - this will let you upload and restore a database dump. If you have shell access, or if the MySQL server is open to the Internet, you can pipe the dump into the MySQL command line client, for example,
mysql -h<hostname> -u<username> -p<password> mydatabase < dump.mysql
Okay, you got a virtual machine and don't know how to upload stuff? This has been discussed in Host-Europe forums for a while. If you don't know the basics you probably don't want to run a server on your own. If you don't know how to use Linux don't start with a machine which can get you in a lot of trouble. A hosting package is probably better you at the moment.
The problem I have is you didn't specify what OS you have. If you're using Linux with Plesk you want to activate FTP, etc. If you are using Linux without Plesk you want to upload the PHP files with WinSCP and over SSH (SCP).
If you are running Windows with Plesk use FTP. If not, you should install an FTP server on the machine.
Regarding the MySQL stuff you're probably best off installing a webfrontend for MySQL.
!DON'T FORGET TO SECURE IT!