Mysql connection from other computer to xampp server? Error 1045 - mysql

There is much information about this error but seems nothing works.
So I try to access to xampp mysql-server using the user root from local network.
mysql -uroot -p -h 192.168.100.48 --port=3306 (connecting from other local computer to xampp server)
But even I put right password (which I use for root) it not work. It works only if I log in using same computer where the server is running. I can use other user which I have specified but not root user. Why?
So how to fix this problem and getting it working?

Does the root user have the correct permissions?
Check the first duplicate link below for full answer - credit to Michael Berkowski:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'192.168.1.%'
IDENTIFIED BY 'some_characters'
WITH GRANT OPTION;
FLUSH PRIVILEGES;
Have you tried search SO first? There are quite a few questions like this.
Possible duplicates:
How to grant remote access permissions to mysql server for user?
Remote MySql connection from other server

Related

MySQL Host '::1' or '127.0.0.1' is not allowed to connect to this MySQL server

I have a strange issue on a web server (Windows Server 2012) with MySQL 5.7.16.
I can't connect anymore to mysql server, I don't know why.
If I type mysql -uroot -ppassword appear an error
ERROR 1130 <HY000>: Host '::1' is not allowed to connect to this MySQL server or
ERROR 1130 <HY000>: Host '127.0.0.1' is not allowed to connect to this MySQL server
I tried to use another user with all privileges and I've seen that in host there is only localhost (not 127.0.0.1 or ::1)
How can I login with root#localhost and not with root#127.0.0.1?
It's very frustrating...
Every account trying to use #127.0.0.1 or #::1 but there exist only localhost in host and I can't change it.
If I type mysql -uroot -ppassword I see
ERROR 1130 <HY000>: Host '127.0.0.1' is not allowed to connect to this MySQL server
Same if I type mysql -uroot -ppassword -h localhost or anything else
Ok i Fixed...
I've comment "skip_name_resolve" in my.ini and everything is back to work.. i really don't know why because this record was in my.ini also yesterday..last week.. last month..
The variable skip_name_resolve gives better performance because the server does not try to resolve the names of the connecting clients or look for them every time in the host name cache (even localhost is resolved/searched), but the manual states that config also limits the #localhost connections. The solution is to copy the #localhost users with #127.0.0.1, like this:
CREATE USER 'root'#'127.0.0.1' IDENTIFIED BY 'root-password';
CREATE USER 'root'#'::1' IDENTIFIED BY 'root-password';
FLUSH PRIVILEGES;
where ::1 is localhost for IPv6 addressing. This way we keep the root and local accounts limited to the local server. Using '%' open the potential clients to the world, and we don't want that. Disabling skip_name_resolve also requires the server having an accesible and fast DNS resolver to minimize latency.
I noted that I can connect with a local phpmyadmin even if the user has #localhost; this is because phpmyadmin connects thru a local unix socket, a special type of file used to communicate between processes, and does not need networking.
EDIT: As #Francisco R noted, the new root users also should have full access to all databases by issuing the following commands:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'127.0.0.1'
GRANT ALL PRIVILEGES ON *.* TO 'root'#'::1'
FLUSH PRIVILEGES
I had the same message after a fresh installation with the no-install zip and solved it as follows. Perhaps this could have been a solution for your problem too:
Stop the MySQL server or service.
Open a Command Prompt window with administrative rights and go to the bin folder in the MySQL install directory.
Start MySQL with skip-grants-table and don't forget your config file:
mysqld --defaults-file=[filename] --skip-grant-tables
Open another Command Prompt window and go to the bin folder again.
Now you can login:
mysql -u root -p
Show the users with:
SELECT user, host FROM mysql.user;
Verify there is one 'root' with host 'localhost'.
Change the host:
UPDATE mysql.user SET host='%' WHERE user='root';
Exit the mysql program and close the Command Prompt window.
Type Ctrl-C in the other Command Prompt window to stop the server, then close the Command Prompt Window.
Start MySQL as you normally would and verify that you can login.
Make sure that when you created the user you have specified % as the hostname, otherwise the user will only be able to connect from the localhost.
I came here looking for a solution using Local by flywheel for wordpress development to the same problem, BUT, in a linux machine.
Just if someone faces the same problem, the solution listed here works.
Just comment skip_name_resolve in the file conf/mysql/my.cnf.hbs under the file tree created by Local
Thanks!
Looks that you need to modify your hosts file. C:\Windows\System32\Drivers\etc\hosts
just add the line and save it, (to be able to edit and save you may need to open it as administrator)
127.0.0.1 localhost

phpMyAdmin "Create database: Documentation No Privileges", how to create database?

I'm just starting to learn php and mysql, and just trying to set everything up. To try out example problems for learning, I'm trying to create database by logging into the http:://my-local-ip/phpmyadmin/. I can login using the user-name and password used during installation, but trying to cretae database I see No Privileges.
I have looked at the possible duplicates, I have tried clearing cache/cookies and entering flush and the user command sql, they have not fixed my issue.
Note that, I'm not on the same computer, I have a separate computer that I'm ssh-ing into (both ubuntu 16) and I'm accessing the web-phpMyAdmin via the local ip address of the ssh-ed computer.
I'm not sure how to fix this issue.
This solved my issue, on ssh-ed terminal, I ran:
sudo mysql
and on the prompt:
FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES ON *.* TO 'myUsernameCreatedEarlier'#'localhost';
Then I cleared the cache/cookies on the browser on my computer (not the server computer). And logged in on the phpMyAdmin web portal. Now I have database creation access.
Use these commands for mariadb with phpmyadmin:
sudo mariadb
FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'#'localhost';

Can't access MySQL on LAN server

MySql is installed on a Ubuntu server.
I am running Windows 8.
Logging in through Putty. I can log in to database with both root and webadmin user accounts.
I can also log in through my browser, using <server ip address>/phpmyadmin
My problem is when I try to use command line to log in. I am trying that approach because I am developing a webpage to access the database on that server. It fails to connect, so I thought if command line works, the webpage will also work.
commandline:
mysql -u webadmin -p
or
mysql -u root -p
error 1045 (28000): access denied for user 'webadmin'#'localhost'
(using password: yes)
I added an iptables entry to allow mysql and that didn't work.
Also, the firewall on server is inactive.
You need to grant access to the database. You can read the documentation here: https://dev.mysql.com/doc/refman/5.1/en/grant.html
You can run the following (but be careful as it will leave your DB open)
GRANT ALL ON *.* TO 'root'#'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
That will allow root to connect from any IP and do any operations to the DB. If that still doesn't work, you might also need to run the following before the 2 lines above
CREATE USER 'root'#'%' IDENTIFIED BY PASSWORD '[your password]';

Re-Enable localhost privileges on MySQL

I work with XAMPP and by mistake I deleted all privileges for localhost in MySQL so I can't use the localhost to GRANT ALL PRIVILEGES TO *.* root#localhost since I'm doing this in the localhost. I remember a User with full privileges and Its password but I can't do much since the localhost has no privileges at all and if I use the MYSQL Shell it tells me the same thing
I didn't enable remote access when I installed the XAMPP so it could be also a problem (Or maybe not and there is a solution within my machine).
Is there a way to access to mysql.user in some way to enable again the privileges for my localhost, or do it using the MySQL shell?
stop server
start server with –skip-grant-tables key
connect to server as root without password
edit privileges table:
USE mysql;
UPDATE user SET host='localhost' WHERE user=’root’ LIMIT 1;
FLUSH PRIVILEGES;
start server in normal mode
If you can restart MySQL server then follow these steps - How to Reset the Root Password.

Moved mysql DBs between mamp installations missing tables

I've been using MAMP out of convenience but have run into major problems after mistakenly changing root permissions. I have not been able to resolve these problems and have opted for a fresh install of MAMP and moving over the db folders, which I read was possible. In doing so, I have a number of DBs which have tables that are MIA.
SHOW GRANTS FOR 'root'#'localhost'
response:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'localhost' IDENTIFIED BY PASSWORD '*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B' WITH GRANT OPTION
GRANT PROXY ON ''#'' TO 'root'#'localhost' WITH GRANT OPTION
I can see the all the tables in the db folder but not all are not showing up in phpmyadmin.
I believe phpmyadmin connects as a socket "Server: Localhost via UNIX socket"
When I login into the console as root/localhost I can see all the tables.
Loggin into the console as root/127.0.0.1 I cannot see the DB at all.
I'm really stuck here and have pretty much lost a day of work because of this.
Update:
When I run mysql_update command I get the following response.
→ /Applications/MAMP/Library/bin/mysql_upgrade -p
Enter password:
Looking for 'mysql' as: /Applications/MAMP/Library/bin/mysql
Looking for 'mysqlcheck' as: /Applications/MAMP/Library/bin/mysqlcheck
Running 'mysqlcheck with default connection arguments
Running 'mysqlcheck with default connection arguments
ipbnew.ipb_admin_login_logs
Error : Table 'ipbnew.ipb_admin_login_logs' doesn't exist
status : Operation failed
ipbnew.ipb_admin_logs
Error : Table 'ipbnew.ipb_admin_logs' doesn't exist
status : Operation failed
I've posted a full explanation of the solution to my problem in a separate SO topic.
MAMP mysql broken root user