How to restore mysql users - mysql

I dropped accidentally all the users exist in my mysql DB and when I refresh the admin page I had this error :
Error
MySQL said:
1130 - Host 'localhost' is not allowed to connect to this MySQL server phpMyAdmin tried to connect to the MySQL server, and the
server rejected the connection. You should check the host, username
and password in your configuration and make sure that they correspond
to the information given by the administrator of the MySQL server.
How can I restore those users without losing my data ?

You just need to set an init file with the correct SQL to create/set a password for the root user, and then restart the server with the --init-file parameter.
Follow the directions here. Any SQL in the init file will be run, so you can create more users if you need to also.

Related

Mysql not accepting connections from some sources

I have a MySQL server (v8.0) running on windows server 2016. I also have IIS running and PHPMyAdmin installed. In addition to this, I have a PHP web application which runs on the same server (under IIS) which accesses the MySQL database. Finally, I have several Python scripts which access the MySQL database.
Somehow, I have lost the ability to access the database from the Python scripts, but the web application still works and PHPMyAdmin can see and modify the database.
Even more strangely, I can no longer user MySQL Workbench to access the server from a PC on the local network, and PHPMyAdmin cannot access the users table of the mysql database. I can't change user details at all through PHPMyAdmin, I get the error:
Error in processing request
Error code: 500
Error text: Internal Server Error (rejected)
It seems that the connection to server has been lost.
MySQL Workbench gives me this error:
Your connection attempt failed for user 'user' to the MySQL server at SERVERADDRESS:PORT:
Access denied for user 'user'#'SERVERADDRESS' (using password: YES)
I have checked that the server can accept connections from remote computers by adding bind-address=0.0.0.0 to the my.ini file. I have also checked to ensure that 3306 is allowed through the firewall.
Any ideas on what could be causing this issue?
ADyson and MrApnea pointed me in the right direction.
The problem was caused by my main database user having the host reset from % to localhost, I'm not sure how this happened or when. As the app was running locally, this was not affected, but all other access was denied (including MySQL workbench). My root user is set to local only for security.
To fix this, I connected to the server via RDP and logged in to the console as the root user. I then ran these commands to see the error:
use mysql;
select host, user from user;
This showed me that the main user account had "localhost" in the host. I ran this command to update this user:
update user set host='%' where user='username' and host='localhost'; flush privileges;

Could not connect to remote database

I have added the given below lines to config.inc.php file in the s C:/xampp/phpmyadmin folder and added the lines below
$i++;$cfg['Servers'][$i]['host'] = '172.16.10.100';$cfg['Servers'][$i]['user'] = 'root';$cfg['Servers'][$i]['password'] = '';$cfg['Servers'][$i]['auth_type'] = 'config';
I have encountered the following error
MySQL said: Documentation
Cannot connect: invalid settings. phpMyAdmin tried to connect to the
MySQL server, and the server rejected the connection. You should check
the host, username and password in your configuration and make sure
that they correspond to the information given by the administrator of
the MySQL server.
What could be the possible reason for this error?
As in the documentation, it seems likely that the hostname, username or password in your string are incorrect.
Do you know that they are correct? MySQL can have host-specific passwords, so connecting from one server may require a different password to connecting from another.

host xxxx is not allowed to connect to this mysql server vb godaddy

I'm having a trouble accessing the database in my godaddy account. I already created a database in phpmyadmin and a user in mysql database
I need to access the database in my godaddy account using my localhost.
But when i run my code, i'm getting a host xxxx is not allowed to connect to this mysql server
below is what i used in config
Public consqlonline As String = "server=Website_ipAddress;user=uname;password=pass;database=syncing;Connect Timeout=2000"
you need to give a privilege to connect the specific database that the application need to connect, via PHPmyadmin >> choose database >> use privileges tab.
by the way i had this problem also and my server was running on Linux, by default the configuration of the server permit connection only from localhost, so to fix that ive edited /etc/mysql/ my.cnf file: changed the bind-address from 127.0.0.1 to 0.0.0.0 (if the version is kind of old you have to comment the "skip-networking" command

How to access MySQL remotely through workbench

Hi I'm trying to create a new Connection to an MySQL database installed on a remote Windows server. However, due to server authentication problem, I cannot get the local mysql workbench connected to the remote database. And I could not find a place in workbench where I can provide my server authentication, i.e. username and password to access server. Does anyone know how to do this?
Thanks!
in the Home window of mysql workbench, near Mysql Connections there is a + button, click on it to Open the setup new Connection wizard, then you get to enter the server's parameters.
Hostname : your Windows Server's host name.
Port : Port on which the remote mysql server communicate.
Username : your Mysql server's Username.
Password : your Mysql server's Password.
Default Shcema : the database you want to connect to.
Hope this helps

MySQL Database connects, but says the name is incorrect

I am trying to install Pligg on my linux server, but am having difficulties. I am at the point where I need to point Pligg to a SQL server, and setup the server on using these instructions:
http://codelikezell.com/setting-up-rails-mysql-php-apache-and-git-on-ec2/
Pligg asks for:
Database Name
Database Username
Database Password
Database Server
Table Prefix
For Database Name, I use mysqld - which Putty confirms is running. I login as root and the password I assigned, set the Server to localhost.
I get this error, however: Error: Connected to the database, but the database name is incorrect.
How can it connect to the DB if the name is not correct? Am I doing something to point Pligg to the wrong DB?
Thanks!
Database name is not the same as process name(mysqld). Leave it blank or enter 'test' as db name; as far as I remember mysql always creates test database by default.