A while back I installed xampp and could not get it to run because the ports were already being used. Someone recommended that I type .. I believe it was: kill all, into the terminal to, I guess, kill the conflicting connections. This worked and I was able to access phpMyAdmin, but then I started having the problem again so i switched to MAMP. Now I can not access MySQL through the terminal. This is what I type in and this is what I get:
Macintosh:~ scottmcpherson$ mysql -u root --password=This_is_where_I_typed_my_pw
-bash: mysql: command not found
Macintosh:~ scottmcpherson$
I can, however access my database through phpMyAdmin. But the tutorials I'm following only show you how to create a database through the terminal plus I would really like to learn how to do it both ways. So, I'm thinking that the killall command screwed something up, or the other command that someone recommended a while back- which I can't remember.
You need to adjust your PATH environment variable. Details are here: http://www.metaltoad.com/blog/getting-command-line-access-php-and-mysql-running-mamp-osx
In short, open (or create) a .profile file in your home directory, and add this line:
export PATH=/Applications/MAMP/Library/bin/:/Applications/MAMP/bin/php5/bin/:/opt/local/bin:/opt/local/sbin:$PATH
Paths may need to be adjusted depending on the location of your MAMP install.
Related
I am having a lot of problems with mysql on macos 10.14. It started with trying to reset my password. Back when I collaborated with someone in 2018 my collaborator used mysql but I did not know how to work it. I have a feeling that the password I used for mysql is not the typical password I used because my attempts to log in failed. watching this video I was told at 9:12 that the password would be set on installation but that turned out to be false. I was never asked for a password upon downloading but perhaps that is because I had part of mysql already downloaded on my computer but I did not have the workbench installed. All of my attempts to reset the password failed. So I then tried deleting mysql and redownloading. Now I am not able not to start the mysql server from mac's system preferences. But that's not my largest problem. I still cannot reset the password and hence even use the app. Following official mysql instructions I cannot reset the password because it requires the location of a pid file. It says
Stop the MySQL server if it is running. Locate the .pid file that contains the server's process ID. The exact location and name of this file depend on your distribution, host name, and configuration. Common locations are /var/lib/mysql/, /var/run/mysqld/, and /usr/local/mysql/data/.
In the folder for mysql located in /usr/local/var/mysql there is no pid file. A lot of the tutorials I've seen recommend using terminal but I cannot use terminal for mysql because I get the mysql command not found error. Ok, so to fix that problem trying this tutorial here it says:
If you’re installing MySQL using the official installer, then your MySQL bin/ folder should be located on /usr/local/bin/mysql
So now I need to find the mysql bin file but when I write ls in the /usr/local/bin folder, mysql does not come up. All of the file beginning near 'my' are
multinit
murge
nasm
So I'm stuck. I find it simply incredible that such a simple thing as resetting a password is so difficult.
Let’s say we installed MySQL version is 8.0 on our Windows OS. The bin directory is present at the following location −
C:\Program Files\MySQL\MySQL Server 8.0\bin
So I am going crazy with this. I have MAMP installed and it's MySQL is working fine. I now installed MySQL 5.7.19 from the official dmg from their site and installed.
From the pref panel I am not getting status updates and as such I cannot stop it even though it is running. Trivial though as I can launctl unload it.
However, the big issue I am facing is that although the server starts correctly (from pref panel) and I can see the process running and the respective /tmp/mysql.sock file when I try to run mysql in terminal (or any other mysql command) I get an error stating it cant find the sock file and it pipes out the Applications/MAMP path.
I looked everywhere for a my.cnf that might be setting this and there are none (apart from the one used by MAMP). No environment variables set to override it, nothing. In fact, there are no other my.cnf files but for some reason it still thinks it should be using /Applications/MAMP path.
my_print_defaults client confirms this as it pipes out
--socket=/Applications/MAMP/tmp/mysql/mysql.sock
but I have absolutely no idea where and how this is being set and I need to be able to run on this instance terminal commands. Driving me crazy for hours now.
No files at
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
No environment variable MYSQL_UNIX_PORT as described here: https://dev.mysql.com/doc/refman/5.7/en/problems-with-mysql-sock.html
So how the heck is it getting this value?
Also checked at DATA_DIR and BASE_DIR, no my.cnf there either.
Obviously Ive done which mysql to confirm I am calling the correct binary.
Any help much appreciated!
UPDATE Running my_print_defaults client --verbose --no-defaults pipes the same exact output, so I am guessing it is somehow set elsewhere. Where can this variable be set otherwise?
Ok so I found the answer after all and sharing it for anyone having the same issue.
In essence, the --socket parameter is added via the ~/.mylogin.cnf file!
I am not sure if I ever added it there but I am pretty sure it wasn't me, so I am guessing MAMP did it.
This is an encrypted file so you can't edit it directly by you can change it via mysql_config_editor:
mysql_config_editor remove --socket
And problem solved!
This is NOT about MySQL's "data directory".
When I log into MySQL on my machine (Windows 10 OS) I know that MySQL still has a "current working directory": importing a .sql file works, giving only the filename, if the file is located in the same directory as the one where I went
> mysql -u ....
So I wondered whether it was possible to get the CWD when actually logged into MySQL. Then I wondered whether it might be possible to change it, i.e. to navigate somewhere else. Then I wondered about running system (i.e. command prompt) commands generally, while still logged in to MySQL.
Here we see a claim that you can indeed do all these things... by going something like:
\! ls -l
On my machine this doesn't work... probably because it's not a Linux OS. I get unknown command '\!'...
Is there any way to do this in Windows?
You're right. The Windows version of the mysql command line client lacks the shell escape \! command.
It is an open source project :-). You or I could give them a pull request with a fix. But then we'd have to decide whether we wanted cmd or powershell in the escaped process.
I'm kind of stuck on what to do with this. There were several options I found between this site and the mysql site on how to resolve a forgotten root password, but I think I've now broken it.
I was unable to use the line command with the created reset text file that mysql.com recommended here
So I uninstalled WAMP which is what I had used to install it to begin with. That also failed because after reinstall I had a new version and I couldnt log into either of them. Apparently both versions were still there as uninstalling WAMP didnt uninstall MySQL.
So I tried the make-sure-everything-is-deleted steps here and rebooted and reinstalled WAMP. No go, won't take default password.
Tried to run the command line command using the newest version and got this error.
Now I can't do anything I need to get done and all other posts I find on this seem to be variants of these things I've already tried.
This time around, the newer version of mysql let me log in with no password. I was able to get it fixed from the command line and get it reset to what I wanted. Tried that multiple times before, so I cannot say I understand what changed now, but it did.
Try to reset you password as described here
stop the mysql service (likely requires user to be admin/root)
write ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass'; into new file and save it under C:\mysql-init.txt (for windows)
Open cmd.exe (with admin privilges) and enter commands (see below)
Commands
C:\> cd "C:\Program Files\MySQL\MySQL Server 8.0\bin"
C:\> mysqld --init-file=C:\\mysql-init.txt
It worked for me.
I've been having a lot of issues lately, basically since the last time I upgraded XAMPP for OSX (v1.7.3) and/or my MySQL GUI tools. Using MySQL Workbench (v5.2.44), I can connect to the DB running in XAMPP just fine, but trying to browse any database, under tables/views/etc it only shows "Fetching..." and never shows anything else. I can actually query tables, which is interesting, but I can't actually manage the databases in any meaningful way.
Googling, others reported having luck running mysql_upgrade on the command line, which ran fine but did not fix my issue.
The following command worked for me on windows:
C:\Program Files\MySQL\MySQL Server 5.5\bin>mysql_upgrade.exe -u root -p --force
If the root password is not set, you might need to do this before you run the command above:
mysql> SET PASSWORD FOR 'root'#'localhost' = PASSWORD('something');
The link above to mysql_upgrade did not solve my problem directly, but it did lead me to examine my mysql error file, which ultimately led me to the solution. I noticed several lines like this in the error file (located at [xampp root]/var/mysql/[dbname].err):
/Applications/XAMPP/xamppfiles/sbin/mysqld: Can't create/write to file
'/var/folders/y2/37h93r_931sdfpcr7vnc83380000gn/T/ibigNFFi' (Errcode: 13)
That led me to this page in the MySQL docs which states that you should explicitly set the temp folder for MySQL. I double-checked my config file ([xampp root]/etc/my.cnf) and saw this, which looked fine:
[mysqld]
tmpdir = /Applications/XAMPP/xamppfiles/temp/
However, looking back at the error log, I also noticed this:
Warning: World-writable config file '/Applications/XAMPP/xamppfiles/etc/my.cnf' is ignored
Duh. The config file was getting ignored, so the configured temp folder was not getting used (I have no clue why the file was world-writeable...). I edited permissions on the my.cnf file which was 777 and simply removed the "Everyone|write" permission (now 775 / -rwxrwxr-x), reloaded everything, and now everything works.
Not a very intuitive symptom for the ultimate fix, so hopefully this helps someone else.
If you have MAMP instead of XAMP the solution above won't work for you.
Open MAMP then on the top menu go to Tools->Upgrade MySQL databases.
Now open Mysql Workbench and it should list all your tables correctly
If you are using linux distro the run following command:
mysql_upgrade -u root -p
I set Authenticated Users with all privileges to the var/folders/y2/
For me work fine ;)
Before the process I removed authenticated users privileges.
Close and reopen Workbench. it worked for me.
Stop server.
close workbench window
start server
open workbench window
worked for me .. windows 64bit
I had that error with MySQL 8, win10. I've noticed that this line Where the error was
Was leading to another directory trying to find the my.ini file. Looked for it, found it in that directory, changed it. Opened Workbench, clik on every item that was in gray, and turned it into black and that's it!! Ok now!!