Mysql in terminal and workbench can't see the same databases - php

I'm using a Macbook Pro. I tried to setup for PHP. The server I'm using is MAMP. After I start MAMP, I can run localhost/phpmyadmin and MySQLWorkbench. But when I try to run mysql through Terminal, I can't connect to my database. I had to disconnect MAMP in order to access my database through Terminal. Then when I restart MAMP, it just connect to Apache Server instead of both Apache and MySQL Server. I figure the port is not 3306 when I run mysql through Terminal. I wonder if I could change the port to 3306 so I can make change to the database I make in the terminal with phpmyadmin. I searched the Internet but couldn't find a solution.
Just now, I couldn't run mysql in terminal. I'm so frustrated. Can somebody help?
Update: I just found out Macbook comes with built-in Apache and Mysql Server. I followed the instruction from below website to set it up and it works. Hope this can help those who has the same problem.
https://coolestguidesontheplanet.com/get-apache-mysql-php-and-phpmyadmin-working-on-macos-sierra/

Maybe... I had the same problem with 2 versions of php (2 differents locations on disk). phpinfo() saw a version, the terminal saw another. The solution: change the $ PATH environment variable.
Hope this helps...

Related

How to safely uninstall a dual mysql installation on ubuntu?

So I installed mysql server through the command line on ubuntu. But a few days later I installed xampp which includes mysql aswell. I had some problems accessing mysql and phpmyadmin. Turns out the problem was that the previous mysql I had installed would start up and occupy the port that the xampp mysql was trying to access. After killing the process and relaunching xampp I had no more problems. The thing is I would like to uninstall the previous mysql server I installed and only work with the one xampp provides, specially to avoid this from happening again after I restart my PC. Is it safe to uninstall and purge it from the command line? Will the uninstall affect in any way the mysql of xampp? And how can I tell between the two?
I do notice that there is a mysql folder at /etc/mysql with its config file my.cnf. And then there is another mysql folder at /opt/lampp/mysql with only a readme.txt and a folder called scripts which contains a ctl.sh file. But under /opt/lampp/etc I can also find a different my.cnf file. Should I assume that an uninstall or purge command from the terminal will leave the mysql I use of xampp intact? Is it safe to follow any uninstall tutorial?
And finally, if someone can explain this to me I would like to know. Why did this problem arise after I turned off my computer and booted it up again? I was working with xampp and able to access phpmyadmin without any problems. So, how come that when I started the computer today, xampp was unable to launch mysql because the previous mysql was an active process? Does mysql launches itself automatically on boot? Any answer will be deeply appreciated, thank you.

How to run Glassfish server with wamp?

I am running a NetBeans project on my Windows machine with Glassfish server with MySQL server 5.6. Now I installed wamp 3.1.3 (64bit), but MySQL service is not starting in wamp. I know it is because MySQL is already running on port 3306. I have tried to change port number for MySQL of wamp in my.ini and php.ini files, but this doesn't work for me.
I have tried so many ways to solve this but didn't succeed. Kindly guide me to solve this issue.
I have found a simple solution of my problem. The sequences of the steps has given below.
Backup your data from C:\MySQL\MySQL Server 5.6\data or export your database by using MySQL Workbench
Remove already installed MySQL Server, using MySQL community installer
Now restart wampmanager.exe
import your data into MySQL database
Cheers. It will work smoothly.

Is Xampp required for laravel?

I am new to PHP and Laravel.
I installed Laravel and Composer , created new project and it is working fine.
Now when i tried to migrate a database using this command php artisan migrate i got errors, i wonder is it something related to not installing Xampp ? i am running Mac OS
The errors i got is
1 PDOException::("SQLSTATE[HY000] [2002] Connection refused")
/app/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:68
2 PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=app", "root", "", [])
/app/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:68
Xampp has nothing to do with Laravel itself. Xampp is a set of tools that is usually used together to deliver websites. Xampp just makes it easier (supposedly) to install those set for you. Rather than having to install and setup all yourself.
Today people tend to avoid such sets in favour for tools like Vagrant or Docker.
Laravel even provides its own Vagrant setup called Homestead.
See ie. in Laravel 5.5 docs: https://laravel.com/docs/5.5/homestead
If you don't want to use Homestead but build your own server environment there's also tools to make this easier for you.
For example there is http://www.puphpet.com for PHP + Vagrant and https://phpdocker.io/ for PHP + Docker.
Xampp is not required but a php server like apache or nginx is required also in order to use mysql you should have mysql installed you get this error
PDOException::("SQLSTATE[HY000] [2002] Connection refused")
/app/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:68
because the mysql service is turned off so I think you open Xampp control Panel and you start mysql in order for it to work and this is why you have asked if Xampp is required am I right !!!
Actually to prove that Xampp has nothing to do with Laravel you can start the mysql server from command line I will give you example in windows OS.
if you have xampp installed on C:/ Driver lets say then try cd(change directory) into this path in your command line
cd c:/xampp/mysql/bin
start mysqld.exe // this will start the mysql service for you
now you can navigate to your Laravel app and try to migrate this time you won't get connection refused error and that is because you have started the Mysql server from command line.
I think this proves that Xampp has nothing to do with Laravel.
Hope this was helpful, good luck.
Mac OS comes with PHP built into it. You should be able to use php -v to see what version. Use php -S localhost:xxxx to output the local directory to a local address.
For example, to run laravel locally, open the terminal cmd+spacebar, type terminal, open it, then use change to the path where your laravel project is.
Type php -S localhost:3000 and it should give you a confirmation in the terminal. Now open a browser and go to localhost:3000 and it should show your project.

DB Connection failed Sylius

I'm running MacOS Sierra and I'm trying to install locally Sylius. Although I (finally) managed to get it installed, I'm still facing connection error with the DB.
Here is the error I'm getting:
Error
Do you have any idea of where might this come from?
Thanks!
Andrea
Ensure that the MySQL server is running. If using MAMP, check MAMP and ensure that MySQL is started. If not using MAMP, try this:
$ mysql.server start
See if you can connect through the console now. If so, you should be able to connect through Sylius.

Can't find MySQL database folders

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

Categories