I have installed MySQL server 5 on redhat linux. I can't login as root so I can't change the root password.
mysql -u root -p
Enter password: <blank>
ERROR 1045 (28000): Access denied for user 'root'#'localhost'
(using password: NO)
When I try to set one like this:
mysqladmin -u root password 'newpass'
I get an error:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'#'localhost'
(using password: NO)'
As if there is a root password set.
I have also tried resetting the password using (described here)
/sbin/service mysqld start --skip-grant-tables
And then making:
mysql> UPDATE mysql.user SET Password=PASSWORD('newpass')
-> WHERE User='root';
ERROR 1142 (42000): UPDATE command denied to user ''#'localhost' for table 'user'
I even uninstalled mysql-server (using yum) and then reinstalled it but that did not help.
How do I force reset the root password?
One option is to save UPDATE mysql.user SET Password=PASSWORD('newpass') WHERE User='root'; into a file and then manually start mysqld with --init-file=FILENAME. Once the server starts, it should reset your password, and then you should be able to log in. After this, you should shut down the server and start it normally.
A little late to the game, but I had the same issue on a raspberry pi install and found out that it needs elevation. Adding a sudo to the front of the password change allowed it to work.
sudo mysqladmin -u root password 'newpass'
followed by an elevated sql access
sudo mysql -u root -p
If either are not run as sudo, it will fail.
The root user password is an empty string by default.
And (using password: NO) says that there is no password.
Do you try to login from another system? I imagine you can only login as root user locally.
I removed the MySQL installation and deleted the data files, and then reinstalled it.
Then I was able to set the root password. Once you set the root password to something. mysqladmin won't let you reset it if you don't know it.
To reset it, you've got to have ownership over how mysqld is executed, and feed it an init file to change the root password:
https://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html
This helped me on Windows with MySQL Server 5.6. Make sure you change the mysqld path to point to where you have installed MySql Server, for me it was "C:\Program Files\mysql\MySQL Server 5.6\bin\mysqld.exe":
Log on to your system as Administrator.
Stop the MySQL server if it is running. For a server that is
running as a Windows service, go to the Services manager:
From the Start menu, select Control Panel, then
Administrative Tools, then Services. Find the MySQL
service in the list and stop it.
If your server is not running as a service, you may need to use
the Task Manager to force it to stop.
Create a text file containing the following statements.
Replace the password with the password that you want to use.
UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
FLUSH PRIVILEGES;
Write the UPDATE and FLUSH statements each on a single line. The UPDATE statement resets the password for all root accounts, and the FLUSH statement tells the server to reload the grant tables into memory so that it notices the password change.
Save the file. For this example, the file will be named C:\mysql-init.txt.
Open a console window to get to the command prompt: From the Start menu, select Run, then enter cmd as the command to be run.
Start the MySQL server with the special --init-file option (notice that the backslash in the option value is doubled):
C:\> C:\mysql\bin\mysqld --init-file=C:\\mysql-init.txt
If you installed MySQL to a location other than C:\mysql, adjust the command accordingly.
The server executes the contents of the file named by the --init-file option at startup, changing each root account password.
You can also add the --console option to the command if you want server output to appear in the console window rather than in a log file.
If you installed MySQL using the MySQL Installation Wizard, you may need to specify a --defaults-file option:
C:\> "C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld.exe"
--defaults-file="C:\\Program Files\\MySQL\\MySQL Server 5.5\\my.ini"
--init-file=C:\\mysql-init.txt
The appropriate --defaults-file setting can be found using the Services Manager: From the Start menu, select Control Panel, then Administrative Tools, then Services. Find the MySQL service in the list, right-click it, and choose the Properties option. The Path to executable field contains the --defaults-file setting.
After the server has started successfully, delete C:\mysql-init.txt.
http://docs.oracle.com/cd/E17952_01/refman-5.5-en/resetting-permissions.html
Remove the -p from your command. -p forces the prompt for password.
Use :
mysql -u root
This will resolve your problem.
Probably a bit late here , but here is what I did :
create file resetpass.sh which has :
UPDATE mysql.user SET Password=PASSWORD('newpassword') WHERE User='root';
# mysqld_safe --init-file=resetpass.sh
# service mysqld start --skip-grant-tables
# mysql -u root -p
Enter pass
mysql > change root pass ; flush privs;
quit
# restart mysql service
The MySQL version I was using was 5.1.73 under centos6
Try do this:
mysql -u root
and then:
mysql> UPDATE mysql.user SET Password=PASSWORD('MyNewPass')
-> WHERE User='root';
mysql> FLUSH PRIVILEGES;
Worked fine for me!
According to the docs, in MySQL 5.7 the temp password gets put in /var/log/mysqld, but this is evidently not the case in 5.6.
With MySQL version 5.6 installed on RHEL 6.7, I finally found the temporary root password set during install was placed in the file /root/.mysql_secret.
open mysql
now enter the following commands :
use mysql;
update user set PASSWORD=password("updated password") where User='root';
flush privileges;
Related
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.
I have a little problem with my phpmyadmin, in fact I accidentally delete multiple user accounts.
Since it is impossible to connect without the error:
# 1045 - Access denied for user 'root' # 'localhost' (using password: NO)
I have search a little on the net before, and even the technic:
UPDATE mysql.user SET Password = PASSWORD ('') WHERE User = 'root';
FLUSH PRIVILEGES;
does not work, or I didn't understood how it worked.
I'm on FreeBSD 8.1, my version of PhpMyadmin is 2.11.
Thank you in advance for your answers.
I summarised my solution here: http://snippets.dzone.com/posts/show/13267
sudo stop mysql
sudo mysqld --skip-grant-tables --skip-networking
mysql
mysql> update mysql.user set password = password('your_new_password') where user = 'root';
mysql> flush privileges;
mysql> exit;
sudo mysqladmin shutdown
sudo start mysql
For mysql 5.7.16 or later I found this (from mysql.com) to be the working solution. Below are some points which are different compared to previous older versions
1) I used the below command to run mysql in safe mode as per some other references which actually worked fine for me (mysql 5.7.16 ubuntu 16.04).
mysqld_safe --skip-grant-tables --skip-networking
2) The below update stmt is NOT working for later version (ie. 5.7 and above)
-- NOT Working for 5.7 and later
UPDATE mysql.user SET Password = PASSWORD ('') WHERE User = 'root';
FLUSH PRIVILEGES;
INSTEAD use below for 5.7.6 and later
UPDATE mysql.user
SET authentication_string = PASSWORD('MyNewPass'), password_expired = 'N'
WHERE User = 'root' AND Host = 'localhost';
FLUSH PRIVILEGES;
OR user below for 5.7.5 or earlier versions.
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('MyNewPass');
I am Using MySQL Server 8 and this is how I solved this problem.
create a file and name it accordingly. I've named it as reset.txt. put below content in the file but change MyNewPass. This will be your new SQL password
ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass';
Stop my SQL server (Go to services and search MYSQL and right-click on it and stop )
Now open a cmd in your bin folder of My SQLserver directory. in my case it's
C:\Program Files\MySQL\MySQL Server 8.0\bin
execute the following command.
mysqld.exe --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" --init-file="C:\reset.txt'
NOTE: my reset.txt file is in the c drive. Give the correct path. Check my.ini file is in the directory. In my case, it is in
C:\ProgramData\MySQL\MySQL Server 8.0\my.ini
Finally, restart the SQL Server. Check with your new password.
Please follow the instruction from the below link to reset your root password.You have to do it from outside mysql.
Resetting MySql Password
Forgetting your MySQL password can be a real headache for you.Here are some easy steps that you can follow to recover MySql password under Windows
Stop MySql
You have to stop MySql service before you proceed.In Windows environment, go to 'Task Manager' and Under 'Service' tab find MySQL and stop it.
Write Sql to change your password
All you need to do is to create a text file and put the below two lines into that. UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; FLUSH PRIVILEGES; Save it under C:\ drive and give it a name 'mysql-init.txt'
Time to restart MySQL by your own.
Now it's time to restart your MySQl which you stopped in before but this time from command line. C:> C:\mysql\bin\mysqld-nt --init-file=C:\mysql-init.txt
Finishing up!
Now you can log in with your new password. When you finish remove the file that you created in the previous stage.
Also there is a link (http://kaziprogrammingblog.osinweb.com/article/showarticle/Resetting-MySql-Password) where I have explained the same thing.
Hope this will help..:)
Answer for XAMPP on Windows:
Edit C:\xampp\mysql\bin\my.ini and insert skip-grant-tables below [mysqld]
Restart MySQL from Control Panel interface
In the phpMyAdmin window, select SQL tab from the top panel. This will open the SQL tab where we can run the SQL queries. Now type the following query in the text area and click Go
UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root'; FLUSH PRIVILEGES;
Remove the skip-grant-tables in the my.ini file
Restart MySQL from Control Panel interface
DONE!
Be awared that mysql root user password does not have to be the same as password for phpmyadmin.
here is what I did and it worked:
After you install (rpm installation), do a vi /etc/my.cnf.
This will give you a path where your datadir is set. For me it was datadir=/var/lib/mysql.
Add a line there user=root, and remove all the content inside the datadir path: rm -rf /var/lib/mysql/*.
Now hit the command: mysqld --initialize.
A temporary password is generated at a location. For this:
grep "A temporary password" /var/log/*.
You will get a line that says:
/var/log/mysqld.log:2018-05-01T15:13:47.937449Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root#localhost: &uosjoGfi9:K. So for me &uosjoGfi9:K was my temporary password.
Now do a mysql -u root -p. Paste your temporary password from what you got from above.
You will be in your mysql cli mode. Now do:
mysql> use mysql;
You will be asked to reset your password:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
Run your ALTER command:
mysql> ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPswd';
And you are done.
in my case its a frustrating Windows Server installation (iis/php/mysql) so this is what i did:
PART 1: remove the old MYSQL :
NOTE: if you already have data you should back it up!
Step 1
Uninstall MySQL from Control Panel. (you should know how to do this)
Step 2
Run Command Prompt as Admini and execute the following commands to stop and remove MySQL service.
Net stop MySQL
Sc delete MySQL
Step 3
Delete these folders:
C:\Program Files\MySQL
C:\Program Files (x86)\MySQL
C:\ProgramData\MySQL
And if it exists:
C:\Users\[User-Name]\AppData\Roaming\MySQL
PART 2: Install MYSQL
Download installer from https://dev.mysql.com/downloads/installer/ and install
-MySQL Server 8.0.23
open cmd as admin and go to
c:\Program Files\MySQL\MySQL Server 8.0\bin\
run
mysqld --initialize --console
mysqld --install
now start the service (type services.msc in run panel)
now back to console run:
mysql -u root -p
ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass';
that's it
mysql80:
update user SET authentication_string='your password after encode to sha256' where User='root';
I have erased and installed OSX 10.11 El Capitan and I have been following through this tutorial to get MySQL up and running on the new OS X. The first step was to download MySQL For Mac OS X 10.9 (x86, 64-bit), DMG Archive (works on 10.11, they recommended in the tutorial). While I were finishing installing the MySQL, I got the message saying that :
2015-10-25T02:10:54.549219Z 1 [Note] A temporary password is generated for root#localhost: R>gFySuiu23U
If you lose this password, please consult the section How to Reset the Root Password in the MySQL reference manual.
That was weird, I have never seen that kind of message. After that, I started MySQL via the Preference Pane and then use /usr/local/mysql/bin/mysql -v command on the terminal for another step. I got an error message saying that :
ERROR 1045 (28000): Access denied for user 'cheetah'#'localhost' (using password: NO)
I have also tried to access database through Sequel Pro using root as username and blank password, I got access denied message saying that :
Unable to connect to host 127.0.0.1 because access was denied.
Double-check your username and password and ensure that access from your current location is permitted.
MySQL said: Access denied for user 'root'#'localhost' (using password: NO)
Okay, I also tried this again using root as a username but 'R>gFySuiu23U' as a password (which was generated from MySQL). I got connection failed message saying that :
Unable to connect to host 127.0.0.1, or the request timed out.
Be sure that the address is correct and that you have the necessary privileges, or try increasing the connection timeout (currently 10 seconds).
MySQL said: Your password has expired. To log in you must change it using a client that supports expired passwords.
How could I solve this problem? I remember that MySQL has never got automatically generated a temporary password like this, hasn't it ?
Try this:
mysql -u root -h 127.0.0.1 -p
Enter password: (enter the random password here)
Ref:https://dev.mysql.com/doc/refman/5.7/en/data-directory-initialization-mysqld.html
Following this, you may reset your password using
ALTER USER 'root'#'localhost' IDENTIFIED BY 'new-password';
This is what worked for me on OS X Yosemite running MySql v5.7 (installed from the .dmg).
cd /usr/local/mysql/bin
./mysql -u root -p --connect-expired-password
(Enter the temporary password generated by the installer.)
This gets you into sandbox mode and mysql> prompt. Then set desired root password with SET PASSWORD:
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('mySuperSecretPassword');
Now that the password MySQL had generated is expired, the problem is reduced to getting this password to work again (1) or generate a new one (2). This can be accomplished by running MySQL with the skip-grant-tables option which would make it ignore the access rights:
Stop your MySQL server.
Add the below at the end of the [mysqld] section of my.cnf file and save it.
skip-grant-tables
Start MySQL server.
In terminal, type
mysql -u root -p
to get into MySQL command prompt.
In the command prompt, type
USE mysql;
to get into the mysql database where it keeps database users.
Type
UPDATE user SET password_expired = 'N' WHERE User = 'root';
to let MySQL know the password is not expired (1) or
UPDATE user SET authentication_string = PASSWORD('YourNewPassword'), password_expired = 'N' WHERE User = 'root';
to assign a new password YourNewPassword to root (2).
Doing these steps under OSX 10.11 El Capitan and MySQL 5.7.X, should do the trick.
Considering that you already have MySQL installed then..
Open a terminal window and type:
sudo /usr/local/mysql/support-files/mysql.server stop
sudo mysqld_safe --skip-grant-tables
Since the command fired in the step 2 will be under on going state, you need to open another terminal window and then type:
mysql -u root -p
UPDATE mysql.user SET password_expired='N', authentication_string=PASSWORD('') WHERE User='root';
quit;
sudo /usr/local/mysql/support-files/mysql.server restart
Important: in the step 2 you must replace for your password.
Hope it will wok for you.
MySQL password expired
Resetting the password will solve the problem temporarily, however, from MySQL 5.7.4 to 5.7.10 (I think to encourage better security) the default value for the default_password_lifetime variable is 360 (about a year). For those versions, if you make no changes to this variable (or to individual user accounts) all user passwords expire after 360 days.
Typically, from a script you might get the message: "Your password has expired. To log in you must change it using a client that supports expired passwords."
So, to prevent automatic password expiry, log in as root (mysql -u root -p), then, for clients that automatically connect to the server (e.g. scripts.) change the password expiration settings for those clients:
ALTER USER 'script'#'localhost' PASSWORD EXPIRE NEVER;
or you can disable automatic password expiration for all users:
SET GLOBAL default_password_lifetime = 0;
Links:
MySQL: Password Expiration and Sandbox Mode
MySQL: Password Expiration Policy
Password expiration policy in MySQL Server 5.7
I'm running macOS Sierra(10.12.3) and I installed mysql-5.7.17-macos10.12-x86_64.dmg.
The answer from #lesley worked for me with the exception that I needed to add ./ to ensure I was calling the mysql binary in my current working directory. Which is where the aforementioned package was installed.
If you cd to /usr/local/mysql/bin and run mysql -u root -p --connect-expired-password, you could receive the following error.
mysql: unknown option '--connect-expired-password'
I did. Because simply running mysql without providing a path, called a previously installed version of the MariaDB client.
So to ensure you are executing the correct binary, you can either
provide the absolute path
/usr/local/mysql/bin/mysql -u root -p --connect-expired-password
or the relative path after changing directories
cd /usr/local/mysql/bin
./mysql -u root -p --connect-expired-password
Both ways should work. Once you are connected to the client, the instruction are the same as above from #lesley.
Enter your temporary password generated by the installer and set your new password.
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('yourNewPassword');
I faced the same problem. I followed the installation process guide from https://www.ntu.edu.sg/home/ehchua/programming/sql/MySQL_HowTo.html and downloaded DMG archive and installed MySQL on my MAC OS X 10.12.2.
Finally executed the following commands on new Terminal.
cd /usr/local/mysql/bin
./mysql -u root -p --connect-expired-password
It worked.
Answer 7 worked for me: El capitan, MySQL installed from dmg and autogenerated password, but made sure to cd to /usr/local/bin/mysql before entering ./mysql -root -p Obvious, but I didn't the first time.
Now to find where all my databases and tables are and how to link them in.
For Mysql 5.7 I use
shell $ > sudo grep 'temporary password' /var/log/mysqld.log
This particular one did the trick for me:
As specified in this link: https://www.variphy.com/kb/mac-os-x-reset-mysql-root-password
Do all the steps except executing
UPDATE mysql.user SET Password=PASSWORD('NewPassword') WHERE User='root';
Execute
UPDATE mysql.user
SET authentication_string = PASSWORD('MyNewPass'), password_expired = 'N'
WHERE User = 'root' AND Host = 'localhost';
And then execute
FLUSH PRIVILEGES;
The another way to solve this issue is to use an older version of MySQL instead.
I have uninstalled MySQL version 5.7.9 for Mac OS X 10.9 (x86, 64-bit), DMG Archive and then install the older version, MySQL version 5.6.7 for Mac OS X 10.9 (x86, 64-bit), DMG Archive. This issue is solved. The given autogenerated password before finishing installation of this older version is gone and I can ultimately access the database using root as username and a blank password. Everything is working like a charm!
I installed view brew, and I had the same error message until I noticed this caveat:
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
To connect run:
mysql -uroot
To have launchd start mysql now and restart at login:
brew services start mysql
Or, if you don't want/need a background service you can just run:
mysql.server start
I got around this problem by running
'mysql -u root -p --connect-expired-password'
Then input the expired auto-gen password from mysql. Finally got in. Selected mysql db with
'use mysql'
and then updated user 'root' pw with
'ALTER USER 'root'#'localhost' IDENTIFIED BY 'your new password'
Installing MySQL manually by downloading packages for the first time generates a default password for root. Copy and save that. If not done somehow on successive re-installations it does not show that password.
Thus you cannot login to root.
Do the following :
Find mysql related entries from system
sudo find / -name mysql
Remove all mysql related entries by doing rm -rf <mysql_entries_above>
Download latest mysql-server and intall it.
You will be promted with a default password which you need to copy.
Run mysql_secure_installation and paste that password when asked for root.
Subsequently follow the steps and change admin password when prompted for.
Restarting Mysql server worked for me.
But in Mysql80-Server, it is more complicated than 5.7. In MySQL80 not allow you to update or change password during the config in my.cnf in state "skip grant table". So you need 3 big steps to do
I) change my.cnf to skip-grant-table
II) login MySQL with blank password & update table to blank password
III) restart mysql and login with blank password and update to new password
Step to do: (whatever, you forgot root password, temporary password gen by installation not work, etc. please follow the steps below) In my case on FreeBSD 12.2
stop your mysql server by
/usr/local/etc/rc.d/mysql-server stop
recheck again whether it is really stop (in case more serious problem than that)
/usr/local/etc/rc.d/mysql-server status
mysql is not running.
find your my.cnf file and add "skip-grant-tables" to it.
(normally before [Mysqldump] head)
restart mysql
/usr/local/etc/rc.d/mysql-server start
login to mysql
mysql -u root -p
when it ask for password, just press enter and you will log into mysql
select DB to use
use mysql
look at the table user
select user, authentication_string,password_expired from user;
update to blank password
UPDATE user SET authentication_string = '', password_expired='N' WHERE User = 'root';
quit mysql and make mysql stop
goto file my.cnf then take "skip-grant-tables" out of file.
restart mysql again with "mysql -u root -p" enter the blank password
then
ALTER USER 'root'#'localhost' IDENTIFIED WITH
caching_sha2_password BY 'YourNewPassword';
quit mysql and make mysql stop
restart mysql again then you will login with your new password
This may happens when you have installed mysql before.
Try the password you set for the last version of mysql.
This did work for me.
I've just installed xampp, and am using command line to write mySQL.
I am using 'root' with no password and can connect to mysql but cannot CREATE DATABASE as I get the error 1044 access denied for user '' # 'localhost'. I am logged in as -uroot.
I have privileges in phpMyadmin to do what I want, but, in command line I seem to have no write privileges. I've looked at all the other related posts on this topic but to no avail. I cannot GRANT privileges as I have none anyway.
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
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.
navigate do C:\xampp\mysql\bin\ and make sure the file mysql.exe is in that folder.
mysql -uroot -p
if dont have a password just press enter.
the prompt changes to
mysql>
do your mysql commands
By default there is no password is set for root user in XAMPP.
You can set password for root user of MySQL.
Navigate to
localhost:80/security/index.php
and set password for root user.
Note:Please change the port number in above url if your Apache in on different port.
Open XAMPP control panel Click "Shell" button
Command prompt window will open now in that window type
mysql -u root -p;
It will ask for password type the password which you have set for root user.
There you go ur logged in as root user :D Now do what u want to do :P
Gain access to a MariaDB 10 database server
After stopping the database server, the next step is to gain access to the server through a backdoor by starting the database server and skipping networking and permission tables. This can be done by running the commands below.
sudo mysqld_safe --skip-grant-tables --skip-networking &
Reset MariaDB root Password
Now that the database server is started in safe mode, run the commands below to logon as root without password prompt. To do that, run the commands below
sudo mysql -u root
Then run the commands below to use the mysql database.
use mysql;
Finally, run the commands below to reset the root password.
update user set password=PASSWORD("new_password_here") where User='root';
Replace new_password _here with the new password you want to create for the root account, then press Enter.
After that, run the commands below to update the permissions and save your changes to disk.
flush privileges;
Exit (CTRL + D) and you’re done.
Next start MariaDB normally and test the new password you just created.
sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
Logon to the database by running the commands below.
sudo mysql -u root -p
source: https://websiteforstudents.com/reset-mariadb-root-password-ubuntu-17-04-17-10/
I had the same issue, and it turned out to be that MariaDB was set to allow only root to log in locally via the unix_socket plug-in, so clearing that setting allowed successfully logging in with the user specified on the command line, provided a correct password is entered, of course.
See this answer on Ask Ubuntu
I re-installed the ODBC connector msi and re-installed mySQL directly (aside from xampp) and it now works. It was a connector problem I think, as SHOW DATABASES wasn't actually showing my databases at all.
My 'root' login wasn't getting access to the DB, which made it seem like it had limited priviliges but it actually wasn't connected properly.
Server file only change name folder
etc/mysql
rename
mysql-
this might help on Ubuntu:
go to /etc/mysql/my.cnf and comment this line:
bind-address = 127.0.0.1
Hope this helps someone, I've been searching for this a while too
Cheers
You mustn't have a space character between -u and the username:
mysql -uroot -p
# or
mysql --user=root --password
I have a little problem with my phpmyadmin, in fact I accidentally delete multiple user accounts.
Since it is impossible to connect without the error:
# 1045 - Access denied for user 'root' # 'localhost' (using password: NO)
I have search a little on the net before, and even the technic:
UPDATE mysql.user SET Password = PASSWORD ('') WHERE User = 'root';
FLUSH PRIVILEGES;
does not work, or I didn't understood how it worked.
I'm on FreeBSD 8.1, my version of PhpMyadmin is 2.11.
Thank you in advance for your answers.
I summarised my solution here: http://snippets.dzone.com/posts/show/13267
sudo stop mysql
sudo mysqld --skip-grant-tables --skip-networking
mysql
mysql> update mysql.user set password = password('your_new_password') where user = 'root';
mysql> flush privileges;
mysql> exit;
sudo mysqladmin shutdown
sudo start mysql
For mysql 5.7.16 or later I found this (from mysql.com) to be the working solution. Below are some points which are different compared to previous older versions
1) I used the below command to run mysql in safe mode as per some other references which actually worked fine for me (mysql 5.7.16 ubuntu 16.04).
mysqld_safe --skip-grant-tables --skip-networking
2) The below update stmt is NOT working for later version (ie. 5.7 and above)
-- NOT Working for 5.7 and later
UPDATE mysql.user SET Password = PASSWORD ('') WHERE User = 'root';
FLUSH PRIVILEGES;
INSTEAD use below for 5.7.6 and later
UPDATE mysql.user
SET authentication_string = PASSWORD('MyNewPass'), password_expired = 'N'
WHERE User = 'root' AND Host = 'localhost';
FLUSH PRIVILEGES;
OR user below for 5.7.5 or earlier versions.
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('MyNewPass');
I am Using MySQL Server 8 and this is how I solved this problem.
create a file and name it accordingly. I've named it as reset.txt. put below content in the file but change MyNewPass. This will be your new SQL password
ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass';
Stop my SQL server (Go to services and search MYSQL and right-click on it and stop )
Now open a cmd in your bin folder of My SQLserver directory. in my case it's
C:\Program Files\MySQL\MySQL Server 8.0\bin
execute the following command.
mysqld.exe --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" --init-file="C:\reset.txt'
NOTE: my reset.txt file is in the c drive. Give the correct path. Check my.ini file is in the directory. In my case, it is in
C:\ProgramData\MySQL\MySQL Server 8.0\my.ini
Finally, restart the SQL Server. Check with your new password.
Please follow the instruction from the below link to reset your root password.You have to do it from outside mysql.
Resetting MySql Password
Forgetting your MySQL password can be a real headache for you.Here are some easy steps that you can follow to recover MySql password under Windows
Stop MySql
You have to stop MySql service before you proceed.In Windows environment, go to 'Task Manager' and Under 'Service' tab find MySQL and stop it.
Write Sql to change your password
All you need to do is to create a text file and put the below two lines into that. UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; FLUSH PRIVILEGES; Save it under C:\ drive and give it a name 'mysql-init.txt'
Time to restart MySQL by your own.
Now it's time to restart your MySQl which you stopped in before but this time from command line. C:> C:\mysql\bin\mysqld-nt --init-file=C:\mysql-init.txt
Finishing up!
Now you can log in with your new password. When you finish remove the file that you created in the previous stage.
Also there is a link (http://kaziprogrammingblog.osinweb.com/article/showarticle/Resetting-MySql-Password) where I have explained the same thing.
Hope this will help..:)
Answer for XAMPP on Windows:
Edit C:\xampp\mysql\bin\my.ini and insert skip-grant-tables below [mysqld]
Restart MySQL from Control Panel interface
In the phpMyAdmin window, select SQL tab from the top panel. This will open the SQL tab where we can run the SQL queries. Now type the following query in the text area and click Go
UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root'; FLUSH PRIVILEGES;
Remove the skip-grant-tables in the my.ini file
Restart MySQL from Control Panel interface
DONE!
Be awared that mysql root user password does not have to be the same as password for phpmyadmin.
here is what I did and it worked:
After you install (rpm installation), do a vi /etc/my.cnf.
This will give you a path where your datadir is set. For me it was datadir=/var/lib/mysql.
Add a line there user=root, and remove all the content inside the datadir path: rm -rf /var/lib/mysql/*.
Now hit the command: mysqld --initialize.
A temporary password is generated at a location. For this:
grep "A temporary password" /var/log/*.
You will get a line that says:
/var/log/mysqld.log:2018-05-01T15:13:47.937449Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root#localhost: &uosjoGfi9:K. So for me &uosjoGfi9:K was my temporary password.
Now do a mysql -u root -p. Paste your temporary password from what you got from above.
You will be in your mysql cli mode. Now do:
mysql> use mysql;
You will be asked to reset your password:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
Run your ALTER command:
mysql> ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPswd';
And you are done.
in my case its a frustrating Windows Server installation (iis/php/mysql) so this is what i did:
PART 1: remove the old MYSQL :
NOTE: if you already have data you should back it up!
Step 1
Uninstall MySQL from Control Panel. (you should know how to do this)
Step 2
Run Command Prompt as Admini and execute the following commands to stop and remove MySQL service.
Net stop MySQL
Sc delete MySQL
Step 3
Delete these folders:
C:\Program Files\MySQL
C:\Program Files (x86)\MySQL
C:\ProgramData\MySQL
And if it exists:
C:\Users\[User-Name]\AppData\Roaming\MySQL
PART 2: Install MYSQL
Download installer from https://dev.mysql.com/downloads/installer/ and install
-MySQL Server 8.0.23
open cmd as admin and go to
c:\Program Files\MySQL\MySQL Server 8.0\bin\
run
mysqld --initialize --console
mysqld --install
now start the service (type services.msc in run panel)
now back to console run:
mysql -u root -p
ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass';
that's it
mysql80:
update user SET authentication_string='your password after encode to sha256' where User='root';