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.
Related
I'm trying to connect remotely to mysql and this isn't possible, I'm running Debian 10 and mysql server 8.0 in my server, I did try to do the changes in /etc/mysql/my.cnf to change or comment bind-address and skip-networking but It doesn't work for me.
I found the solution, in Mysql 8.0 remote connections It doesn't need enable in remote connection you only need to create a new user and give it grant privileges, the command in sql console that I used :
CREATE USER 'newuser'#'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'newuser'#'%' WITH GRANT OPTION;
FLUSH privileges;
Reference: https://www.youtube.com/watch?v=K_UkiAMyPpk
I am not so into DB and I have the following problem.
I have installed a MySql 5.7.17 on a remote Ubuntu 16.04 server and I have to connect to this server from a client installed on my laptop.
So The first thing that I have done is that I have changed the bind-address directive values (into the /etc/mysql/mysql.conf.d/mysqld.cnf file) from:
Bind-address=127.0.0.1
to:
bind-address = 0.0.0.0
to allow also external connection.
The problem is that when I try to connect from my client (installed on my laptop) I obtain this error:
Host 'XXX.YYY.ZZ.JJ' is not allowed to connect to this MySQL server
(where **XXX.YYY.ZZ.JJ* is my laptop IP address).
From what I have understood I also have to give to the mysql user w the db permissions to connect from any host and not just from localhost.
I think that it should be something related to the grant: https://dev.mysql.com/doc/refman/5.5/en/grant.html
What exactly have I to do? I think that I have to access to MySql from my server shell (via SSH) and then perform a query that grant some privileges to the root user (the MySql user) to allow to access from outside.
But I don't know what exactly I have to do. How can I allow this external connection for the roo user?
As you mentioned, you need to login to mysql server with root access and then run following command on mysql prompt
GRANT ALL PRIVILEGES ON your_db_name.* TO 'your_db_user_name'#'%' IDENTIFIED BY 'newpassword';
you can also specify a specific IP instead of %
GRANT ALL PRIVILEGES ON your_db_name.* TO 'your_db_user_name'#'your_IP_here' IDENTIFIED BY 'newpassword';
you can also specify a for all databases
GRANT ALL PRIVILEGES ON *.* TO 'your_db_user_name'#'your_IP_here' IDENTIFIED BY 'newpassword';
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';
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
How do you set a users host permission via SSH for MySql?
I've managed to accidentally set the wrong domain/ip for my root user in WebMin > MySQL Server permissions. Like I went into hosts to allow remote access and put the wrong address. Now even Webmin cannot get into he database with the credentials.
Login to server via SSH.
Use following command to enter mysql:
mysql --skip-grant-tables -u root -p
skip-grant-tables will cause mysql to abandon privilege system for this session.
Then use grant command to grant any privilege to your root user:
grant all privileges on *.* to 'root'#'my-host-or-ip'