ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
I am an electrical engineering who mainly play around with power system instead of programming. Recently, I have been following a manual to install a software suite on Ubuntu. I have no knowledge on mySQL
at all, actually. I have done the following installations on my Ubuntu.
sudo apt-get update
sudo apt-get install mysql-server-5.5
sudo apt-get install mysql-client-5.5
sudo apt-get install mysql-common
sudo apt-get install glade
sudo apt-get install ntp
Then I do
me@ubuntu:~/Desktop/iPDC-v1.3.1/DBServer-1.1$ mysql -uroot -proot <"Db.sql"
I ended up with the following error message.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
How may I fix it and continue?
mysql linux ubuntu
add a comment |
I am an electrical engineering who mainly play around with power system instead of programming. Recently, I have been following a manual to install a software suite on Ubuntu. I have no knowledge on mySQL
at all, actually. I have done the following installations on my Ubuntu.
sudo apt-get update
sudo apt-get install mysql-server-5.5
sudo apt-get install mysql-client-5.5
sudo apt-get install mysql-common
sudo apt-get install glade
sudo apt-get install ntp
Then I do
me@ubuntu:~/Desktop/iPDC-v1.3.1/DBServer-1.1$ mysql -uroot -proot <"Db.sql"
I ended up with the following error message.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
How may I fix it and continue?
mysql linux ubuntu
1
This does not seem to be strictly programming-related to me. I flagged it for migration to SuperUser
– Uli Köhler
Feb 21 '14 at 20:55
add a comment |
I am an electrical engineering who mainly play around with power system instead of programming. Recently, I have been following a manual to install a software suite on Ubuntu. I have no knowledge on mySQL
at all, actually. I have done the following installations on my Ubuntu.
sudo apt-get update
sudo apt-get install mysql-server-5.5
sudo apt-get install mysql-client-5.5
sudo apt-get install mysql-common
sudo apt-get install glade
sudo apt-get install ntp
Then I do
me@ubuntu:~/Desktop/iPDC-v1.3.1/DBServer-1.1$ mysql -uroot -proot <"Db.sql"
I ended up with the following error message.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
How may I fix it and continue?
mysql linux ubuntu
I am an electrical engineering who mainly play around with power system instead of programming. Recently, I have been following a manual to install a software suite on Ubuntu. I have no knowledge on mySQL
at all, actually. I have done the following installations on my Ubuntu.
sudo apt-get update
sudo apt-get install mysql-server-5.5
sudo apt-get install mysql-client-5.5
sudo apt-get install mysql-common
sudo apt-get install glade
sudo apt-get install ntp
Then I do
me@ubuntu:~/Desktop/iPDC-v1.3.1/DBServer-1.1$ mysql -uroot -proot <"Db.sql"
I ended up with the following error message.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
How may I fix it and continue?
mysql linux ubuntu
mysql linux ubuntu
asked Feb 21 '14 at 20:52
Sibbs GamblingSibbs Gambling
5,7592571141
5,7592571141
1
This does not seem to be strictly programming-related to me. I flagged it for migration to SuperUser
– Uli Köhler
Feb 21 '14 at 20:55
add a comment |
1
This does not seem to be strictly programming-related to me. I flagged it for migration to SuperUser
– Uli Köhler
Feb 21 '14 at 20:55
1
1
This does not seem to be strictly programming-related to me. I flagged it for migration to SuperUser
– Uli Köhler
Feb 21 '14 at 20:55
This does not seem to be strictly programming-related to me. I flagged it for migration to SuperUser
– Uli Köhler
Feb 21 '14 at 20:55
add a comment |
19 Answers
19
active
oldest
votes
Note: For MySQL 5.7+ please see answer from @Lahiru to this question. That contains more current information.
For MySQL < 5.7:
The default root password is blank (i.e. empty string) not root
. So you can just login as:
mysql -u root
You should obviously change your root password after installation
mysqladmin -u root password [newpassword]
In most cases you should also set up individual user accounts before working extensively with the DB as well.
4
@FarticlePilter The-p
flag specifies the password, so after you change your root password you would do likemysql -u root -p[newpassword]
. The< [filename]
is using std input to execute an SQL file at the path given via the user credential you provide.
– Mike Brant
Feb 21 '14 at 21:00
11
I tried as toldmysqladmin -u root password abc1234
, but I gotmysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: NO)'
. Thank you so much!
– Sibbs Gambling
Feb 21 '14 at 23:18
2
@Kanagaroo in this question, the OP states they just installed MySQL for the first time and then tried to access via MySQL command line client. That sounds like first time access to me.
– Mike Brant
Dec 13 '14 at 13:17
17
Actually for mysql community server 5.7, the default root password is randomly generated when you install. Check your /var/log/mysqld.log for a line talking about a "temporary password". Saves hours of messing around.
– Phil
Jan 8 '16 at 10:04
1
@BraianMellor This does solve the problem for MySQL < 5.7 in that the default (post-installation) root password on Ubuntu is blank (no password), where in the original question the poster was trying to use root/root. The question was not about lost password, changing password, or similar. For newer versions of MySQL the other answer I referenced is the correct one, as a user must look in the error logs to see the randomly-generated root password.
– Mike Brant
Jul 25 '17 at 19:36
|
show 8 more comments
I was able to solve this problem by executing this statement
sudo dpkg-reconfigure mysql-server-5.5
Which will change the root password.
7
Just what I needed... but not everyone has version 5.5 of server. usedpkg --get-selections | grep sql
to get your version
– Balmipour
Sep 10 '15 at 11:18
1
@Balmipour what should be the equivalent command to check the sql version in Rhel 6.x
– PrathamN
Sep 12 '15 at 4:00
@Divz what should be the command to reconfigure mysql server in Rhel/centos
– PrathamN
Sep 12 '15 at 4:03
@PrathamN I never used red had, but googling for "red hat check packages versions" gives me commands like this one :yum list installed
add| grep sql
to filter only SQL packages.
– Balmipour
Sep 12 '15 at 11:22
When I run this command in Mac OS X, I get this error:sudo: dpkg-reconfigure: command not found
. Any suggestion?
– mOna
Mar 14 '16 at 16:08
|
show 2 more comments
You have to reset the password! steps for mac osx(tested and working) and ubuntu
Stop MySQL using
sudo service mysql stop
or
$ sudo /usr/local/mysql/support-files/mysql.server stop
Start it in safe mode:
$ sudo mysqld_safe --skip-grant-tables --skip-networking
(above line is the whole command)
This will be an ongoing command until the process is finished so open another shell/terminal window, log in without a password:
$ mysql -u root
mysql> UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';
As per @IberoMedia's comment, for newer versions of MySQL, the field is called authentication_string
:
mysql> UPDATE mysql.user SET authentication_string =PASSWORD('password') WHERE User='root';
Start MySQL using:
sudo service mysql start
or
sudo /usr/local/mysql/support-files/mysql.server start
your new password is 'password'.
2
Please, NOT that way ! @Divz's answer is more secure. Quoting the doc about --skip-grant-tables : This enables anyone to connect without a password and with all privileges [...] Because this is insecure, [...] use--skip-grant-tables
in conjunction with--skip-networking
to prevent remote clients from connecting. oh, and also, this one didn't work for me. Thats why I came here :p
– Balmipour
Sep 10 '15 at 12:16
1
If you go that way, yes. It didn't work for me, and following @Divz's answer seems way easier to me, anyway--
What I would suggest is usingdpkg --get-selections | grep mysql-server-
to get your exact MySQL version, then go for sudo dpkg-reconfigure mysql-server-5.x (replace 5.x with your server version, btw). I commented @Divz's answer with this precision, but it's masked by the several "thanks" comments.
– Balmipour
Sep 10 '15 at 16:13
4
update user set authentication_string=password('1111') where user='root';
– Dejell
Dec 17 '15 at 20:51
2
This actually worked...the other solutions still gave me the same error.
– eddy147
Jan 1 '17 at 16:49
1
I've to change the commandsudo mysql restart
forsudo service mysql restart
, and it worked like a charm.'I've edited your post.
– eifersucht
Oct 27 '17 at 9:39
|
show 4 more comments
if the problem still exists try to force changing the pass
/etc/init.d/mysql stop
mysqld_safe --skip-grant-tables &
mysql -u root
Setup new MySQL root user password
use mysql;
update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
flush privileges;
quit;
Stop MySQL Server:
/etc/init.d/mysql stop
Start MySQL server and test it:
mysql -u root -p
1
Thank you.ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
was also plaguing my server. 'mysqld_safe' also failed until I did a 'killall mysqld' AFTER your Step 1.
– Marcos
Aug 29 '14 at 10:09
Please, NOT that way ! @Divz's answer is more secure. Quoting the doc about --skip-grant-tables: This enables anyone to connect without a password and with all privileges [...] Because this is insecure, [...] use--skip-grant-tables
in conjunction with--skip-networking
to prevent remote clients from connecting. oh, and also, this one didn't work for me. Thats why I came here :p
– Balmipour
Sep 10 '15 at 12:19
2
Its giving me: ERROR 1054 (42S22): Unknown column 'password' in 'field list'
– MD. Mohiuddin Ahmed
Dec 7 '15 at 12:15
Check answer by @Anshu it's more secure way of handling this
– Mugoma J. Okomba
Aug 29 '16 at 7:23
For me, the mysql version is 5.6+, and the OS is centOS6.5, I should use the/etc/init.d/mysqld stop
not/etc/init.d/mysql stop
.
– StrongYoung
Apr 12 '17 at 1:28
add a comment |
At the initial start up of the server the following happens, given that the data directory of the server is empty:
- The server is initialized.
- SSL certificate and key files are generated in the data directory.
- The validate_password plugin is installed and enabled.
- The superuser account 'root'@'localhost' is created. The password for the superuser is set and stored in the error log file.
To reveal it, use the following command:
shell> sudo grep 'temporary password' /var/log/mysqld.log
Change the root password as soon as possible by logging in with the generated temporary password and set a custom password for the superuser account:
shell> mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass5!';
6
This looked promising, but it doesn't work for me. When I runsudo grep 'temporary password' /var/log/mysqld.log
I get/var/log/mysqld.log: No such file or directory
– Eric Hepperle - CodeSlayer2010
Apr 20 '17 at 16:17
3
Trysudo grep 'temporary password' /var/log/mysql/error.log
. @Lahiru solution worked for me.
– artemisian
Jun 9 '17 at 21:26
11
I tried sudo grep 'temporary password' /var/log/mysql/error.log but it returns nothing.
– learner
Aug 22 '17 at 16:53
1
Tryshell> sudo grep 'password' /var/log/mysql/error.log
. Worked for me, but I get: root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option. My mysql version is: Ver 8.0.13 for Linux on x86_64 (MySQL Community Server - GPL)
– kaspiotr
Nov 18 '18 at 0:11
add a comment |
I know this an old Question but i feel this might help someone. I was recently faced with the same problem but in my case, i remember my password quite alright but it kept on giving me the same error. I tried so many solutions but still none helped then i tried this
mysql -u root -p
after which it asks you for a pass word like this
Enter password:
and then i typed in the password i used. That's all
Funny that this helped after days of research.
– girish_vr
Aug 11 '18 at 9:31
Nice to know @girish_vr
– XY-JOE
Aug 12 '18 at 13:23
Worked for me! My mysql-server version is: Server version: 8.0.13 MySQL Community Server - GPL
– kaspiotr
Nov 18 '18 at 1:21
add a comment |
It happens when your password is missing.
Steps to change password when you have forgotten:
Stop MySQL Server (on Linux):
sudo systemctl stop mysql
Start the database without loading the grant tables or enabling networking:
sudo mysqld_safe --skip-grant-tables --skip-networking &
The ampersand at the end of this command will make this process run in the
background so you can continue to use your terminal and run #mysql -u root, it will not ask for password.
If you get error like as below:
2018-02-12T08:57:39.826071Z mysqld_safe Directory '/var/run/mysqld' for UNIX
socket file don't exists.
mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (2)
[1]+ Exit 1
Make MySQL service directory.
sudo mkdir /var/run/mysqld
Give MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqld
Run the same command in step 2 to run mysql in background.
Run mysql -u root you will get mysql console without entering password.
Run these commands
FLUSH PRIVILEGES;
For MySQL 5.7.6 and newer
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
For MySQL 5.7.5 and older
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new_password');
If the ALTER USER command doesn't work use:
UPDATE mysql.user SET authentication_string = PASSWORD('new_password') WHERE User = 'root' AND Host = 'localhost';
Now exit
To stop instance started manually
sudo kill `cat /var/run/mysqld/mysqld.pid`
Restart mysql
sudo systemctl start mysql
In my case, I have to modify the Step 6 assudo kill `sudo cat /var/run/mysqld/mysqld.pid`
– kolunar
Nov 29 '18 at 10:25
This is the one that worked for me. In step 5, do 1. use USER 2. To change password use --> update user set authentication_string = PASSWORD("password") where User='root';
– Bikram
Jan 12 at 8:35
add a comment |
Am using Ubuntu-16.04 : installed mysql - 5.7.
I Had the same issue : Login denied for root user.
Tried the below steps:
dpkg --get-selections | grep mysql
(to get the version of mysql).dpkg-reconfigure mysql-server-5.7
mysql -u root -p
Without -p that doesn't prompt you to ask password. Once you are in, you can create a user with a password by following steps :
CREATE USER 'your_new_username'@'your-hostname' IDENTIFIED BY 'your-password';
GRANT ALL PRIVILEGES ON *.* to 'your_new_username'@'your-hostname' WITH GRANT OPTION;
Exit from the root and login from the you gave above.
mysql -u <your_new_username> -p
For some reason still just typing mysql does not work. AT ALL. I suggest to make it a habit to use mysql -u <name> -p
.
add a comment |
I came across this very annoying problem and found many answers that did not work. The best solution I came across was to completely uninstall mysql and re-install it. On re-install you set a root password and this fixed the problem.
sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-5.5 mysql-client-core-5.5
sudo rm -rf /etc/mysql /var/lib/mysql
sudo apt-get autoremove
sudo apt-get autoclean
I found this code elsewhere so I take no credit for it. But it works.
To install mysql after uninstalling it I think digital ocean has a good tutorial on it. Checkout my gist for this.
https://gist.github.com/JamesDaniel/c02ef210c17c1dec82fc973cac484096
Works on Raspberry Pi too :)
– CodingYourLife
Apr 12 '17 at 22:18
add a comment |
Please read the official documentation: Mysql: How to Reset the Root Password
If you have access to terminal:
MySQL 5.7.6 and later:
$ mysql
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
MySQL 5.7.5 and earlier:
$ mysql
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
1
Gives : ERROR 1131 (42000): You are using MySQL as an anonymous user and anonymous users are not allowed to change passwords
– MD. Mohiuddin Ahmed
Dec 7 '15 at 12:19
1
It's normal. Your user is anonymous. You need to execute> mysql -u {your_username}
– d.danailov
Dec 7 '15 at 16:22
add a comment |
I am using mysql-5.7.12-osx10.11-x86_64.dmg in Mac OSX
The installation process automatically sets up a temporary password for root user. You should save the password. The password can not be recovered.
Follow the instruction
- Go to
cd /usr/local/mysql/bin/
- Enter the temporary password (which would look something like, "tsO07JF1=>3")
- You should get mysql> prompt.
- Run,
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('{YOUR_PASSWORD}');
If you wish to set your password: "root" then the command would be,SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root');
- Run
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
- Run
exit
- Run
./mysql -u root -p
- Type your password. In my case I would type, "root" (without quote)
- That's all.
For convenience, you should add "/usr/local/mysql/bin"
to your PATH
Now from anywhere you can type ./mysql -u root -p
and then type the password and you will get mysql> prompt.
Hope it helps.
add a comment |
The answer may sound silly, but after wasting hours of time, this is how I got it to work
mysql -u root -p
I got the error message
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Even though I was typing the correct password(the temporary password you get when you first install mysql)
I got it right when I typed in the password when the password prompt was blinking
add a comment |
if the problem still exists try to force changing the pass
Stop MySQL Server (on Linux):
/etc/init.d/mysql stop
Stop MySQL Server (on Mac OS X):
mysql.server stop
Start mysqld_safe daemon with --skip-grant-tables
mysqld_safe --skip-grant-tables &
mysql -u root
Setup new MySQL root user password
use mysql;
update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
flush privileges;
quit;
Stop MySQL Server (on Linux):
/etc/init.d/mysql stop
Stop MySQL Server (on Mac OS X):
mysql.server stop
Start MySQL server service and test to login by root:
mysql -u root -p
add a comment |
Just one line and it solved my issue.
sudo dpkg-reconfigure mysql-server-5.5
add a comment |
In Ubuntu 16.04 (MySQL version 5.7.13) I was able to resolve the problem with the steps below:
Follow the instructions from the in section B.5.3.2.2 Resetting the Root Password: Unix and Unix-Like Systems
MySQL 5.7 reference manual
When I tried #sudo mysqld_safe --init-file=/home/me/mysql-init & it failed. The error was in /var/log/mysql/error.log
2016-08-10T11:41:20.421946Z 0 [Note] Execution of init_file '/home/me/mysql/mysql-init' started.
2016-08-10T11:41:20.422070Z 0 [ERROR] /usr/sbin/mysqld: File '/home/me/mysql/mysql-init' not found (Errcode: 13 - Permission denied)
2016-08-10T11:41:20.422096Z 0 [ERROR] Aborting
The file permission of mysql-init was not the problem, need to edit apparmor permission
Edit by #sudo vi /etc/apparmor.d/usr.sbin.mysqld
....
/var/log/mysql/ r,
/var/log/mysql/** rw,
# Allow user init file
/home/pranab/mysql/* r,
# Site-specific additions and overrides. See local/README for details.
#include <local/usr.sbin.mysqld>
}
Do #sudo /etc/init.d/apparmor reload
Start mysqld_safe again try step 2 above. Check /var/log/mysql/error.log make sure there is no error and the mysqld is successfully started
Run #mysql -u root -p
Enter password:
Enter the password that you specified in mysql-init. You should be able to log in as root now.
Shutdown mysqld_safe by #sudo mysqladmin -u root -p shutdown
Start mysqld normal way by #sudo systemctl start mysql
add a comment |
BY default password will be null, so you have to change password by doing below steps.
connect to mysql
root# mysql
Use mysql
mysql> update user set password=PASSWORD('root') where User='root';
Finally, reload the privileges:
mysql> flush privileges;
mysql> quit
add a comment |
In recent MySQL versions there is no password
in mysql.user
table.
So you need to execute ALTER USER
. Put this one line command into the file.
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
And execute it as init file (as root or mysql user)
mysqld_safe --init-file=/home/me/mysql-init &
MySQL server need to be stopped to start mysqld_safe
.
Also, there may be a problem with apparmor permissions to load this init file. Read more here
https://blogs.oracle.com/jsmyth/entry/apparmor_and_mysql
add a comment |
If you haven't set password yet, then run mysql -uroot
, it works for me.
add a comment |
On Mac, If you have a problem in logging in with the first password you were given in installation, maybe you can just simply kill the mysql process and then try.
So:
1- run the following command to find the PID of mysql:
ps -aef | grep mysql | grep -v grep
2- kill the process:
kill -15 [process id]
Then you can login with the initial password using this command:
mysql -uroot -p
Which ask you to enter your password. Just enter the initial password.
add a comment |
protected by Community♦ Oct 18 '14 at 4:03
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
19 Answers
19
active
oldest
votes
19 Answers
19
active
oldest
votes
active
oldest
votes
active
oldest
votes
Note: For MySQL 5.7+ please see answer from @Lahiru to this question. That contains more current information.
For MySQL < 5.7:
The default root password is blank (i.e. empty string) not root
. So you can just login as:
mysql -u root
You should obviously change your root password after installation
mysqladmin -u root password [newpassword]
In most cases you should also set up individual user accounts before working extensively with the DB as well.
4
@FarticlePilter The-p
flag specifies the password, so after you change your root password you would do likemysql -u root -p[newpassword]
. The< [filename]
is using std input to execute an SQL file at the path given via the user credential you provide.
– Mike Brant
Feb 21 '14 at 21:00
11
I tried as toldmysqladmin -u root password abc1234
, but I gotmysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: NO)'
. Thank you so much!
– Sibbs Gambling
Feb 21 '14 at 23:18
2
@Kanagaroo in this question, the OP states they just installed MySQL for the first time and then tried to access via MySQL command line client. That sounds like first time access to me.
– Mike Brant
Dec 13 '14 at 13:17
17
Actually for mysql community server 5.7, the default root password is randomly generated when you install. Check your /var/log/mysqld.log for a line talking about a "temporary password". Saves hours of messing around.
– Phil
Jan 8 '16 at 10:04
1
@BraianMellor This does solve the problem for MySQL < 5.7 in that the default (post-installation) root password on Ubuntu is blank (no password), where in the original question the poster was trying to use root/root. The question was not about lost password, changing password, or similar. For newer versions of MySQL the other answer I referenced is the correct one, as a user must look in the error logs to see the randomly-generated root password.
– Mike Brant
Jul 25 '17 at 19:36
|
show 8 more comments
Note: For MySQL 5.7+ please see answer from @Lahiru to this question. That contains more current information.
For MySQL < 5.7:
The default root password is blank (i.e. empty string) not root
. So you can just login as:
mysql -u root
You should obviously change your root password after installation
mysqladmin -u root password [newpassword]
In most cases you should also set up individual user accounts before working extensively with the DB as well.
4
@FarticlePilter The-p
flag specifies the password, so after you change your root password you would do likemysql -u root -p[newpassword]
. The< [filename]
is using std input to execute an SQL file at the path given via the user credential you provide.
– Mike Brant
Feb 21 '14 at 21:00
11
I tried as toldmysqladmin -u root password abc1234
, but I gotmysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: NO)'
. Thank you so much!
– Sibbs Gambling
Feb 21 '14 at 23:18
2
@Kanagaroo in this question, the OP states they just installed MySQL for the first time and then tried to access via MySQL command line client. That sounds like first time access to me.
– Mike Brant
Dec 13 '14 at 13:17
17
Actually for mysql community server 5.7, the default root password is randomly generated when you install. Check your /var/log/mysqld.log for a line talking about a "temporary password". Saves hours of messing around.
– Phil
Jan 8 '16 at 10:04
1
@BraianMellor This does solve the problem for MySQL < 5.7 in that the default (post-installation) root password on Ubuntu is blank (no password), where in the original question the poster was trying to use root/root. The question was not about lost password, changing password, or similar. For newer versions of MySQL the other answer I referenced is the correct one, as a user must look in the error logs to see the randomly-generated root password.
– Mike Brant
Jul 25 '17 at 19:36
|
show 8 more comments
Note: For MySQL 5.7+ please see answer from @Lahiru to this question. That contains more current information.
For MySQL < 5.7:
The default root password is blank (i.e. empty string) not root
. So you can just login as:
mysql -u root
You should obviously change your root password after installation
mysqladmin -u root password [newpassword]
In most cases you should also set up individual user accounts before working extensively with the DB as well.
Note: For MySQL 5.7+ please see answer from @Lahiru to this question. That contains more current information.
For MySQL < 5.7:
The default root password is blank (i.e. empty string) not root
. So you can just login as:
mysql -u root
You should obviously change your root password after installation
mysqladmin -u root password [newpassword]
In most cases you should also set up individual user accounts before working extensively with the DB as well.
edited Apr 16 '18 at 21:54
answered Feb 21 '14 at 20:54
Mike BrantMike Brant
60k86885
60k86885
4
@FarticlePilter The-p
flag specifies the password, so after you change your root password you would do likemysql -u root -p[newpassword]
. The< [filename]
is using std input to execute an SQL file at the path given via the user credential you provide.
– Mike Brant
Feb 21 '14 at 21:00
11
I tried as toldmysqladmin -u root password abc1234
, but I gotmysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: NO)'
. Thank you so much!
– Sibbs Gambling
Feb 21 '14 at 23:18
2
@Kanagaroo in this question, the OP states they just installed MySQL for the first time and then tried to access via MySQL command line client. That sounds like first time access to me.
– Mike Brant
Dec 13 '14 at 13:17
17
Actually for mysql community server 5.7, the default root password is randomly generated when you install. Check your /var/log/mysqld.log for a line talking about a "temporary password". Saves hours of messing around.
– Phil
Jan 8 '16 at 10:04
1
@BraianMellor This does solve the problem for MySQL < 5.7 in that the default (post-installation) root password on Ubuntu is blank (no password), where in the original question the poster was trying to use root/root. The question was not about lost password, changing password, or similar. For newer versions of MySQL the other answer I referenced is the correct one, as a user must look in the error logs to see the randomly-generated root password.
– Mike Brant
Jul 25 '17 at 19:36
|
show 8 more comments
4
@FarticlePilter The-p
flag specifies the password, so after you change your root password you would do likemysql -u root -p[newpassword]
. The< [filename]
is using std input to execute an SQL file at the path given via the user credential you provide.
– Mike Brant
Feb 21 '14 at 21:00
11
I tried as toldmysqladmin -u root password abc1234
, but I gotmysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: NO)'
. Thank you so much!
– Sibbs Gambling
Feb 21 '14 at 23:18
2
@Kanagaroo in this question, the OP states they just installed MySQL for the first time and then tried to access via MySQL command line client. That sounds like first time access to me.
– Mike Brant
Dec 13 '14 at 13:17
17
Actually for mysql community server 5.7, the default root password is randomly generated when you install. Check your /var/log/mysqld.log for a line talking about a "temporary password". Saves hours of messing around.
– Phil
Jan 8 '16 at 10:04
1
@BraianMellor This does solve the problem for MySQL < 5.7 in that the default (post-installation) root password on Ubuntu is blank (no password), where in the original question the poster was trying to use root/root. The question was not about lost password, changing password, or similar. For newer versions of MySQL the other answer I referenced is the correct one, as a user must look in the error logs to see the randomly-generated root password.
– Mike Brant
Jul 25 '17 at 19:36
4
4
@FarticlePilter The
-p
flag specifies the password, so after you change your root password you would do like mysql -u root -p[newpassword]
. The < [filename]
is using std input to execute an SQL file at the path given via the user credential you provide.– Mike Brant
Feb 21 '14 at 21:00
@FarticlePilter The
-p
flag specifies the password, so after you change your root password you would do like mysql -u root -p[newpassword]
. The < [filename]
is using std input to execute an SQL file at the path given via the user credential you provide.– Mike Brant
Feb 21 '14 at 21:00
11
11
I tried as told
mysqladmin -u root password abc1234
, but I got mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: NO)'
. Thank you so much!– Sibbs Gambling
Feb 21 '14 at 23:18
I tried as told
mysqladmin -u root password abc1234
, but I got mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: NO)'
. Thank you so much!– Sibbs Gambling
Feb 21 '14 at 23:18
2
2
@Kanagaroo in this question, the OP states they just installed MySQL for the first time and then tried to access via MySQL command line client. That sounds like first time access to me.
– Mike Brant
Dec 13 '14 at 13:17
@Kanagaroo in this question, the OP states they just installed MySQL for the first time and then tried to access via MySQL command line client. That sounds like first time access to me.
– Mike Brant
Dec 13 '14 at 13:17
17
17
Actually for mysql community server 5.7, the default root password is randomly generated when you install. Check your /var/log/mysqld.log for a line talking about a "temporary password". Saves hours of messing around.
– Phil
Jan 8 '16 at 10:04
Actually for mysql community server 5.7, the default root password is randomly generated when you install. Check your /var/log/mysqld.log for a line talking about a "temporary password". Saves hours of messing around.
– Phil
Jan 8 '16 at 10:04
1
1
@BraianMellor This does solve the problem for MySQL < 5.7 in that the default (post-installation) root password on Ubuntu is blank (no password), where in the original question the poster was trying to use root/root. The question was not about lost password, changing password, or similar. For newer versions of MySQL the other answer I referenced is the correct one, as a user must look in the error logs to see the randomly-generated root password.
– Mike Brant
Jul 25 '17 at 19:36
@BraianMellor This does solve the problem for MySQL < 5.7 in that the default (post-installation) root password on Ubuntu is blank (no password), where in the original question the poster was trying to use root/root. The question was not about lost password, changing password, or similar. For newer versions of MySQL the other answer I referenced is the correct one, as a user must look in the error logs to see the randomly-generated root password.
– Mike Brant
Jul 25 '17 at 19:36
|
show 8 more comments
I was able to solve this problem by executing this statement
sudo dpkg-reconfigure mysql-server-5.5
Which will change the root password.
7
Just what I needed... but not everyone has version 5.5 of server. usedpkg --get-selections | grep sql
to get your version
– Balmipour
Sep 10 '15 at 11:18
1
@Balmipour what should be the equivalent command to check the sql version in Rhel 6.x
– PrathamN
Sep 12 '15 at 4:00
@Divz what should be the command to reconfigure mysql server in Rhel/centos
– PrathamN
Sep 12 '15 at 4:03
@PrathamN I never used red had, but googling for "red hat check packages versions" gives me commands like this one :yum list installed
add| grep sql
to filter only SQL packages.
– Balmipour
Sep 12 '15 at 11:22
When I run this command in Mac OS X, I get this error:sudo: dpkg-reconfigure: command not found
. Any suggestion?
– mOna
Mar 14 '16 at 16:08
|
show 2 more comments
I was able to solve this problem by executing this statement
sudo dpkg-reconfigure mysql-server-5.5
Which will change the root password.
7
Just what I needed... but not everyone has version 5.5 of server. usedpkg --get-selections | grep sql
to get your version
– Balmipour
Sep 10 '15 at 11:18
1
@Balmipour what should be the equivalent command to check the sql version in Rhel 6.x
– PrathamN
Sep 12 '15 at 4:00
@Divz what should be the command to reconfigure mysql server in Rhel/centos
– PrathamN
Sep 12 '15 at 4:03
@PrathamN I never used red had, but googling for "red hat check packages versions" gives me commands like this one :yum list installed
add| grep sql
to filter only SQL packages.
– Balmipour
Sep 12 '15 at 11:22
When I run this command in Mac OS X, I get this error:sudo: dpkg-reconfigure: command not found
. Any suggestion?
– mOna
Mar 14 '16 at 16:08
|
show 2 more comments
I was able to solve this problem by executing this statement
sudo dpkg-reconfigure mysql-server-5.5
Which will change the root password.
I was able to solve this problem by executing this statement
sudo dpkg-reconfigure mysql-server-5.5
Which will change the root password.
edited May 10 '14 at 14:48
JJD
25.3k35152253
25.3k35152253
answered Mar 18 '14 at 3:37
DivzDivz
1,305286
1,305286
7
Just what I needed... but not everyone has version 5.5 of server. usedpkg --get-selections | grep sql
to get your version
– Balmipour
Sep 10 '15 at 11:18
1
@Balmipour what should be the equivalent command to check the sql version in Rhel 6.x
– PrathamN
Sep 12 '15 at 4:00
@Divz what should be the command to reconfigure mysql server in Rhel/centos
– PrathamN
Sep 12 '15 at 4:03
@PrathamN I never used red had, but googling for "red hat check packages versions" gives me commands like this one :yum list installed
add| grep sql
to filter only SQL packages.
– Balmipour
Sep 12 '15 at 11:22
When I run this command in Mac OS X, I get this error:sudo: dpkg-reconfigure: command not found
. Any suggestion?
– mOna
Mar 14 '16 at 16:08
|
show 2 more comments
7
Just what I needed... but not everyone has version 5.5 of server. usedpkg --get-selections | grep sql
to get your version
– Balmipour
Sep 10 '15 at 11:18
1
@Balmipour what should be the equivalent command to check the sql version in Rhel 6.x
– PrathamN
Sep 12 '15 at 4:00
@Divz what should be the command to reconfigure mysql server in Rhel/centos
– PrathamN
Sep 12 '15 at 4:03
@PrathamN I never used red had, but googling for "red hat check packages versions" gives me commands like this one :yum list installed
add| grep sql
to filter only SQL packages.
– Balmipour
Sep 12 '15 at 11:22
When I run this command in Mac OS X, I get this error:sudo: dpkg-reconfigure: command not found
. Any suggestion?
– mOna
Mar 14 '16 at 16:08
7
7
Just what I needed... but not everyone has version 5.5 of server. use
dpkg --get-selections | grep sql
to get your version– Balmipour
Sep 10 '15 at 11:18
Just what I needed... but not everyone has version 5.5 of server. use
dpkg --get-selections | grep sql
to get your version– Balmipour
Sep 10 '15 at 11:18
1
1
@Balmipour what should be the equivalent command to check the sql version in Rhel 6.x
– PrathamN
Sep 12 '15 at 4:00
@Balmipour what should be the equivalent command to check the sql version in Rhel 6.x
– PrathamN
Sep 12 '15 at 4:00
@Divz what should be the command to reconfigure mysql server in Rhel/centos
– PrathamN
Sep 12 '15 at 4:03
@Divz what should be the command to reconfigure mysql server in Rhel/centos
– PrathamN
Sep 12 '15 at 4:03
@PrathamN I never used red had, but googling for "red hat check packages versions" gives me commands like this one :
yum list installed
add | grep sql
to filter only SQL packages.– Balmipour
Sep 12 '15 at 11:22
@PrathamN I never used red had, but googling for "red hat check packages versions" gives me commands like this one :
yum list installed
add | grep sql
to filter only SQL packages.– Balmipour
Sep 12 '15 at 11:22
When I run this command in Mac OS X, I get this error:
sudo: dpkg-reconfigure: command not found
. Any suggestion?– mOna
Mar 14 '16 at 16:08
When I run this command in Mac OS X, I get this error:
sudo: dpkg-reconfigure: command not found
. Any suggestion?– mOna
Mar 14 '16 at 16:08
|
show 2 more comments
You have to reset the password! steps for mac osx(tested and working) and ubuntu
Stop MySQL using
sudo service mysql stop
or
$ sudo /usr/local/mysql/support-files/mysql.server stop
Start it in safe mode:
$ sudo mysqld_safe --skip-grant-tables --skip-networking
(above line is the whole command)
This will be an ongoing command until the process is finished so open another shell/terminal window, log in without a password:
$ mysql -u root
mysql> UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';
As per @IberoMedia's comment, for newer versions of MySQL, the field is called authentication_string
:
mysql> UPDATE mysql.user SET authentication_string =PASSWORD('password') WHERE User='root';
Start MySQL using:
sudo service mysql start
or
sudo /usr/local/mysql/support-files/mysql.server start
your new password is 'password'.
2
Please, NOT that way ! @Divz's answer is more secure. Quoting the doc about --skip-grant-tables : This enables anyone to connect without a password and with all privileges [...] Because this is insecure, [...] use--skip-grant-tables
in conjunction with--skip-networking
to prevent remote clients from connecting. oh, and also, this one didn't work for me. Thats why I came here :p
– Balmipour
Sep 10 '15 at 12:16
1
If you go that way, yes. It didn't work for me, and following @Divz's answer seems way easier to me, anyway--
What I would suggest is usingdpkg --get-selections | grep mysql-server-
to get your exact MySQL version, then go for sudo dpkg-reconfigure mysql-server-5.x (replace 5.x with your server version, btw). I commented @Divz's answer with this precision, but it's masked by the several "thanks" comments.
– Balmipour
Sep 10 '15 at 16:13
4
update user set authentication_string=password('1111') where user='root';
– Dejell
Dec 17 '15 at 20:51
2
This actually worked...the other solutions still gave me the same error.
– eddy147
Jan 1 '17 at 16:49
1
I've to change the commandsudo mysql restart
forsudo service mysql restart
, and it worked like a charm.'I've edited your post.
– eifersucht
Oct 27 '17 at 9:39
|
show 4 more comments
You have to reset the password! steps for mac osx(tested and working) and ubuntu
Stop MySQL using
sudo service mysql stop
or
$ sudo /usr/local/mysql/support-files/mysql.server stop
Start it in safe mode:
$ sudo mysqld_safe --skip-grant-tables --skip-networking
(above line is the whole command)
This will be an ongoing command until the process is finished so open another shell/terminal window, log in without a password:
$ mysql -u root
mysql> UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';
As per @IberoMedia's comment, for newer versions of MySQL, the field is called authentication_string
:
mysql> UPDATE mysql.user SET authentication_string =PASSWORD('password') WHERE User='root';
Start MySQL using:
sudo service mysql start
or
sudo /usr/local/mysql/support-files/mysql.server start
your new password is 'password'.
2
Please, NOT that way ! @Divz's answer is more secure. Quoting the doc about --skip-grant-tables : This enables anyone to connect without a password and with all privileges [...] Because this is insecure, [...] use--skip-grant-tables
in conjunction with--skip-networking
to prevent remote clients from connecting. oh, and also, this one didn't work for me. Thats why I came here :p
– Balmipour
Sep 10 '15 at 12:16
1
If you go that way, yes. It didn't work for me, and following @Divz's answer seems way easier to me, anyway--
What I would suggest is usingdpkg --get-selections | grep mysql-server-
to get your exact MySQL version, then go for sudo dpkg-reconfigure mysql-server-5.x (replace 5.x with your server version, btw). I commented @Divz's answer with this precision, but it's masked by the several "thanks" comments.
– Balmipour
Sep 10 '15 at 16:13
4
update user set authentication_string=password('1111') where user='root';
– Dejell
Dec 17 '15 at 20:51
2
This actually worked...the other solutions still gave me the same error.
– eddy147
Jan 1 '17 at 16:49
1
I've to change the commandsudo mysql restart
forsudo service mysql restart
, and it worked like a charm.'I've edited your post.
– eifersucht
Oct 27 '17 at 9:39
|
show 4 more comments
You have to reset the password! steps for mac osx(tested and working) and ubuntu
Stop MySQL using
sudo service mysql stop
or
$ sudo /usr/local/mysql/support-files/mysql.server stop
Start it in safe mode:
$ sudo mysqld_safe --skip-grant-tables --skip-networking
(above line is the whole command)
This will be an ongoing command until the process is finished so open another shell/terminal window, log in without a password:
$ mysql -u root
mysql> UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';
As per @IberoMedia's comment, for newer versions of MySQL, the field is called authentication_string
:
mysql> UPDATE mysql.user SET authentication_string =PASSWORD('password') WHERE User='root';
Start MySQL using:
sudo service mysql start
or
sudo /usr/local/mysql/support-files/mysql.server start
your new password is 'password'.
You have to reset the password! steps for mac osx(tested and working) and ubuntu
Stop MySQL using
sudo service mysql stop
or
$ sudo /usr/local/mysql/support-files/mysql.server stop
Start it in safe mode:
$ sudo mysqld_safe --skip-grant-tables --skip-networking
(above line is the whole command)
This will be an ongoing command until the process is finished so open another shell/terminal window, log in without a password:
$ mysql -u root
mysql> UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';
As per @IberoMedia's comment, for newer versions of MySQL, the field is called authentication_string
:
mysql> UPDATE mysql.user SET authentication_string =PASSWORD('password') WHERE User='root';
Start MySQL using:
sudo service mysql start
or
sudo /usr/local/mysql/support-files/mysql.server start
your new password is 'password'.
edited Nov 7 '18 at 16:29
Peter K.
6,28644164
6,28644164
answered Sep 17 '14 at 6:44
tk_tk_
7,63824962
7,63824962
2
Please, NOT that way ! @Divz's answer is more secure. Quoting the doc about --skip-grant-tables : This enables anyone to connect without a password and with all privileges [...] Because this is insecure, [...] use--skip-grant-tables
in conjunction with--skip-networking
to prevent remote clients from connecting. oh, and also, this one didn't work for me. Thats why I came here :p
– Balmipour
Sep 10 '15 at 12:16
1
If you go that way, yes. It didn't work for me, and following @Divz's answer seems way easier to me, anyway--
What I would suggest is usingdpkg --get-selections | grep mysql-server-
to get your exact MySQL version, then go for sudo dpkg-reconfigure mysql-server-5.x (replace 5.x with your server version, btw). I commented @Divz's answer with this precision, but it's masked by the several "thanks" comments.
– Balmipour
Sep 10 '15 at 16:13
4
update user set authentication_string=password('1111') where user='root';
– Dejell
Dec 17 '15 at 20:51
2
This actually worked...the other solutions still gave me the same error.
– eddy147
Jan 1 '17 at 16:49
1
I've to change the commandsudo mysql restart
forsudo service mysql restart
, and it worked like a charm.'I've edited your post.
– eifersucht
Oct 27 '17 at 9:39
|
show 4 more comments
2
Please, NOT that way ! @Divz's answer is more secure. Quoting the doc about --skip-grant-tables : This enables anyone to connect without a password and with all privileges [...] Because this is insecure, [...] use--skip-grant-tables
in conjunction with--skip-networking
to prevent remote clients from connecting. oh, and also, this one didn't work for me. Thats why I came here :p
– Balmipour
Sep 10 '15 at 12:16
1
If you go that way, yes. It didn't work for me, and following @Divz's answer seems way easier to me, anyway--
What I would suggest is usingdpkg --get-selections | grep mysql-server-
to get your exact MySQL version, then go for sudo dpkg-reconfigure mysql-server-5.x (replace 5.x with your server version, btw). I commented @Divz's answer with this precision, but it's masked by the several "thanks" comments.
– Balmipour
Sep 10 '15 at 16:13
4
update user set authentication_string=password('1111') where user='root';
– Dejell
Dec 17 '15 at 20:51
2
This actually worked...the other solutions still gave me the same error.
– eddy147
Jan 1 '17 at 16:49
1
I've to change the commandsudo mysql restart
forsudo service mysql restart
, and it worked like a charm.'I've edited your post.
– eifersucht
Oct 27 '17 at 9:39
2
2
Please, NOT that way ! @Divz's answer is more secure. Quoting the doc about --skip-grant-tables : This enables anyone to connect without a password and with all privileges [...] Because this is insecure, [...] use
--skip-grant-tables
in conjunction with --skip-networking
to prevent remote clients from connecting. oh, and also, this one didn't work for me. Thats why I came here :p– Balmipour
Sep 10 '15 at 12:16
Please, NOT that way ! @Divz's answer is more secure. Quoting the doc about --skip-grant-tables : This enables anyone to connect without a password and with all privileges [...] Because this is insecure, [...] use
--skip-grant-tables
in conjunction with --skip-networking
to prevent remote clients from connecting. oh, and also, this one didn't work for me. Thats why I came here :p– Balmipour
Sep 10 '15 at 12:16
1
1
If you go that way, yes. It didn't work for me, and following @Divz's answer seems way easier to me, anyway
--
What I would suggest is using dpkg --get-selections | grep mysql-server-
to get your exact MySQL version, then go for sudo dpkg-reconfigure mysql-server-5.x (replace 5.x with your server version, btw). I commented @Divz's answer with this precision, but it's masked by the several "thanks" comments.– Balmipour
Sep 10 '15 at 16:13
If you go that way, yes. It didn't work for me, and following @Divz's answer seems way easier to me, anyway
--
What I would suggest is using dpkg --get-selections | grep mysql-server-
to get your exact MySQL version, then go for sudo dpkg-reconfigure mysql-server-5.x (replace 5.x with your server version, btw). I commented @Divz's answer with this precision, but it's masked by the several "thanks" comments.– Balmipour
Sep 10 '15 at 16:13
4
4
update user set authentication_string=password('1111') where user='root';
– Dejell
Dec 17 '15 at 20:51
update user set authentication_string=password('1111') where user='root';
– Dejell
Dec 17 '15 at 20:51
2
2
This actually worked...the other solutions still gave me the same error.
– eddy147
Jan 1 '17 at 16:49
This actually worked...the other solutions still gave me the same error.
– eddy147
Jan 1 '17 at 16:49
1
1
I've to change the command
sudo mysql restart
for sudo service mysql restart
, and it worked like a charm.'I've edited your post.– eifersucht
Oct 27 '17 at 9:39
I've to change the command
sudo mysql restart
for sudo service mysql restart
, and it worked like a charm.'I've edited your post.– eifersucht
Oct 27 '17 at 9:39
|
show 4 more comments
if the problem still exists try to force changing the pass
/etc/init.d/mysql stop
mysqld_safe --skip-grant-tables &
mysql -u root
Setup new MySQL root user password
use mysql;
update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
flush privileges;
quit;
Stop MySQL Server:
/etc/init.d/mysql stop
Start MySQL server and test it:
mysql -u root -p
1
Thank you.ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
was also plaguing my server. 'mysqld_safe' also failed until I did a 'killall mysqld' AFTER your Step 1.
– Marcos
Aug 29 '14 at 10:09
Please, NOT that way ! @Divz's answer is more secure. Quoting the doc about --skip-grant-tables: This enables anyone to connect without a password and with all privileges [...] Because this is insecure, [...] use--skip-grant-tables
in conjunction with--skip-networking
to prevent remote clients from connecting. oh, and also, this one didn't work for me. Thats why I came here :p
– Balmipour
Sep 10 '15 at 12:19
2
Its giving me: ERROR 1054 (42S22): Unknown column 'password' in 'field list'
– MD. Mohiuddin Ahmed
Dec 7 '15 at 12:15
Check answer by @Anshu it's more secure way of handling this
– Mugoma J. Okomba
Aug 29 '16 at 7:23
For me, the mysql version is 5.6+, and the OS is centOS6.5, I should use the/etc/init.d/mysqld stop
not/etc/init.d/mysql stop
.
– StrongYoung
Apr 12 '17 at 1:28
add a comment |
if the problem still exists try to force changing the pass
/etc/init.d/mysql stop
mysqld_safe --skip-grant-tables &
mysql -u root
Setup new MySQL root user password
use mysql;
update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
flush privileges;
quit;
Stop MySQL Server:
/etc/init.d/mysql stop
Start MySQL server and test it:
mysql -u root -p
1
Thank you.ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
was also plaguing my server. 'mysqld_safe' also failed until I did a 'killall mysqld' AFTER your Step 1.
– Marcos
Aug 29 '14 at 10:09
Please, NOT that way ! @Divz's answer is more secure. Quoting the doc about --skip-grant-tables: This enables anyone to connect without a password and with all privileges [...] Because this is insecure, [...] use--skip-grant-tables
in conjunction with--skip-networking
to prevent remote clients from connecting. oh, and also, this one didn't work for me. Thats why I came here :p
– Balmipour
Sep 10 '15 at 12:19
2
Its giving me: ERROR 1054 (42S22): Unknown column 'password' in 'field list'
– MD. Mohiuddin Ahmed
Dec 7 '15 at 12:15
Check answer by @Anshu it's more secure way of handling this
– Mugoma J. Okomba
Aug 29 '16 at 7:23
For me, the mysql version is 5.6+, and the OS is centOS6.5, I should use the/etc/init.d/mysqld stop
not/etc/init.d/mysql stop
.
– StrongYoung
Apr 12 '17 at 1:28
add a comment |
if the problem still exists try to force changing the pass
/etc/init.d/mysql stop
mysqld_safe --skip-grant-tables &
mysql -u root
Setup new MySQL root user password
use mysql;
update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
flush privileges;
quit;
Stop MySQL Server:
/etc/init.d/mysql stop
Start MySQL server and test it:
mysql -u root -p
if the problem still exists try to force changing the pass
/etc/init.d/mysql stop
mysqld_safe --skip-grant-tables &
mysql -u root
Setup new MySQL root user password
use mysql;
update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
flush privileges;
quit;
Stop MySQL Server:
/etc/init.d/mysql stop
Start MySQL server and test it:
mysql -u root -p
edited Jun 4 '16 at 18:28
Silvio Delgado
5,17921219
5,17921219
answered May 20 '14 at 13:34
Yasin HassanienYasin Hassanien
3,36111513
3,36111513
1
Thank you.ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
was also plaguing my server. 'mysqld_safe' also failed until I did a 'killall mysqld' AFTER your Step 1.
– Marcos
Aug 29 '14 at 10:09
Please, NOT that way ! @Divz's answer is more secure. Quoting the doc about --skip-grant-tables: This enables anyone to connect without a password and with all privileges [...] Because this is insecure, [...] use--skip-grant-tables
in conjunction with--skip-networking
to prevent remote clients from connecting. oh, and also, this one didn't work for me. Thats why I came here :p
– Balmipour
Sep 10 '15 at 12:19
2
Its giving me: ERROR 1054 (42S22): Unknown column 'password' in 'field list'
– MD. Mohiuddin Ahmed
Dec 7 '15 at 12:15
Check answer by @Anshu it's more secure way of handling this
– Mugoma J. Okomba
Aug 29 '16 at 7:23
For me, the mysql version is 5.6+, and the OS is centOS6.5, I should use the/etc/init.d/mysqld stop
not/etc/init.d/mysql stop
.
– StrongYoung
Apr 12 '17 at 1:28
add a comment |
1
Thank you.ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
was also plaguing my server. 'mysqld_safe' also failed until I did a 'killall mysqld' AFTER your Step 1.
– Marcos
Aug 29 '14 at 10:09
Please, NOT that way ! @Divz's answer is more secure. Quoting the doc about --skip-grant-tables: This enables anyone to connect without a password and with all privileges [...] Because this is insecure, [...] use--skip-grant-tables
in conjunction with--skip-networking
to prevent remote clients from connecting. oh, and also, this one didn't work for me. Thats why I came here :p
– Balmipour
Sep 10 '15 at 12:19
2
Its giving me: ERROR 1054 (42S22): Unknown column 'password' in 'field list'
– MD. Mohiuddin Ahmed
Dec 7 '15 at 12:15
Check answer by @Anshu it's more secure way of handling this
– Mugoma J. Okomba
Aug 29 '16 at 7:23
For me, the mysql version is 5.6+, and the OS is centOS6.5, I should use the/etc/init.d/mysqld stop
not/etc/init.d/mysql stop
.
– StrongYoung
Apr 12 '17 at 1:28
1
1
Thank you.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
was also plaguing my server. 'mysqld_safe' also failed until I did a 'killall mysqld' AFTER your Step 1.– Marcos
Aug 29 '14 at 10:09
Thank you.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
was also plaguing my server. 'mysqld_safe' also failed until I did a 'killall mysqld' AFTER your Step 1.– Marcos
Aug 29 '14 at 10:09
Please, NOT that way ! @Divz's answer is more secure. Quoting the doc about --skip-grant-tables: This enables anyone to connect without a password and with all privileges [...] Because this is insecure, [...] use
--skip-grant-tables
in conjunction with --skip-networking
to prevent remote clients from connecting. oh, and also, this one didn't work for me. Thats why I came here :p– Balmipour
Sep 10 '15 at 12:19
Please, NOT that way ! @Divz's answer is more secure. Quoting the doc about --skip-grant-tables: This enables anyone to connect without a password and with all privileges [...] Because this is insecure, [...] use
--skip-grant-tables
in conjunction with --skip-networking
to prevent remote clients from connecting. oh, and also, this one didn't work for me. Thats why I came here :p– Balmipour
Sep 10 '15 at 12:19
2
2
Its giving me: ERROR 1054 (42S22): Unknown column 'password' in 'field list'
– MD. Mohiuddin Ahmed
Dec 7 '15 at 12:15
Its giving me: ERROR 1054 (42S22): Unknown column 'password' in 'field list'
– MD. Mohiuddin Ahmed
Dec 7 '15 at 12:15
Check answer by @Anshu it's more secure way of handling this
– Mugoma J. Okomba
Aug 29 '16 at 7:23
Check answer by @Anshu it's more secure way of handling this
– Mugoma J. Okomba
Aug 29 '16 at 7:23
For me, the mysql version is 5.6+, and the OS is centOS6.5, I should use the
/etc/init.d/mysqld stop
not /etc/init.d/mysql stop
.– StrongYoung
Apr 12 '17 at 1:28
For me, the mysql version is 5.6+, and the OS is centOS6.5, I should use the
/etc/init.d/mysqld stop
not /etc/init.d/mysql stop
.– StrongYoung
Apr 12 '17 at 1:28
add a comment |
At the initial start up of the server the following happens, given that the data directory of the server is empty:
- The server is initialized.
- SSL certificate and key files are generated in the data directory.
- The validate_password plugin is installed and enabled.
- The superuser account 'root'@'localhost' is created. The password for the superuser is set and stored in the error log file.
To reveal it, use the following command:
shell> sudo grep 'temporary password' /var/log/mysqld.log
Change the root password as soon as possible by logging in with the generated temporary password and set a custom password for the superuser account:
shell> mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass5!';
6
This looked promising, but it doesn't work for me. When I runsudo grep 'temporary password' /var/log/mysqld.log
I get/var/log/mysqld.log: No such file or directory
– Eric Hepperle - CodeSlayer2010
Apr 20 '17 at 16:17
3
Trysudo grep 'temporary password' /var/log/mysql/error.log
. @Lahiru solution worked for me.
– artemisian
Jun 9 '17 at 21:26
11
I tried sudo grep 'temporary password' /var/log/mysql/error.log but it returns nothing.
– learner
Aug 22 '17 at 16:53
1
Tryshell> sudo grep 'password' /var/log/mysql/error.log
. Worked for me, but I get: root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option. My mysql version is: Ver 8.0.13 for Linux on x86_64 (MySQL Community Server - GPL)
– kaspiotr
Nov 18 '18 at 0:11
add a comment |
At the initial start up of the server the following happens, given that the data directory of the server is empty:
- The server is initialized.
- SSL certificate and key files are generated in the data directory.
- The validate_password plugin is installed and enabled.
- The superuser account 'root'@'localhost' is created. The password for the superuser is set and stored in the error log file.
To reveal it, use the following command:
shell> sudo grep 'temporary password' /var/log/mysqld.log
Change the root password as soon as possible by logging in with the generated temporary password and set a custom password for the superuser account:
shell> mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass5!';
6
This looked promising, but it doesn't work for me. When I runsudo grep 'temporary password' /var/log/mysqld.log
I get/var/log/mysqld.log: No such file or directory
– Eric Hepperle - CodeSlayer2010
Apr 20 '17 at 16:17
3
Trysudo grep 'temporary password' /var/log/mysql/error.log
. @Lahiru solution worked for me.
– artemisian
Jun 9 '17 at 21:26
11
I tried sudo grep 'temporary password' /var/log/mysql/error.log but it returns nothing.
– learner
Aug 22 '17 at 16:53
1
Tryshell> sudo grep 'password' /var/log/mysql/error.log
. Worked for me, but I get: root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option. My mysql version is: Ver 8.0.13 for Linux on x86_64 (MySQL Community Server - GPL)
– kaspiotr
Nov 18 '18 at 0:11
add a comment |
At the initial start up of the server the following happens, given that the data directory of the server is empty:
- The server is initialized.
- SSL certificate and key files are generated in the data directory.
- The validate_password plugin is installed and enabled.
- The superuser account 'root'@'localhost' is created. The password for the superuser is set and stored in the error log file.
To reveal it, use the following command:
shell> sudo grep 'temporary password' /var/log/mysqld.log
Change the root password as soon as possible by logging in with the generated temporary password and set a custom password for the superuser account:
shell> mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass5!';
At the initial start up of the server the following happens, given that the data directory of the server is empty:
- The server is initialized.
- SSL certificate and key files are generated in the data directory.
- The validate_password plugin is installed and enabled.
- The superuser account 'root'@'localhost' is created. The password for the superuser is set and stored in the error log file.
To reveal it, use the following command:
shell> sudo grep 'temporary password' /var/log/mysqld.log
Change the root password as soon as possible by logging in with the generated temporary password and set a custom password for the superuser account:
shell> mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass5!';
answered Mar 23 '17 at 5:17
LahiruLahiru
497514
497514
6
This looked promising, but it doesn't work for me. When I runsudo grep 'temporary password' /var/log/mysqld.log
I get/var/log/mysqld.log: No such file or directory
– Eric Hepperle - CodeSlayer2010
Apr 20 '17 at 16:17
3
Trysudo grep 'temporary password' /var/log/mysql/error.log
. @Lahiru solution worked for me.
– artemisian
Jun 9 '17 at 21:26
11
I tried sudo grep 'temporary password' /var/log/mysql/error.log but it returns nothing.
– learner
Aug 22 '17 at 16:53
1
Tryshell> sudo grep 'password' /var/log/mysql/error.log
. Worked for me, but I get: root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option. My mysql version is: Ver 8.0.13 for Linux on x86_64 (MySQL Community Server - GPL)
– kaspiotr
Nov 18 '18 at 0:11
add a comment |
6
This looked promising, but it doesn't work for me. When I runsudo grep 'temporary password' /var/log/mysqld.log
I get/var/log/mysqld.log: No such file or directory
– Eric Hepperle - CodeSlayer2010
Apr 20 '17 at 16:17
3
Trysudo grep 'temporary password' /var/log/mysql/error.log
. @Lahiru solution worked for me.
– artemisian
Jun 9 '17 at 21:26
11
I tried sudo grep 'temporary password' /var/log/mysql/error.log but it returns nothing.
– learner
Aug 22 '17 at 16:53
1
Tryshell> sudo grep 'password' /var/log/mysql/error.log
. Worked for me, but I get: root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option. My mysql version is: Ver 8.0.13 for Linux on x86_64 (MySQL Community Server - GPL)
– kaspiotr
Nov 18 '18 at 0:11
6
6
This looked promising, but it doesn't work for me. When I run
sudo grep 'temporary password' /var/log/mysqld.log
I get /var/log/mysqld.log: No such file or directory
– Eric Hepperle - CodeSlayer2010
Apr 20 '17 at 16:17
This looked promising, but it doesn't work for me. When I run
sudo grep 'temporary password' /var/log/mysqld.log
I get /var/log/mysqld.log: No such file or directory
– Eric Hepperle - CodeSlayer2010
Apr 20 '17 at 16:17
3
3
Try
sudo grep 'temporary password' /var/log/mysql/error.log
. @Lahiru solution worked for me.– artemisian
Jun 9 '17 at 21:26
Try
sudo grep 'temporary password' /var/log/mysql/error.log
. @Lahiru solution worked for me.– artemisian
Jun 9 '17 at 21:26
11
11
I tried sudo grep 'temporary password' /var/log/mysql/error.log but it returns nothing.
– learner
Aug 22 '17 at 16:53
I tried sudo grep 'temporary password' /var/log/mysql/error.log but it returns nothing.
– learner
Aug 22 '17 at 16:53
1
1
Try
shell> sudo grep 'password' /var/log/mysql/error.log
. Worked for me, but I get: root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option. My mysql version is: Ver 8.0.13 for Linux on x86_64 (MySQL Community Server - GPL)– kaspiotr
Nov 18 '18 at 0:11
Try
shell> sudo grep 'password' /var/log/mysql/error.log
. Worked for me, but I get: root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option. My mysql version is: Ver 8.0.13 for Linux on x86_64 (MySQL Community Server - GPL)– kaspiotr
Nov 18 '18 at 0:11
add a comment |
I know this an old Question but i feel this might help someone. I was recently faced with the same problem but in my case, i remember my password quite alright but it kept on giving me the same error. I tried so many solutions but still none helped then i tried this
mysql -u root -p
after which it asks you for a pass word like this
Enter password:
and then i typed in the password i used. That's all
Funny that this helped after days of research.
– girish_vr
Aug 11 '18 at 9:31
Nice to know @girish_vr
– XY-JOE
Aug 12 '18 at 13:23
Worked for me! My mysql-server version is: Server version: 8.0.13 MySQL Community Server - GPL
– kaspiotr
Nov 18 '18 at 1:21
add a comment |
I know this an old Question but i feel this might help someone. I was recently faced with the same problem but in my case, i remember my password quite alright but it kept on giving me the same error. I tried so many solutions but still none helped then i tried this
mysql -u root -p
after which it asks you for a pass word like this
Enter password:
and then i typed in the password i used. That's all
Funny that this helped after days of research.
– girish_vr
Aug 11 '18 at 9:31
Nice to know @girish_vr
– XY-JOE
Aug 12 '18 at 13:23
Worked for me! My mysql-server version is: Server version: 8.0.13 MySQL Community Server - GPL
– kaspiotr
Nov 18 '18 at 1:21
add a comment |
I know this an old Question but i feel this might help someone. I was recently faced with the same problem but in my case, i remember my password quite alright but it kept on giving me the same error. I tried so many solutions but still none helped then i tried this
mysql -u root -p
after which it asks you for a pass word like this
Enter password:
and then i typed in the password i used. That's all
I know this an old Question but i feel this might help someone. I was recently faced with the same problem but in my case, i remember my password quite alright but it kept on giving me the same error. I tried so many solutions but still none helped then i tried this
mysql -u root -p
after which it asks you for a pass word like this
Enter password:
and then i typed in the password i used. That's all
answered Mar 21 '18 at 22:22
XY-JOEXY-JOE
25537
25537
Funny that this helped after days of research.
– girish_vr
Aug 11 '18 at 9:31
Nice to know @girish_vr
– XY-JOE
Aug 12 '18 at 13:23
Worked for me! My mysql-server version is: Server version: 8.0.13 MySQL Community Server - GPL
– kaspiotr
Nov 18 '18 at 1:21
add a comment |
Funny that this helped after days of research.
– girish_vr
Aug 11 '18 at 9:31
Nice to know @girish_vr
– XY-JOE
Aug 12 '18 at 13:23
Worked for me! My mysql-server version is: Server version: 8.0.13 MySQL Community Server - GPL
– kaspiotr
Nov 18 '18 at 1:21
Funny that this helped after days of research.
– girish_vr
Aug 11 '18 at 9:31
Funny that this helped after days of research.
– girish_vr
Aug 11 '18 at 9:31
Nice to know @girish_vr
– XY-JOE
Aug 12 '18 at 13:23
Nice to know @girish_vr
– XY-JOE
Aug 12 '18 at 13:23
Worked for me! My mysql-server version is: Server version: 8.0.13 MySQL Community Server - GPL
– kaspiotr
Nov 18 '18 at 1:21
Worked for me! My mysql-server version is: Server version: 8.0.13 MySQL Community Server - GPL
– kaspiotr
Nov 18 '18 at 1:21
add a comment |
It happens when your password is missing.
Steps to change password when you have forgotten:
Stop MySQL Server (on Linux):
sudo systemctl stop mysql
Start the database without loading the grant tables or enabling networking:
sudo mysqld_safe --skip-grant-tables --skip-networking &
The ampersand at the end of this command will make this process run in the
background so you can continue to use your terminal and run #mysql -u root, it will not ask for password.
If you get error like as below:
2018-02-12T08:57:39.826071Z mysqld_safe Directory '/var/run/mysqld' for UNIX
socket file don't exists.
mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (2)
[1]+ Exit 1
Make MySQL service directory.
sudo mkdir /var/run/mysqld
Give MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqld
Run the same command in step 2 to run mysql in background.
Run mysql -u root you will get mysql console without entering password.
Run these commands
FLUSH PRIVILEGES;
For MySQL 5.7.6 and newer
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
For MySQL 5.7.5 and older
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new_password');
If the ALTER USER command doesn't work use:
UPDATE mysql.user SET authentication_string = PASSWORD('new_password') WHERE User = 'root' AND Host = 'localhost';
Now exit
To stop instance started manually
sudo kill `cat /var/run/mysqld/mysqld.pid`
Restart mysql
sudo systemctl start mysql
In my case, I have to modify the Step 6 assudo kill `sudo cat /var/run/mysqld/mysqld.pid`
– kolunar
Nov 29 '18 at 10:25
This is the one that worked for me. In step 5, do 1. use USER 2. To change password use --> update user set authentication_string = PASSWORD("password") where User='root';
– Bikram
Jan 12 at 8:35
add a comment |
It happens when your password is missing.
Steps to change password when you have forgotten:
Stop MySQL Server (on Linux):
sudo systemctl stop mysql
Start the database without loading the grant tables or enabling networking:
sudo mysqld_safe --skip-grant-tables --skip-networking &
The ampersand at the end of this command will make this process run in the
background so you can continue to use your terminal and run #mysql -u root, it will not ask for password.
If you get error like as below:
2018-02-12T08:57:39.826071Z mysqld_safe Directory '/var/run/mysqld' for UNIX
socket file don't exists.
mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (2)
[1]+ Exit 1
Make MySQL service directory.
sudo mkdir /var/run/mysqld
Give MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqld
Run the same command in step 2 to run mysql in background.
Run mysql -u root you will get mysql console without entering password.
Run these commands
FLUSH PRIVILEGES;
For MySQL 5.7.6 and newer
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
For MySQL 5.7.5 and older
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new_password');
If the ALTER USER command doesn't work use:
UPDATE mysql.user SET authentication_string = PASSWORD('new_password') WHERE User = 'root' AND Host = 'localhost';
Now exit
To stop instance started manually
sudo kill `cat /var/run/mysqld/mysqld.pid`
Restart mysql
sudo systemctl start mysql
In my case, I have to modify the Step 6 assudo kill `sudo cat /var/run/mysqld/mysqld.pid`
– kolunar
Nov 29 '18 at 10:25
This is the one that worked for me. In step 5, do 1. use USER 2. To change password use --> update user set authentication_string = PASSWORD("password") where User='root';
– Bikram
Jan 12 at 8:35
add a comment |
It happens when your password is missing.
Steps to change password when you have forgotten:
Stop MySQL Server (on Linux):
sudo systemctl stop mysql
Start the database without loading the grant tables or enabling networking:
sudo mysqld_safe --skip-grant-tables --skip-networking &
The ampersand at the end of this command will make this process run in the
background so you can continue to use your terminal and run #mysql -u root, it will not ask for password.
If you get error like as below:
2018-02-12T08:57:39.826071Z mysqld_safe Directory '/var/run/mysqld' for UNIX
socket file don't exists.
mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (2)
[1]+ Exit 1
Make MySQL service directory.
sudo mkdir /var/run/mysqld
Give MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqld
Run the same command in step 2 to run mysql in background.
Run mysql -u root you will get mysql console without entering password.
Run these commands
FLUSH PRIVILEGES;
For MySQL 5.7.6 and newer
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
For MySQL 5.7.5 and older
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new_password');
If the ALTER USER command doesn't work use:
UPDATE mysql.user SET authentication_string = PASSWORD('new_password') WHERE User = 'root' AND Host = 'localhost';
Now exit
To stop instance started manually
sudo kill `cat /var/run/mysqld/mysqld.pid`
Restart mysql
sudo systemctl start mysql
It happens when your password is missing.
Steps to change password when you have forgotten:
Stop MySQL Server (on Linux):
sudo systemctl stop mysql
Start the database without loading the grant tables or enabling networking:
sudo mysqld_safe --skip-grant-tables --skip-networking &
The ampersand at the end of this command will make this process run in the
background so you can continue to use your terminal and run #mysql -u root, it will not ask for password.
If you get error like as below:
2018-02-12T08:57:39.826071Z mysqld_safe Directory '/var/run/mysqld' for UNIX
socket file don't exists.
mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (2)
[1]+ Exit 1
Make MySQL service directory.
sudo mkdir /var/run/mysqld
Give MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqld
Run the same command in step 2 to run mysql in background.
Run mysql -u root you will get mysql console without entering password.
Run these commands
FLUSH PRIVILEGES;
For MySQL 5.7.6 and newer
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
For MySQL 5.7.5 and older
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new_password');
If the ALTER USER command doesn't work use:
UPDATE mysql.user SET authentication_string = PASSWORD('new_password') WHERE User = 'root' AND Host = 'localhost';
Now exit
To stop instance started manually
sudo kill `cat /var/run/mysqld/mysqld.pid`
Restart mysql
sudo systemctl start mysql
edited Feb 12 '18 at 14:50
Moritz
57.8k19132184
57.8k19132184
answered Feb 12 '18 at 14:25
SameerSameer
15916
15916
In my case, I have to modify the Step 6 assudo kill `sudo cat /var/run/mysqld/mysqld.pid`
– kolunar
Nov 29 '18 at 10:25
This is the one that worked for me. In step 5, do 1. use USER 2. To change password use --> update user set authentication_string = PASSWORD("password") where User='root';
– Bikram
Jan 12 at 8:35
add a comment |
In my case, I have to modify the Step 6 assudo kill `sudo cat /var/run/mysqld/mysqld.pid`
– kolunar
Nov 29 '18 at 10:25
This is the one that worked for me. In step 5, do 1. use USER 2. To change password use --> update user set authentication_string = PASSWORD("password") where User='root';
– Bikram
Jan 12 at 8:35
In my case, I have to modify the Step 6 as
sudo kill `sudo cat /var/run/mysqld/mysqld.pid`
– kolunar
Nov 29 '18 at 10:25
In my case, I have to modify the Step 6 as
sudo kill `sudo cat /var/run/mysqld/mysqld.pid`
– kolunar
Nov 29 '18 at 10:25
This is the one that worked for me. In step 5, do 1. use USER 2. To change password use --> update user set authentication_string = PASSWORD("password") where User='root';
– Bikram
Jan 12 at 8:35
This is the one that worked for me. In step 5, do 1. use USER 2. To change password use --> update user set authentication_string = PASSWORD("password") where User='root';
– Bikram
Jan 12 at 8:35
add a comment |
Am using Ubuntu-16.04 : installed mysql - 5.7.
I Had the same issue : Login denied for root user.
Tried the below steps:
dpkg --get-selections | grep mysql
(to get the version of mysql).dpkg-reconfigure mysql-server-5.7
mysql -u root -p
Without -p that doesn't prompt you to ask password. Once you are in, you can create a user with a password by following steps :
CREATE USER 'your_new_username'@'your-hostname' IDENTIFIED BY 'your-password';
GRANT ALL PRIVILEGES ON *.* to 'your_new_username'@'your-hostname' WITH GRANT OPTION;
Exit from the root and login from the you gave above.
mysql -u <your_new_username> -p
For some reason still just typing mysql does not work. AT ALL. I suggest to make it a habit to use mysql -u <name> -p
.
add a comment |
Am using Ubuntu-16.04 : installed mysql - 5.7.
I Had the same issue : Login denied for root user.
Tried the below steps:
dpkg --get-selections | grep mysql
(to get the version of mysql).dpkg-reconfigure mysql-server-5.7
mysql -u root -p
Without -p that doesn't prompt you to ask password. Once you are in, you can create a user with a password by following steps :
CREATE USER 'your_new_username'@'your-hostname' IDENTIFIED BY 'your-password';
GRANT ALL PRIVILEGES ON *.* to 'your_new_username'@'your-hostname' WITH GRANT OPTION;
Exit from the root and login from the you gave above.
mysql -u <your_new_username> -p
For some reason still just typing mysql does not work. AT ALL. I suggest to make it a habit to use mysql -u <name> -p
.
add a comment |
Am using Ubuntu-16.04 : installed mysql - 5.7.
I Had the same issue : Login denied for root user.
Tried the below steps:
dpkg --get-selections | grep mysql
(to get the version of mysql).dpkg-reconfigure mysql-server-5.7
mysql -u root -p
Without -p that doesn't prompt you to ask password. Once you are in, you can create a user with a password by following steps :
CREATE USER 'your_new_username'@'your-hostname' IDENTIFIED BY 'your-password';
GRANT ALL PRIVILEGES ON *.* to 'your_new_username'@'your-hostname' WITH GRANT OPTION;
Exit from the root and login from the you gave above.
mysql -u <your_new_username> -p
For some reason still just typing mysql does not work. AT ALL. I suggest to make it a habit to use mysql -u <name> -p
.
Am using Ubuntu-16.04 : installed mysql - 5.7.
I Had the same issue : Login denied for root user.
Tried the below steps:
dpkg --get-selections | grep mysql
(to get the version of mysql).dpkg-reconfigure mysql-server-5.7
mysql -u root -p
Without -p that doesn't prompt you to ask password. Once you are in, you can create a user with a password by following steps :
CREATE USER 'your_new_username'@'your-hostname' IDENTIFIED BY 'your-password';
GRANT ALL PRIVILEGES ON *.* to 'your_new_username'@'your-hostname' WITH GRANT OPTION;
Exit from the root and login from the you gave above.
mysql -u <your_new_username> -p
For some reason still just typing mysql does not work. AT ALL. I suggest to make it a habit to use mysql -u <name> -p
.
edited Jan 19 at 9:25
Zoe
11.6k74379
11.6k74379
answered Jun 21 '17 at 15:21
Nikhil RushmithNikhil Rushmith
15114
15114
add a comment |
add a comment |
I came across this very annoying problem and found many answers that did not work. The best solution I came across was to completely uninstall mysql and re-install it. On re-install you set a root password and this fixed the problem.
sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-5.5 mysql-client-core-5.5
sudo rm -rf /etc/mysql /var/lib/mysql
sudo apt-get autoremove
sudo apt-get autoclean
I found this code elsewhere so I take no credit for it. But it works.
To install mysql after uninstalling it I think digital ocean has a good tutorial on it. Checkout my gist for this.
https://gist.github.com/JamesDaniel/c02ef210c17c1dec82fc973cac484096
Works on Raspberry Pi too :)
– CodingYourLife
Apr 12 '17 at 22:18
add a comment |
I came across this very annoying problem and found many answers that did not work. The best solution I came across was to completely uninstall mysql and re-install it. On re-install you set a root password and this fixed the problem.
sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-5.5 mysql-client-core-5.5
sudo rm -rf /etc/mysql /var/lib/mysql
sudo apt-get autoremove
sudo apt-get autoclean
I found this code elsewhere so I take no credit for it. But it works.
To install mysql after uninstalling it I think digital ocean has a good tutorial on it. Checkout my gist for this.
https://gist.github.com/JamesDaniel/c02ef210c17c1dec82fc973cac484096
Works on Raspberry Pi too :)
– CodingYourLife
Apr 12 '17 at 22:18
add a comment |
I came across this very annoying problem and found many answers that did not work. The best solution I came across was to completely uninstall mysql and re-install it. On re-install you set a root password and this fixed the problem.
sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-5.5 mysql-client-core-5.5
sudo rm -rf /etc/mysql /var/lib/mysql
sudo apt-get autoremove
sudo apt-get autoclean
I found this code elsewhere so I take no credit for it. But it works.
To install mysql after uninstalling it I think digital ocean has a good tutorial on it. Checkout my gist for this.
https://gist.github.com/JamesDaniel/c02ef210c17c1dec82fc973cac484096
I came across this very annoying problem and found many answers that did not work. The best solution I came across was to completely uninstall mysql and re-install it. On re-install you set a root password and this fixed the problem.
sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-5.5 mysql-client-core-5.5
sudo rm -rf /etc/mysql /var/lib/mysql
sudo apt-get autoremove
sudo apt-get autoclean
I found this code elsewhere so I take no credit for it. But it works.
To install mysql after uninstalling it I think digital ocean has a good tutorial on it. Checkout my gist for this.
https://gist.github.com/JamesDaniel/c02ef210c17c1dec82fc973cac484096
edited Jan 19 at 9:24
Zoe
11.6k74379
11.6k74379
answered Feb 9 '17 at 21:05
JamesDJamesD
32639
32639
Works on Raspberry Pi too :)
– CodingYourLife
Apr 12 '17 at 22:18
add a comment |
Works on Raspberry Pi too :)
– CodingYourLife
Apr 12 '17 at 22:18
Works on Raspberry Pi too :)
– CodingYourLife
Apr 12 '17 at 22:18
Works on Raspberry Pi too :)
– CodingYourLife
Apr 12 '17 at 22:18
add a comment |
Please read the official documentation: Mysql: How to Reset the Root Password
If you have access to terminal:
MySQL 5.7.6 and later:
$ mysql
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
MySQL 5.7.5 and earlier:
$ mysql
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
1
Gives : ERROR 1131 (42000): You are using MySQL as an anonymous user and anonymous users are not allowed to change passwords
– MD. Mohiuddin Ahmed
Dec 7 '15 at 12:19
1
It's normal. Your user is anonymous. You need to execute> mysql -u {your_username}
– d.danailov
Dec 7 '15 at 16:22
add a comment |
Please read the official documentation: Mysql: How to Reset the Root Password
If you have access to terminal:
MySQL 5.7.6 and later:
$ mysql
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
MySQL 5.7.5 and earlier:
$ mysql
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
1
Gives : ERROR 1131 (42000): You are using MySQL as an anonymous user and anonymous users are not allowed to change passwords
– MD. Mohiuddin Ahmed
Dec 7 '15 at 12:19
1
It's normal. Your user is anonymous. You need to execute> mysql -u {your_username}
– d.danailov
Dec 7 '15 at 16:22
add a comment |
Please read the official documentation: Mysql: How to Reset the Root Password
If you have access to terminal:
MySQL 5.7.6 and later:
$ mysql
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
MySQL 5.7.5 and earlier:
$ mysql
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
Please read the official documentation: Mysql: How to Reset the Root Password
If you have access to terminal:
MySQL 5.7.6 and later:
$ mysql
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
MySQL 5.7.5 and earlier:
$ mysql
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
edited Mar 27 '17 at 14:46
answered Aug 10 '15 at 10:05
d.danailovd.danailov
7,11444231
7,11444231
1
Gives : ERROR 1131 (42000): You are using MySQL as an anonymous user and anonymous users are not allowed to change passwords
– MD. Mohiuddin Ahmed
Dec 7 '15 at 12:19
1
It's normal. Your user is anonymous. You need to execute> mysql -u {your_username}
– d.danailov
Dec 7 '15 at 16:22
add a comment |
1
Gives : ERROR 1131 (42000): You are using MySQL as an anonymous user and anonymous users are not allowed to change passwords
– MD. Mohiuddin Ahmed
Dec 7 '15 at 12:19
1
It's normal. Your user is anonymous. You need to execute> mysql -u {your_username}
– d.danailov
Dec 7 '15 at 16:22
1
1
Gives : ERROR 1131 (42000): You are using MySQL as an anonymous user and anonymous users are not allowed to change passwords
– MD. Mohiuddin Ahmed
Dec 7 '15 at 12:19
Gives : ERROR 1131 (42000): You are using MySQL as an anonymous user and anonymous users are not allowed to change passwords
– MD. Mohiuddin Ahmed
Dec 7 '15 at 12:19
1
1
It's normal. Your user is anonymous. You need to execute
> mysql -u {your_username}
– d.danailov
Dec 7 '15 at 16:22
It's normal. Your user is anonymous. You need to execute
> mysql -u {your_username}
– d.danailov
Dec 7 '15 at 16:22
add a comment |
I am using mysql-5.7.12-osx10.11-x86_64.dmg in Mac OSX
The installation process automatically sets up a temporary password for root user. You should save the password. The password can not be recovered.
Follow the instruction
- Go to
cd /usr/local/mysql/bin/
- Enter the temporary password (which would look something like, "tsO07JF1=>3")
- You should get mysql> prompt.
- Run,
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('{YOUR_PASSWORD}');
If you wish to set your password: "root" then the command would be,SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root');
- Run
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
- Run
exit
- Run
./mysql -u root -p
- Type your password. In my case I would type, "root" (without quote)
- That's all.
For convenience, you should add "/usr/local/mysql/bin"
to your PATH
Now from anywhere you can type ./mysql -u root -p
and then type the password and you will get mysql> prompt.
Hope it helps.
add a comment |
I am using mysql-5.7.12-osx10.11-x86_64.dmg in Mac OSX
The installation process automatically sets up a temporary password for root user. You should save the password. The password can not be recovered.
Follow the instruction
- Go to
cd /usr/local/mysql/bin/
- Enter the temporary password (which would look something like, "tsO07JF1=>3")
- You should get mysql> prompt.
- Run,
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('{YOUR_PASSWORD}');
If you wish to set your password: "root" then the command would be,SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root');
- Run
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
- Run
exit
- Run
./mysql -u root -p
- Type your password. In my case I would type, "root" (without quote)
- That's all.
For convenience, you should add "/usr/local/mysql/bin"
to your PATH
Now from anywhere you can type ./mysql -u root -p
and then type the password and you will get mysql> prompt.
Hope it helps.
add a comment |
I am using mysql-5.7.12-osx10.11-x86_64.dmg in Mac OSX
The installation process automatically sets up a temporary password for root user. You should save the password. The password can not be recovered.
Follow the instruction
- Go to
cd /usr/local/mysql/bin/
- Enter the temporary password (which would look something like, "tsO07JF1=>3")
- You should get mysql> prompt.
- Run,
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('{YOUR_PASSWORD}');
If you wish to set your password: "root" then the command would be,SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root');
- Run
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
- Run
exit
- Run
./mysql -u root -p
- Type your password. In my case I would type, "root" (without quote)
- That's all.
For convenience, you should add "/usr/local/mysql/bin"
to your PATH
Now from anywhere you can type ./mysql -u root -p
and then type the password and you will get mysql> prompt.
Hope it helps.
I am using mysql-5.7.12-osx10.11-x86_64.dmg in Mac OSX
The installation process automatically sets up a temporary password for root user. You should save the password. The password can not be recovered.
Follow the instruction
- Go to
cd /usr/local/mysql/bin/
- Enter the temporary password (which would look something like, "tsO07JF1=>3")
- You should get mysql> prompt.
- Run,
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('{YOUR_PASSWORD}');
If you wish to set your password: "root" then the command would be,SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root');
- Run
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
- Run
exit
- Run
./mysql -u root -p
- Type your password. In my case I would type, "root" (without quote)
- That's all.
For convenience, you should add "/usr/local/mysql/bin"
to your PATH
Now from anywhere you can type ./mysql -u root -p
and then type the password and you will get mysql> prompt.
Hope it helps.
edited May 30 '16 at 17:49
answered May 30 '16 at 11:14
tausiqtausiq
6471016
6471016
add a comment |
add a comment |
The answer may sound silly, but after wasting hours of time, this is how I got it to work
mysql -u root -p
I got the error message
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Even though I was typing the correct password(the temporary password you get when you first install mysql)
I got it right when I typed in the password when the password prompt was blinking
add a comment |
The answer may sound silly, but after wasting hours of time, this is how I got it to work
mysql -u root -p
I got the error message
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Even though I was typing the correct password(the temporary password you get when you first install mysql)
I got it right when I typed in the password when the password prompt was blinking
add a comment |
The answer may sound silly, but after wasting hours of time, this is how I got it to work
mysql -u root -p
I got the error message
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Even though I was typing the correct password(the temporary password you get when you first install mysql)
I got it right when I typed in the password when the password prompt was blinking
The answer may sound silly, but after wasting hours of time, this is how I got it to work
mysql -u root -p
I got the error message
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Even though I was typing the correct password(the temporary password you get when you first install mysql)
I got it right when I typed in the password when the password prompt was blinking
answered Dec 6 '17 at 3:31
Amit KumarAmit Kumar
682210
682210
add a comment |
add a comment |
if the problem still exists try to force changing the pass
Stop MySQL Server (on Linux):
/etc/init.d/mysql stop
Stop MySQL Server (on Mac OS X):
mysql.server stop
Start mysqld_safe daemon with --skip-grant-tables
mysqld_safe --skip-grant-tables &
mysql -u root
Setup new MySQL root user password
use mysql;
update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
flush privileges;
quit;
Stop MySQL Server (on Linux):
/etc/init.d/mysql stop
Stop MySQL Server (on Mac OS X):
mysql.server stop
Start MySQL server service and test to login by root:
mysql -u root -p
add a comment |
if the problem still exists try to force changing the pass
Stop MySQL Server (on Linux):
/etc/init.d/mysql stop
Stop MySQL Server (on Mac OS X):
mysql.server stop
Start mysqld_safe daemon with --skip-grant-tables
mysqld_safe --skip-grant-tables &
mysql -u root
Setup new MySQL root user password
use mysql;
update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
flush privileges;
quit;
Stop MySQL Server (on Linux):
/etc/init.d/mysql stop
Stop MySQL Server (on Mac OS X):
mysql.server stop
Start MySQL server service and test to login by root:
mysql -u root -p
add a comment |
if the problem still exists try to force changing the pass
Stop MySQL Server (on Linux):
/etc/init.d/mysql stop
Stop MySQL Server (on Mac OS X):
mysql.server stop
Start mysqld_safe daemon with --skip-grant-tables
mysqld_safe --skip-grant-tables &
mysql -u root
Setup new MySQL root user password
use mysql;
update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
flush privileges;
quit;
Stop MySQL Server (on Linux):
/etc/init.d/mysql stop
Stop MySQL Server (on Mac OS X):
mysql.server stop
Start MySQL server service and test to login by root:
mysql -u root -p
if the problem still exists try to force changing the pass
Stop MySQL Server (on Linux):
/etc/init.d/mysql stop
Stop MySQL Server (on Mac OS X):
mysql.server stop
Start mysqld_safe daemon with --skip-grant-tables
mysqld_safe --skip-grant-tables &
mysql -u root
Setup new MySQL root user password
use mysql;
update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
flush privileges;
quit;
Stop MySQL Server (on Linux):
/etc/init.d/mysql stop
Stop MySQL Server (on Mac OS X):
mysql.server stop
Start MySQL server service and test to login by root:
mysql -u root -p
answered Jul 26 '17 at 2:19
Max YaoMax Yao
53147
53147
add a comment |
add a comment |
Just one line and it solved my issue.
sudo dpkg-reconfigure mysql-server-5.5
add a comment |
Just one line and it solved my issue.
sudo dpkg-reconfigure mysql-server-5.5
add a comment |
Just one line and it solved my issue.
sudo dpkg-reconfigure mysql-server-5.5
Just one line and it solved my issue.
sudo dpkg-reconfigure mysql-server-5.5
edited May 11 '16 at 22:07
Paul Roub
32.7k85773
32.7k85773
answered May 11 '16 at 21:51
Satyendra SahaniSatyendra Sahani
985
985
add a comment |
add a comment |
In Ubuntu 16.04 (MySQL version 5.7.13) I was able to resolve the problem with the steps below:
Follow the instructions from the in section B.5.3.2.2 Resetting the Root Password: Unix and Unix-Like Systems
MySQL 5.7 reference manual
When I tried #sudo mysqld_safe --init-file=/home/me/mysql-init & it failed. The error was in /var/log/mysql/error.log
2016-08-10T11:41:20.421946Z 0 [Note] Execution of init_file '/home/me/mysql/mysql-init' started.
2016-08-10T11:41:20.422070Z 0 [ERROR] /usr/sbin/mysqld: File '/home/me/mysql/mysql-init' not found (Errcode: 13 - Permission denied)
2016-08-10T11:41:20.422096Z 0 [ERROR] Aborting
The file permission of mysql-init was not the problem, need to edit apparmor permission
Edit by #sudo vi /etc/apparmor.d/usr.sbin.mysqld
....
/var/log/mysql/ r,
/var/log/mysql/** rw,
# Allow user init file
/home/pranab/mysql/* r,
# Site-specific additions and overrides. See local/README for details.
#include <local/usr.sbin.mysqld>
}
Do #sudo /etc/init.d/apparmor reload
Start mysqld_safe again try step 2 above. Check /var/log/mysql/error.log make sure there is no error and the mysqld is successfully started
Run #mysql -u root -p
Enter password:
Enter the password that you specified in mysql-init. You should be able to log in as root now.
Shutdown mysqld_safe by #sudo mysqladmin -u root -p shutdown
Start mysqld normal way by #sudo systemctl start mysql
add a comment |
In Ubuntu 16.04 (MySQL version 5.7.13) I was able to resolve the problem with the steps below:
Follow the instructions from the in section B.5.3.2.2 Resetting the Root Password: Unix and Unix-Like Systems
MySQL 5.7 reference manual
When I tried #sudo mysqld_safe --init-file=/home/me/mysql-init & it failed. The error was in /var/log/mysql/error.log
2016-08-10T11:41:20.421946Z 0 [Note] Execution of init_file '/home/me/mysql/mysql-init' started.
2016-08-10T11:41:20.422070Z 0 [ERROR] /usr/sbin/mysqld: File '/home/me/mysql/mysql-init' not found (Errcode: 13 - Permission denied)
2016-08-10T11:41:20.422096Z 0 [ERROR] Aborting
The file permission of mysql-init was not the problem, need to edit apparmor permission
Edit by #sudo vi /etc/apparmor.d/usr.sbin.mysqld
....
/var/log/mysql/ r,
/var/log/mysql/** rw,
# Allow user init file
/home/pranab/mysql/* r,
# Site-specific additions and overrides. See local/README for details.
#include <local/usr.sbin.mysqld>
}
Do #sudo /etc/init.d/apparmor reload
Start mysqld_safe again try step 2 above. Check /var/log/mysql/error.log make sure there is no error and the mysqld is successfully started
Run #mysql -u root -p
Enter password:
Enter the password that you specified in mysql-init. You should be able to log in as root now.
Shutdown mysqld_safe by #sudo mysqladmin -u root -p shutdown
Start mysqld normal way by #sudo systemctl start mysql
add a comment |
In Ubuntu 16.04 (MySQL version 5.7.13) I was able to resolve the problem with the steps below:
Follow the instructions from the in section B.5.3.2.2 Resetting the Root Password: Unix and Unix-Like Systems
MySQL 5.7 reference manual
When I tried #sudo mysqld_safe --init-file=/home/me/mysql-init & it failed. The error was in /var/log/mysql/error.log
2016-08-10T11:41:20.421946Z 0 [Note] Execution of init_file '/home/me/mysql/mysql-init' started.
2016-08-10T11:41:20.422070Z 0 [ERROR] /usr/sbin/mysqld: File '/home/me/mysql/mysql-init' not found (Errcode: 13 - Permission denied)
2016-08-10T11:41:20.422096Z 0 [ERROR] Aborting
The file permission of mysql-init was not the problem, need to edit apparmor permission
Edit by #sudo vi /etc/apparmor.d/usr.sbin.mysqld
....
/var/log/mysql/ r,
/var/log/mysql/** rw,
# Allow user init file
/home/pranab/mysql/* r,
# Site-specific additions and overrides. See local/README for details.
#include <local/usr.sbin.mysqld>
}
Do #sudo /etc/init.d/apparmor reload
Start mysqld_safe again try step 2 above. Check /var/log/mysql/error.log make sure there is no error and the mysqld is successfully started
Run #mysql -u root -p
Enter password:
Enter the password that you specified in mysql-init. You should be able to log in as root now.
Shutdown mysqld_safe by #sudo mysqladmin -u root -p shutdown
Start mysqld normal way by #sudo systemctl start mysql
In Ubuntu 16.04 (MySQL version 5.7.13) I was able to resolve the problem with the steps below:
Follow the instructions from the in section B.5.3.2.2 Resetting the Root Password: Unix and Unix-Like Systems
MySQL 5.7 reference manual
When I tried #sudo mysqld_safe --init-file=/home/me/mysql-init & it failed. The error was in /var/log/mysql/error.log
2016-08-10T11:41:20.421946Z 0 [Note] Execution of init_file '/home/me/mysql/mysql-init' started.
2016-08-10T11:41:20.422070Z 0 [ERROR] /usr/sbin/mysqld: File '/home/me/mysql/mysql-init' not found (Errcode: 13 - Permission denied)
2016-08-10T11:41:20.422096Z 0 [ERROR] Aborting
The file permission of mysql-init was not the problem, need to edit apparmor permission
Edit by #sudo vi /etc/apparmor.d/usr.sbin.mysqld
....
/var/log/mysql/ r,
/var/log/mysql/** rw,
# Allow user init file
/home/pranab/mysql/* r,
# Site-specific additions and overrides. See local/README for details.
#include <local/usr.sbin.mysqld>
}
Do #sudo /etc/init.d/apparmor reload
Start mysqld_safe again try step 2 above. Check /var/log/mysql/error.log make sure there is no error and the mysqld is successfully started
Run #mysql -u root -p
Enter password:
Enter the password that you specified in mysql-init. You should be able to log in as root now.
Shutdown mysqld_safe by #sudo mysqladmin -u root -p shutdown
Start mysqld normal way by #sudo systemctl start mysql
answered Aug 10 '16 at 13:37
codegencodegen
6912
6912
add a comment |
add a comment |
BY default password will be null, so you have to change password by doing below steps.
connect to mysql
root# mysql
Use mysql
mysql> update user set password=PASSWORD('root') where User='root';
Finally, reload the privileges:
mysql> flush privileges;
mysql> quit
add a comment |
BY default password will be null, so you have to change password by doing below steps.
connect to mysql
root# mysql
Use mysql
mysql> update user set password=PASSWORD('root') where User='root';
Finally, reload the privileges:
mysql> flush privileges;
mysql> quit
add a comment |
BY default password will be null, so you have to change password by doing below steps.
connect to mysql
root# mysql
Use mysql
mysql> update user set password=PASSWORD('root') where User='root';
Finally, reload the privileges:
mysql> flush privileges;
mysql> quit
BY default password will be null, so you have to change password by doing below steps.
connect to mysql
root# mysql
Use mysql
mysql> update user set password=PASSWORD('root') where User='root';
Finally, reload the privileges:
mysql> flush privileges;
mysql> quit
answered Jul 23 '14 at 10:08
community wiki
Rizwan Basheer
add a comment |
add a comment |
In recent MySQL versions there is no password
in mysql.user
table.
So you need to execute ALTER USER
. Put this one line command into the file.
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
And execute it as init file (as root or mysql user)
mysqld_safe --init-file=/home/me/mysql-init &
MySQL server need to be stopped to start mysqld_safe
.
Also, there may be a problem with apparmor permissions to load this init file. Read more here
https://blogs.oracle.com/jsmyth/entry/apparmor_and_mysql
add a comment |
In recent MySQL versions there is no password
in mysql.user
table.
So you need to execute ALTER USER
. Put this one line command into the file.
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
And execute it as init file (as root or mysql user)
mysqld_safe --init-file=/home/me/mysql-init &
MySQL server need to be stopped to start mysqld_safe
.
Also, there may be a problem with apparmor permissions to load this init file. Read more here
https://blogs.oracle.com/jsmyth/entry/apparmor_and_mysql
add a comment |
In recent MySQL versions there is no password
in mysql.user
table.
So you need to execute ALTER USER
. Put this one line command into the file.
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
And execute it as init file (as root or mysql user)
mysqld_safe --init-file=/home/me/mysql-init &
MySQL server need to be stopped to start mysqld_safe
.
Also, there may be a problem with apparmor permissions to load this init file. Read more here
https://blogs.oracle.com/jsmyth/entry/apparmor_and_mysql
In recent MySQL versions there is no password
in mysql.user
table.
So you need to execute ALTER USER
. Put this one line command into the file.
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
And execute it as init file (as root or mysql user)
mysqld_safe --init-file=/home/me/mysql-init &
MySQL server need to be stopped to start mysqld_safe
.
Also, there may be a problem with apparmor permissions to load this init file. Read more here
https://blogs.oracle.com/jsmyth/entry/apparmor_and_mysql
answered Jun 9 '16 at 15:06
Vladimir KovalchukVladimir Kovalchuk
134112
134112
add a comment |
add a comment |
If you haven't set password yet, then run mysql -uroot
, it works for me.
add a comment |
If you haven't set password yet, then run mysql -uroot
, it works for me.
add a comment |
If you haven't set password yet, then run mysql -uroot
, it works for me.
If you haven't set password yet, then run mysql -uroot
, it works for me.
answered Aug 16 '18 at 11:10
ahbonahbon
46329
46329
add a comment |
add a comment |
On Mac, If you have a problem in logging in with the first password you were given in installation, maybe you can just simply kill the mysql process and then try.
So:
1- run the following command to find the PID of mysql:
ps -aef | grep mysql | grep -v grep
2- kill the process:
kill -15 [process id]
Then you can login with the initial password using this command:
mysql -uroot -p
Which ask you to enter your password. Just enter the initial password.
add a comment |
On Mac, If you have a problem in logging in with the first password you were given in installation, maybe you can just simply kill the mysql process and then try.
So:
1- run the following command to find the PID of mysql:
ps -aef | grep mysql | grep -v grep
2- kill the process:
kill -15 [process id]
Then you can login with the initial password using this command:
mysql -uroot -p
Which ask you to enter your password. Just enter the initial password.
add a comment |
On Mac, If you have a problem in logging in with the first password you were given in installation, maybe you can just simply kill the mysql process and then try.
So:
1- run the following command to find the PID of mysql:
ps -aef | grep mysql | grep -v grep
2- kill the process:
kill -15 [process id]
Then you can login with the initial password using this command:
mysql -uroot -p
Which ask you to enter your password. Just enter the initial password.
On Mac, If you have a problem in logging in with the first password you were given in installation, maybe you can just simply kill the mysql process and then try.
So:
1- run the following command to find the PID of mysql:
ps -aef | grep mysql | grep -v grep
2- kill the process:
kill -15 [process id]
Then you can login with the initial password using this command:
mysql -uroot -p
Which ask you to enter your password. Just enter the initial password.
answered Jan 19 at 9:22
Maryam ZakaniMaryam Zakani
12514
12514
add a comment |
add a comment |
protected by Community♦ Oct 18 '14 at 4:03
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
1
This does not seem to be strictly programming-related to me. I flagged it for migration to SuperUser
– Uli Köhler
Feb 21 '14 at 20:55