Unable to Access MySQL from Command Line - mysql

Using MAMP 4.2.1
My bash profile:
export PATH=$PATH:/Applications/MAMP/Library/bin
Things tried and results:
mysql
=>ERROR 1045 (28000): Access denied for user 'jessier'#'localhost' (using password: NO)
mysql -u root -p
=>Enter password: (*mypassword)
=> ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2)
/Applications/MAMP/Library/bin/mysql -u root -p
=>Enter password: (*mypassword)
=> ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2)
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock
(Attempt again using previous commands, same error messages. Restarted terminal, restarted server, tried with servers both on and off to no success. MAMP running fine in /phpmyadmin.)

UPDATE: SOLVED. Removed MAMP and did a fresh install. Once server started, ran:
/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot
Success.

Related

mysql cli to 127.0.0.1 but redirect to 172.17.0.1

I have installed mysql-client in my Mac by the following command:
brew install mysql-client
And when I run the following command:
mysql -h 127.0.0.1 -u root -p
An ERROR 1045 occured:
ERROR 1045 (28000): Access denied for user 'root'#'172.17.0.1' (using password: NO)
but when I use Sequel Pro I can login the local mysql server.
Why the 127.0.0.1 becomes 172.17.0.1 ?
MORE DETAIL INFO
I run this command on local host iTerm. I use the docker pull to pull a mysql:5.7 image from docker registry:
docker run --name mysql -e MYSQL_ROOT_PASSWORD=xxxxxx -d -p 0.0.0.0:3306:3306 mysql:5.7
And the mysql container is just running, then I use Sequel Pro GUI client to connect into the database in docker, and it works. And then I try to use
brew install mysql-client
to install the mysql command (because I want to use it to run a sql file to prepare data for my project's tests suite). after installed mysql-client, i use the command
mysql -h 127.0.0.1 -u root -p
try to connect database, but it promote the
**ERROR 1045 (28000): Access denied for user 'root'#'172.17.0.1' (using password: NO)**.
I did not do any configuration for the mysql docker container.
After hours try and search, finally I found the solution:
mysql -h 127.0.0.1 -P 3306 -u root -p
you need a -P parameter

ERROR 2002 (HY000): can't login to mysql with standard sintax

I don't know why standard login to mysql fails:
mysql -u davide -p Enter password: "my password" ERROR 2002 (HY000):
Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (2)
I can log in with this command:
mysql -h 127.0.0.1 -u davide -p
I can't login via phpMyadmin too for this reason

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

I tried to connect mySQL from remote server I followed these commands:
convert
bind-address = 127.0.0.1
to
bind-address = 0.0.0.0
and followed by,
systemctl restart mysql.service
then login to mySQL server in local machine and gave following command:
GRANT ALL ON databaseName.* TO 'user'#'xx.xx.xx.xx' IDENTIFIED BY 'password';
then tried in remote server with following command:
mysql -u user -p -h xx.xx.xx.xx
Got error as:
ERROR 2003 (HY000): Can't connect to MySQL server on 'xx.xx.xx.xx'
Can someone help on this? How can I connect mySQL remotely?

access denied mysql monitor

I installed xampp on 10.9 mavericks. Unfortunately the command mysql does not work in the terminal. I managed to start the mysql monitor from xamppfiles/bin/. When I try to create a new database I get
ERROR 1044 (42000): Access denied for user ''#'localhost' to database XY
What can I do?
No, you should run mysql -u root -p in bash, not at the MySQL command-line. If you are in mysql, you can exit by typing exit.
You may need to set up a root account for your MySQL database:
In the terminal type:
mysqladmin -u root password 'root password goes here'
And then to invoke the MySQL client:
mysql -h localhost -u root -p

MYSQL can't start service on Windows 7

EDIT: This happened most of the times, due to power failure.
Two things which worked for me.
1. Knowing how to change root password in MySQL, and taking backup of databases.
2. Install MYSQL as service.
C:\> "C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld" --install
I had done clean installation of MYSQL 5.6 few days ago.
On first day everythng was fine. I could access city and world tables.
On next day I started getting below errors. Some were I read to run mysqld at admin level.
And it solved problem, but I couldn't access city and world table anymore.
On third day. I am getting only this errors.
Note: MYSQL service running previously fine, when firewall, antivirus (avast) and apache was running.
When run on admin mode :
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root -p localhost
Enter password: ***********
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root -p localhost
Enter password: *
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root -p localhost
Enter password:
ERROR 1049 (42000): Unknown database 'localhost'
When run on user mode (who is admin also) :
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root -p localhost
Enter password: ***********
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root -p localhost
Enter password: *
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root -p localhost
Enter password:
ERROR 1049 (42000): Unknown database 'localhost'
Not able to start MYSQL Service from Control Panel\All Control Panel Items\Administrative Tools\Service
Error Message ; WIndows could not start the MYSQL56 service on Local Computer
Error 1067 THe process terminated unexpectedly
Regards : Msinfo
You need to use "-h" before "localhost" if you want to specify a host, otherwise just remove "localhost" and it should work fine, considering a running server on your system.
Also, MySQL server is "mysqld.exe" not "mysql.exe". mysqld (d stands for daemon) is the server which should run in background and does the actual stuff like creating tables,DBs etc. But mysql.exe just connects to the server and helps you to execute SQL queries. mysql.exe is just an interface to connect to server. If you want to know why your server (windows service in your case) is not starting, you should see the XXX.log in your MySQL server installation folder under Program Files.
try by creating the database in MySql by the respective name "localhost"
eg: create database localhost;
by doing this you can clear the below error
ERROR 1049 (42000): Unknown database 'localhost'
hope i am correct
Thanks,
Daya