Can't connect to localhost MySQL database through command line? - mysql

Weird issue. Can't connect to localhost MySQL database from command line, but I can through MySQL program, Sequel Pro. Any ideas why? I entered the same user/password, but I'm getting a access denied error for root#localhost
Extra question: can you run MySQL commands within Sequel Pro? I'm pretty new to MySQL, but I'm just trying to change a simple column definition.
EDIT: reset password from within Sequel Pro query for root, and was able to get it working.

MySQL has different accesses. You can allow a MySQL database to only serve requests from a specific machine, or only from the local machine.
However, note that MySQL differentiates login from "localhost" and from "127.0.0.1".
Try allowing both localhost, 127.0.0.1 and "%" to the account.

Related

Cannot preform mysql query from ubuntu terminal

What I'm trying to do:
I have a Minecraft server, I'm trying to my an admin panel so the other admins can help out the server more closely.
Right now, I am trying to make a live console. My thought was is that if I have a script fire off every 10 seconds the script would perform a MySQL query and upload the log file contents to the Database and then on the webpage is would display the rows.
What I have tried:
So I looked on StackOverflow and you can query MySQL databases from the Ubuntu terminal and I have tried that.
mysql -u username#Database -pPassword -h azure.database.for.mysql.url -P 3306 -D SchemaName
It does not work as I get an error
ERROR 1045 (28000): Access denied for user 'username'#'machineIp' (using password: YES)
There were people saying to edit the configs and comment out "bind-address" however it seems to only apply to the machine the MySQL server is on, and not the one performing the queries.
Things to note:
The Web Server, Minecraft Servers, and MySQL Server are all on different machines.
The MySQL server is a SaaS provided by Azure.
I use this database for my web server and it works fine in connecting to the server so I believe it is not a MySQL server issue.
I also use this database for my Minecraft permissions plugin and it connects fine.
If you have more questions please ask and I will do my best at answering them.
It looks like its not accepting your password.
This is the format that I use to access mysql from terminal.
mysql --prompt="(\u#\h) [\d]> " --user=your_username --password your_password

Can't connect to MySQL with DataGrip via unix socket

it's my first time using DataGrip trying to connect to MySQL in a Ubuntu 18.04 server.
I've added a new user to MySQL. When I try to connect to MySQL using the command MySQL -u user -p works.
But on DataGrip, I've created an ssh tunnel and it's making the connection without any problems.
But when trying to connect to MySQL it gives this error The specified database user/password combination is rejected: [28000][1698] Access denied for user 'user'#'localhost'.
I am sure that the password is correct and in the log file it is showing that it's making the ssh connection, but it gives access denied when connecting to MySQL. If someone could help me, I appreciate it.
To connect to MySQL server using unix sockets follow an article in DataGrip documentation.
Connection via sockets available in DataGrip since version 2021.1.

Remotely Accessing MySQL on Mac Mini/Time Capsule

I'm currently trying to run an application on a server but my customer is very 'picky' about their data and wish to store the database on their own internal office server. I've installed MySQL and can get the application to run locally but for a few specific reasons the application needs to run else where.
I basically can't get access to MySQL from a different location. I think my main stumbling block is port forwarding to the correct location. MySQL is installed on a mac mini with local IP address 192.168.1.242 and the router/modem is an Apple Time Capsule. I've tried looking at tutorials but they all have options that I don't have access to. I've attached a screenshot of the options I have access to and the settings I've tried so far.
Other information possibly needed is:
I need to connect from PHP
I've set a user up within MySQL with a wildcard (%)
I'm testing it using the following: command on my local machine in CMD: mysql -u username -h remote_ip_address -p
I get the following error: ERROR 2003 (HY000): Can't connect to MySQL server on 'REMOTE_IP_ADDRESS' (10061)
Firewall is turned off completely on the Mac Mini
There is nothing in the my.cnf file
OS is Sierra
That's all I can think of at the moment but any advice would be greatly appreciated and any more information required can be provided.
PS. evidently I'm not very good with MAC machines/networks
For anyone that reads this I had a very specific issue. I installed MySQL using homebrew. Homebrew binds MySQL to 127.0.0.1 therefore will only allow connections to MySQL from the same machine no matter what you try to do. To fix it I've had to edit /usr/local/Cellar/mysql//homebrew.mxcl.mysql.plist and replace --bind-address=127.0.0.1 with bind-address=*.
MySQL has an internal firewall of users/IPs. Even if you can connect locally, you might not have permission remotely:
Try this as root user on the MySQL server (locally first!)
GRANT ALL ON <db>.* TO '<user>'#'<remoteIP>' IDENTIFIED BY '<password>';
Where
<db> is the name of the DB
<user> is name under which you connect
<remoteIP> is your external office IP FROM which you are trying to connect
<password> should be self-explanatory!
This will explain the options better

Accessing Database created in XAMPP while working in Laravel 5 homestead

I'm starting a large project in Laravel 5. In the past I used XAMPP for all local work. Now we're going to work in Homestead. I got Homestead set up and running and I booted up a Laravel 5 project in it. works fine.
Because of various reasons we do NOT want to use Laravel migrations but are using MYSQL workbench in combo with XAMPP-PHPMyAdmin for work on the mysql database. My question is: how can I access this mysql database from within the Homestead VM?
I tried all kinds of settings in the app/Config/database.php. but none work.
I looked around for related questions here, but none seem to answer the base of my question: is it even possible to access a remote database (or one on my host machine) from within homestead?
I read somewhere that I can create migrations from an SQL dump to duplicate the DB in homestead using a package (https://github.com/Xethron/migrations-generator). using this as a workaround, I could connect my Laravel app to my DB I have set up in XAMPP, generate the migrations, then connect back to the Homestead DB and finally run the migrations. I think this could work but I would prefer direct connection. any suggestions on how to connect to a database outside the Homestead VM would be welcome.
<1>Open .env (can be found in root of laravel)
<2>Change DB_HOST to your LAN IP address(something like 198.168.0.11)
DB_HOST=LAN_IP
<3>Now go to phpmyadmin and in privileges tab
Add new user and fill login info
Select host as any_host(or fill host with your PC name)
I am also relatively new to Laravel and Homestead too but have had some luck with it.
First I'm not sure it's such a great idea not to use the MySQL instance inside Homestead but if you have your reasons I'll take you at your word. That said from your "Homestead" directory you can "vagrant ssh" into your Homestead VM.
Here you can mysql -u homestead -psecret dbname into your database and configure it at will just as you would your XAMPP instance. If you are using Laravel models as long as they match the database you'll be fine.
To your point of connecting to another database from within the VM have you tried to connect to that outside database from the command line? As long as your XAMPP MySQL instance is configured to receive remote connections and you have a user properly configured you should be able to test from the command line from within the Vagrant VM. See below where 192.168.1.196 is the IP address of the box/VM containing the MySQL instance to which you want to connect. I'm not running XAMPP but I was able to make a connection from within Vagrant Homestead out of the VM to another MySQL instance running on my local machine by providing my local network address. "127.0.0.1" won't work obviously because the Vagrant VM will perceive that as itself.
mysql -u user -ppassword dbname -h 192.168.1.196
Hope this helps.

Can't connect to MySQL

I'm trying to connect to MySQL, using Sequel Pro, something I have done many times before. Host 127.0.0.1, username root, no password. I get the following message:
Unable to connect to host 127.0.0.1 because access was denied.
Double-check your username and password and ensure that access from your current location is permitted.
MySQL said: Access denied for user 'root'#'localhost' (using password: NO)
For what it's worth, I got this message after upgrading to a new Mac OS (Mavericks), realized that the server wasn't running, downloaded a new server (which is currently running), and tried again - but I had the same problem.
Make sure you are running MySql in background System Preferences -> Mysql -> Start MySql
Make sure you are able to connect to MySql through command line, if command line works, there is no reason why it should not work in SequelPro.
If problem still persists, try changing the 'root' password.
It happened to my in Mac. I went to system preferences -> MySQL -> Stopped the server, started it again, and it worked.