mysql only runs as root - mysql

I've just recently installed my Macports MAMP environment and I thought I'd followed the directions, but couldn't get MySQL to run. After much wrangling and testing, I've stumbled upon what the problem is, but I have no idea how to solve it.
I was getting the classic, irritating "Can't connect to local MySQL server through socket" error message. Checking and rechecking, the socket file was exactly where MySQL expected it to be and was set to the right permissions. Then, while trying to troubleshoot, I attempted to log in while I was still in superuser and boom! I was in!!
Leave superuser and it no longer works. Doh!
So my question is: how might I correct this problem and get it to run as a regular user? The trouble with Google searching a topic like this is that the two user systems - MySQL and Mac - are getting confused and I'm not finding the solution I need.
Thanks very much!
A brief example of the problem:
`tomb# mysql -u root -p thisismypassword
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/local/var/run/mysql55/mysqld.sock' (13)
tomb#sudo su
Password:
sh-3.2#mysql -u root -p thisismypassword
mysql >`

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

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

ERROR 2003 (HY000): Can't connect to MySQL server on '....' (65)

This is the first time I am setting up a remote connection and I am doing this.
mysql -u user -password -h dbserver.dev.5bfed886-8150-4a8d-b0d5-4c7cffb5c54c.drush.in -P 11831 dbname
I get this error back.
ERROR 2003 (HY000): Can't connect to MySQL server on 'dbserver.$ENV.$SITE.drush.in' (65)
I have scoured the web I am not able to find a solution, I would appreciate any help. I apologize beforehand if any information is missing (I am a first timer).
Try this:
mysql -uuser -p -hdbserver.dev.5bfed886-8150-4a8d-b0d5-4c7cffb5c54c.drush.in -P11831
mysql ask you for password after running
As the last commenter mentioned, you need to "wake" up the site. However, this can be accomplished just by reloading the homepage.
https://pantheon.io/docs/debug-connections/
Services such as MySQL and SFTP are running; however, the local client
is unable to connect due to an idled container or DNS issues. Before
further troubleshooting, wake the environment by loading the home page...
If you're trying to connect to Pantheon (which it looks like you are), you might just need to wake up your instance. I did that with terminus drush --site=[site_name] --env=[environment_name] st where [site_name] is replaced with the machine name of your site and [environment_name] is replaced with the machine name of the environment you wish to awaken.

Cannot Connect to Database Server mysql workbench

I'm trying to connect to mysql workbench but I get the following error
Error Message
Cannot Connect to Database Server
Your connection attempt failed for user 'root' from your host to server at
127.0.0.1:3306:
Could not open database.
Please:
1. Check that mysql is running on server 127.0.0.1
Check that mysql is running on port 3306 (note: 3306 is the default, but this can be changed)
Check the root has rights to connect to 127.0.0.1 from your address (mysql rights define what clients can connect to the server and from which machines)
Make sure you are both providing a password if needed and using the correct
password for 127.0.0.1 connecting from the host address you're connecting
When I Test Connection, the parameters are correct, and actually I can enter and manage database in console.
When I installed Mysql for first time I could enter to Workbench one time and if I closed Workbench I had to restart my PC to connect another time.
I reinstalled 2 or 3 times Mysql server and Workbench and now I cannot connect from Workbench even once.
I faced similar issue and resolved it by following these steps:
In the terminal, execute this command
mysql -u root -p -h localhost -P 3306
Enter the password
This will be displayed
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 8.0.16 Homebrew
Now do,
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
Now you should be able to login and connect to DB in the workbench with password 'root'
I don't know if it helps anyone, but I had the same problem on windows after updating from MySQL 5.7 to 8.0.
The solution for me was to go to services.msc, stop the MySQL service and start the "MySQL80" service instead.
Then I restarted MySQL Workbench (run as admin) and it worked.
Please make sure that You have Downloaded MySQl server while dowloading MySQl workbench from MySQl installer (if you have checked Custom download)
I had the same issue a few days ago. As I could see in the original question, there has been multiple MySQL installation on the same computer - the same flow I tried after failing in the first attempt.
In the case we are trying to reinstall MySQL, we should be aware of remaining hidden files after MySQL has been uninstalled for the first time. In order to remove them all (and make one successful installation), we should:
Make hidden files visible on your computer (instructions)
Delete all files related to MySQL after choosing uninstalling of the MySQL (I had to check C://ProgramData hidden folder)
Try a new installation
I think that during the first installation, I didn't have all required dependencies on the computer (for example Python) and the installation failed. After installing it, uninstalling the MySQL, and taking steps from above, I finally managed to run it successfully :)
I hope this could help someone! :)
This solved it for me (MAC OS)
Open MySQL from System Preferences > MySQL
Click 'Stop MySQL Server' if the server is running
Select 'Initialize Database'
Type your new password.
Choose 'Use legacy password'
Start the Server again.
Now connect the MySQL Workbench

remote mysql access showing different database list

I found a weird problem that when I connect to my database which locates at another server, the output of show databases; was different with that when I did local.
My database was running MySQL at IP 10.200.0.11, I connect with mysql -u username -p -h 10.200.0.11
I did some search, seems no people reported this problem? Did my mysql client cached something? I tried another client machine, and it works good through.
Any thoughts? Thanks in advance.