MySQL, accidently deleted the root users - mysql

In phpMyAdmin, I accidently deleted the 3 root users, when I add mysql_grant_tables or whatever it says they're still there.
I try and run this and it says this.
mysql> grant all privileges on . to 'root'#'localhost' identified by
"" with grant option; ERROR 1290 (HY000): The MySQL server is running
with the --skip-grant-tables option so it cannot execute this
statement
Is there a way that I can get these users back up and running again?

Manually Backup (COMPY) your own databases from data folder from
MySQL
Manually Backup (COMPY) your website(s)
Uninstall XAMPP and setup new one.

Related

ERROR 1045 (28000): Access denied for user 'root'#'localhost'

so i installed the MySQL application for the first time. firstly i saw the command line client is not opening so i searched for solutions. they said i must go to the bin directory and run it manually. and after i run the cmd mysql -uroot -p and run it and enter password, it gives me the error: ERROR 1045 (28000): Access denied for user 'root'#'localhost' i tried every single solution on stackoverflow including disabling permissions, running manually which i mentioned above, starting the service from service.msc, running it with password and without.... it just doesnt want to work.
appreciate any help in advance.
GENERIC MYSQL INFO
To start with, read the mysql manual: https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
The steps will show you how to shut down the service and start it with an overriding command that doesn't require passwords, then you reset the password. From the manual:
Stop the MySQL server, then restart it with the --skip-grant-tables option. This enables anyone to connect without a password and with all privileges and disables account-management statements such as ALTER USER and SET PASSWORD. Because this is insecure, you might want to use --skip-grant-tables in conjunction with --skip-networking to prevent remote clients from connecting.
Connect to the MySQL server using the mysql client; no password is necessary because the server was started with --skip-grant-tables:
shell> mysql
In the mysql client, tell the server to reload the grant tables so that account-management statements work:
mysql> FLUSH PRIVILEGES;
Then change the 'root'#'localhost' account password. Replace the password with the password that you want to use. To change the password for a root account with a different hostname part, modify the instructions to use that hostname.
MySQL 5.7.6 and later:
mysql> ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass';
MySQL 5.7.5 and earlier:
mysql> SET PASSWORD FOR 'root'#'localhost' = PASSWORD('MyNewPass');
Or directly on the user table:
UPDATE mysql.user SET password=PASSWORD('mynewpassword') WHERE user='root';
XAMPP SPECIFIC
Stop the MySQL service. Open a command window. Change to the XAMPP MySQL directory:
> cd \xampp\mysql\bin\
Run the service without security (note you are running mysqld, not mysql):
> mysqld.exe --skip-grant-tables
The MySQL service will be running in this window, so open another command window and switch to the XAMPP MySQL directory:
> cd \xampp\mysql\bin\
Run the MySQL client:
> mysql
Update the password:
mysql> UPDATE mysql.user SET password=PASSWORD('mynewpassword') WHERE user='root';
Exit MySQL:
mysql> \q
Use task manager to cancel the mysqld.exe that is still running. Restart the mysql service.
I got the answer myself. Seemingly, if you get this error, it means that you need to reset your password. You can learn how to do that in MySQL from this link.
And don't forget to change the 5.7 version with your currently installed version in using commands (mine was 8.0).
After that, everything was working fine for me.

Cannot grant MySQL user access to information_schema database

I am creating a Laravel App and testing it in production mode on a fresh installation of Ubuntu 19.10.03. Fresh LAMP installation (PHP 7.3, MySQL 8.0.19-0).
I can create a new database, and a new user that has full access to the database, but Laravel requires that the user have the SELECT option from the 'information_schema' database as well. Here is the process I am using:
$ sudo mysql
mysql> CREATE DATABASE IF NOT EXISTS `my-laravel-database`;
mysql> CREATE USER IF NOT EXISTS 'laravelUser'#'localhost' IDENTIFIED WITH mysql_native_password BY 'myPass';
mysql> GRANT ALL PRIVILEGES ON `my-laravel-database`.* TO 'laravelUser'#'localhost' WITH GRANT OPTION;
mysql> GRANT SELECT ON `information_schema`.* TO 'laravelUser'#'localhost';
The last command always returns
ERROR 1044 (4200): Access denied for user 'root'#'localhost' to database 'information_schema'
I have tried running the mysql_secure_installation command to set the root password, this did not help. I can run the app as the root user, but I do not want to do this in production.
I have also tried a fresh installation of Ubuntu with just the LAMP services installed.
I wasted DAYS on something tangential to this problem. The answer was in the MySQL manual:
For most INFORMATION_SCHEMA tables, each MySQL user has the right to access them, but can see only the rows in the tables that correspond to objects for which the user has the proper access privileges.
So you can't grant permission to INFORMATION_SCHEMA directly, you have to grant permission to the tables on your own schemas, and as you do, those tables will start showing up in INFORMATION_SCHEMA queries.
Unfortunate, because I'd love have a user who's able to see INFORMATION_SCHEMA, but not the content of the actual tables, and there doesn't seem to be a way to do that.
Try the following:
USE mysql;
ANALYZE TABLE db;
In case table is broken run the following:
REPAIR TABLE db;
Then restart MySQL server.

Mysql connection from other computer to xampp server? Error 1045

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

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

Phpmyadmin - Mysql no privileges

I installed wamp 2.1 on windows 7. However when i open phpMyAdmin, I get the error, Mysql 'No Provileges'. I uninstalled wamp and reinstalled it a few times, but it doesn't help. Does anyone know how to solve this issue?
Also, when i tried creating a database from mysql console, i am getting the following error:
ERROR 1044 <42000>: Access denied for user ''#'localhost' to database 'a_db_name'
Thank God and to all helped.
Its simple.
Must! click logout icon in phpadmin page
In login page, type:
username:root password: (blank)
surprise. now you can happily create your database.
Are you logging into MySQL as root? You have to explicitly grant privileges to your "regular" MySQL user account while logged in as MySQL root.
First set up a root account for your MySQL database.
In the terminal type:
mysqladmin -u root password 'password'
To log into MySQL, use this:
mysql -u root -p
Edit:
To set the privileges manually start the server with the skip-grant-tables option, open mysql client and manually update the mysql.user table and/or the mysql.db tables. This can be a tedious task though so if what you need is an account with all privs I would do the following.
Start the server with the skip-grant-tables option
Start mysql client (without a username/password)
Issue the command
flush privileges;
which forces the grant tables to be loaded.
Create a new account with the GRANT command something like this (but replacing username and password with whatever you want to use.
GRANT ALL on *.* to 'username'#'localhost' identified by 'password';
Restart the server in normal mode (without skip-grant-tables) and log in with your newly created account.
Refer this MySQL docs.
Take a look at my topic regarding this issue, which takes some of the above.
MAMP mysql broken root user
You need to shutdown your mysql install and restart it from the command line properly like is indicated above. In my topic I have full clear instructions on how to do so. My instructions are for MAMP but you should be able to adapt it for your install.
Simple solution. Just find the icon right to "home" in PhpMyAdmin and click to logout. Then login using username "root" and password ""(blank). This will work accordingly.
username ought to be root and keep the password null(keep the password field blank)
right click on the wamp icon and goto mysql console.
Login with password if you have set any.By default the password is blank and username is 'root'
Once you are in mysql prompt execute
FLUSH PRIVILEGES;
now quit the command prompt and you are good to go.
in step 1 .inter your databasevery important.
in step 2 .select your database via all tables .
in step 3. backup type=replace & export.
in step 4 import database in my sql.
attention please:in import your database...
all table must view & selected in step 4.