OSX MySql terminal parameters - mysql

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!

Related

Raspberry Pi MySQL Remote Connection (error: 10061)

I'm trying to connect to a MySQL server running on my Raspberry Pi 3 remotely (though on the same LAN).
Attempting to do so through HeidiSQL returns an error coded 10061. A bit of research suggests I have to edit the config to allow remote connections.
The config, however, does not contain a bind-adress x.x.x.x line (/etc/mysql/my.cnf) for my to comment out. Added it myself breaks the service, causing errors when trying to restart it.
Checking other possible config file locations resulted in only empty files.
Additionally, comparing to the "default" config file, mine is a lot shorter, and has no actual statements, other than a few includes for other config files (it seems). These included files are all empty as well.
I'm now lost, and cannot figure out how to allow remote connections to my server. Any help is much appreciated :)
Thanks to #PetervanderWal, I suspected that the lack of a bind-address statement in the config was no freak coincidence. Therefore, I did a grep search for any files containing "bind-address", and found the correct configuration file: /etc/mysql/mariadb.conf.d/50-server.cnf. This file had the ´bind-address´ statement, which - after commenting it out - fixed the problem.
The takeaway here (if you ask me) is, if none of your config files contain the bind-address statement, widen your search for the correct config file.
Thanks Peter, hope this helps others.

setting up MySQL Workbench with MAMP - missing 'mysql.sock' file

I am having trouble connecting MySQL Workbench to MAMP. I am using version MySQL Workbench version 6.0 and MAMP version 3.0.3.
I have followed the instructions on this link: http://www.rubberneckdesigns.com/mamp/how-to-set-up-mysql-workbench-for-a-mamp-server/comment-page-1/#comment-6539 (this is just basic instructions to setting up MySQL Workbench with MAMP so no need to look through if you are familiar with the set up steps)
It all goes okay until the step were I have to select the Configuration File as:
/Applications/MAMP/tmp/mysql/mysql.sock
This file does not appear to be in this location or anywhere else on my computer.
In the answer to this link: Database connection "Mysql" is missing and mysql.sock is missing, he says he managed to figure out that his mysql.sock file was actually hidden, however I have my Mac set to display hidden files and I can see all my other hidden files, but still no sign of this file. He said after finding it was hidden he went to his database configuration file and added the following:
'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock'
Does anyone know what file he is referring to when he says database configuration file? I have tried figuring it out using Google but no luck. I am new to MAMP and new to MySQL Workbench.
This problem with the mysql.sock file, seems to be a problem for a lot of people. If anyone has a better solution than adding the above command to the database configuration file or can shed some light on this problem I would love to hear it.
Thanks
I have not been able to figure out where the mysql.sock file is, Mike Lischke has left a comment saying the socket file is created dynamically when you open a connection, which could be the case, but I do not know much about MySQL and the files so I can not confirm if this is correct, however, I have found the solution to my problem.
The overall problem was that I could not connect MySQLWorkbench to my Local Server (MAMP) as I could not find the mysql.sock file. When I tried to connect I was getting an error message saying it could not find the mysql.sock file.
The solution to my problem was to instead of setting the 'Hostname' in the MySQLWorkbench set up window as 'localhost', which is suggested in the guide I followed, I instead set it to the IP '127.0.0.1'. I then set the 'Connection Method' to 'Standard (TCP/IP)' instead of 'Local Socket/Pipe'. I believe what this is doing is setting it up to connect through the IP rather than the Socket, meaning the mysql.sock file is no long necessary.
This is a very simple solution and in hindsight it makes sense and I probably should have known this from the start, however because I am new to MySQL I didn't. If anyone else is having a similar problem connecting, I hope this helps.

Forgotten MySQL root password

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.

MySQL Workbench "fetching..." -- cannot browse DB

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!!

Accessing mysql via terminal

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.