Professional Documents
Culture Documents
Mysql - ERROR 1045 (28000) - Access Denied For User 'Root'@'Localhost' (Using Password - YES) - Stack Overflow
Mysql - ERROR 1045 (28000) - Access Denied For User 'Root'@'Localhost' (Using Password - YES) - Stack Overflow
Mysql - ERROR 1045 (28000) - Access Denied For User 'Root'@'Localhost' (Using Password - YES) - Stack Overflow
JointheStackOverflowCommunity
Signup
ERROR1045(28000):Accessdeniedforuser'root'@'localhost'(usingpassword:YES)
Iamanelectricalengineeringwhomainlyplayaroundwithpowersysteminsteadofprogramming.Recently,Ihavebeenfollowingamanualto
installasoftwaresuiteonUbuntu.Ihavenoknowledgeon mySQL atall,actually.IhavedonethefollowinginstallationsonmyUbuntu.
sudoaptgetupdate
sudoaptgetinstallmysqlserver5.5
sudoaptgetinstallmysqlclient5.5
sudoaptgetinstallmysqlcommon
sudoaptgetinstallglade
sudoaptgetinstallntp
ThenIdo
me@ubuntu:~/Desktop/iPDCv1.3.1/DBServer1.1$mysqlurootproot<"Db.sql"
Iendedupwiththefollowingerrormessage.
ERROR1045(28000):Accessdeniedforuser'root'@'localhost'(usingpassword:YES)
HowmayIfixitandcontinue?
askedFeb21'14at20:52
SibbsGambling
3,826 11 53 120
1 Thisdoesnotseemtobestrictlyprogrammingrelatedtome.IflaggeditformigrationtoSuperUser
UliKhlerFeb21'14at20:55
12Answers
mysqluroot
Youshouldobviouslychangeyourrootpasswordafterinstallation
mysqladminurootpassword[newpassword]
Inmostcasesyoushouldalsosetupindividualuseraccountsbeforeworkingextensivelywith
theDBaswell.
Note:ForMySQL5.7+pleaseseeanswerfrom@Lahirutothisquestion.Thatcontainsmore
currentinformation.
editedMar27at14:31 answeredFeb21'14at20:54
TobySpeight MikeBrant
8,978 9 23 46 53.7k 5 51 75
@FarticlePilterThe p flagspecifiesthepassword,soafteryouchangeyourrootpasswordyouwould
dolike mysqlurootp[newpassword] .The <[filename] isusingstdinputtoexecuteanSQLfile
atthepathgivenviatheusercredentialyouprovide.MikeBrantFeb21'14at21:00
2 @Kanagaroointhisquestion,theOPstatestheyjustinstalledMySQLforthefirsttimeandthentriedto
accessviaMySQLcommandlineclient.Thatsoundslikefirsttimeaccesstome.MikeBrantDec13
'14at13:17
12 Actuallyformysqlcommunityserver5.7,thedefaultrootpasswordisrandomlygeneratedwhenyou
install.Checkyour/var/log/mysqld.logforalinetalkingabouta"temporarypassword".Saveshoursof
messingaround.Phil_1984_Jan8'16at10:04
Iwasabletosolvethisproblembyexecutingthisstatement
sudodpkgreconfiguremysqlserver5.5
Whichwillchangetherootpassword.
editedMay10'14at14:48 answeredMar18'14at3:37
JJD Divz
19.2k 28 121 202 1,145 1 6 6
2 JustwhatIneeded...butnoteveryonehasversion5.5ofserver.use dpkggetselections|grep
sql togetyourversion Balmipour Sep10'15at11:18
1 @BalmipourwhatshouldbetheequivalentcommandtocheckthesqlversioninRhel6.x PrathamNSep
12'15at4:00
Youhavetoresetthepassword!stepsformacosx(testedandworking)andubuntu
StopMySQL
$sudo/usr/local/mysql/supportfiles/mysql.serverstop
Startitinsafemode:
$sudomysqld_safeskipgranttables
(abovelineisthewholecommand)
Thiswillbeanongoingcommanduntiltheprocessisfinishedsoopenanothershell/terminal
window,loginwithoutapassword:
$mysqluroot
mysql>UPDATEmysql.userSETPassword=PASSWORD('password')WHEREUser='root';
StartMySQL
sudo/usr/local/mysql/supportfiles/mysql.serverstart
yournewpasswordis'password'.
answeredSep17'14at6:44
thusharaK
3,509 1 27 49
1 Please,NOTthatway!@Divz'sanswerismoresecure.Quotingthedocaboutskipgranttables:This
enablesanyonetoconnectwithoutapasswordandwithallprivileges[...]Becausethisisinsecure,
[...]use skipgranttables inconjunctionwith skipnetworking topreventremoteclientsfrom
connecting.oh,andalso,thisonedidn'tworkforme.ThatswhyIcamehere:pBalmipourSep10'15at
12:16
1 Ifyougothatway ,yes.Itdidn'tworkforme,andfollowing@Divz'sanswerseemswayeasiertome,
anyway WhatIwouldsuggestisusing dpkggetselections|grepmysqlserver togetyour
exactMySQLversion,thengoforsudodpkgreconfiguremysqlserver5.x(replace5.xwithyourserver
version,btw).Icommented@Divz'sanswerwiththisprecision,butit'smaskedbytheseveral"thanks"
comments.BalmipourSep10'15at16:13
2 updateusersetauthentication_string=password('1111')whereuser='root'DejellDec17'15at20:51
2 Thisactuallyworked...theothersolutionsstillgavemethesameerror.eddy147Jan1at16:49
iftheproblemstillexiststrytoforcechangingthepass
/etc/init.d/mysqlstop
mysqld_safeskipgranttables&
mysqluroot
SetupnewMySQLrootuserpassword
usemysql;
updateusersetpassword=PASSWORD("NEWROOTPASSWORD")whereUser='root';
flushprivileges;
quit;
StopMySQLServer:
/etc/init.d/mysqlstop
StartMySQLserverandtestit:
mysqlurootp
editedJun4'16at18:28 answeredMay20'14at13:34
SilvioDelgado YasinHassanien
4,089 2 10 18 2,553 1 11 13
1 Thankyou. ERROR1045(28000):Accessdeniedforuser'root'@'localhost'(usingpassword:NO)
wasalsoplaguingmyserver.'mysqld_safe'alsofaileduntilIdida'killallmysqld'AFTERyourStep1.
Marcos Aug29'14at10:09
2 Itsgivingme:ERROR1054(42S22):Unknowncolumn'password'in'fieldlist'MD.MohiuddinAhmedDec
7'15at12:15
Forme,themysqlversionis5.6+,andtheOSiscentOS6.5,Ishouldusethe /etc/init.d/mysqldstop
not /etc/init.d/mysqlstop .StrongYoungApr12at1:28
Pleasereadtheofficialdocumentation:Mysql:HowtoResettheRootPassword
Ifyouhaveaccesstoterminal:
MySQL5.7.6andlater:
$mysql
mysql>ALTERUSER'root'@'localhost'IDENTIFIEDBY'MyNewPass';
MySQL5.7.5andearlier:
$mysql
mysql>SETPASSWORDFOR'root'@'localhost'=PASSWORD('MyNewPass');
editedMar27at14:46 answeredAug10'15at10:05
d.danailov
5,340 1 34 25
Gives:ERROR1131(42000):YouareusingMySQLasananonymoususerandanonymoususersarenot
allowedtochangepasswords MD.MohiuddinAhmedDec7'15at12:19
Icameacrossthisveryannoyingproblemandfoundmanyanswersthatdidnotwork.Thebest
solutionIcameacrosswastocompletelyuninstallmysqlandreinstallit.Onreinstallyouseta
rootpasswordandthisfixedtheproblem.
sudoaptgetpurgemysqlservermysqlclientmysqlcommonmysqlservercore5.5mysqlclient
core5.5
sudormrf/etc/mysql/var/lib/mysql
sudoaptgetautoremove
sudoaptgetautoclean
IfoundthiscodeelsewheresoItakenocreditforit.Butitworks.Toinstallmysqlafter
uninstallingitIthinkdigitaloceanhasagoodtutorialonit.Checkoutmygistforthis.
https://gist.github.com/JamesDaniel/c02ef210c17c1dec82fc973cac484096
answeredFeb9at21:05
JamesD
66 6
WorksonRaspberryPitoo:)CodingYourLifeApr12at22:18
Iamusingmysql5.7.12osx10.11x86_64.dmginMacOSX
Theinstallationprocessautomaticallysetsupatemporarypasswordforrootuser.Youshould
savethepassword.Thepasswordcannotberecovered.
Followtheinstruction
1.Goto cd/usr/local/mysql/bin/
2.Enterthetemporarypassword(whichwouldlooksomethinglike,"tsO07JF1=>3")
3.Youshouldgetmysql>prompt.
4.Run, SETPASSWORDFOR'root'@'localhost'=PASSWORD('{YOUR_PASSWORD}'); Ifyouwishtoset
yourpassword:"root"thenthecommandwouldbe, SETPASSWORDFOR'root'@'localhost'=
PASSWORD('root');
5.Run ALTERUSER'root'@'localhost'PASSWORDEXPIRENEVER;
6.Run exit
7.Run ./mysqlurootp
8.Typeyourpassword.InmycaseIwouldtype,"root"(withoutquote)
9.That'sall.
Hopeithelps.
editedMay30'16at17:49 answeredMay30'16at11:14
tausiq
492 6 13
BYdefaultpasswordwillbenull,soyouhavetochangepasswordbydoingbelowsteps.
connecttomysql
root#mysql
Usemysql
mysql>updateusersetpassword=PASSWORD('root')whereUser='root'Finally,reloadthe
privileges:
mysql>flushprivilegesmysql>quit
answeredJul23'14at10:08 communitywiki
RizwanBasheer
Justonelineanditsolvedmyissue.
sudodpkgreconfiguremysqlserver5.5
editedMay11'16at22:07 answeredMay11'16at21:51
PaulRoub SatyendraSahani
30.2k 8 44 69 58 5
ALTERUSER'root'@'localhost'IDENTIFIEDBY'MyNewPass';
Andexecuteitasinitfile(asrootormysqluser)
mysqld_safeinitfile=/home/me/mysqlinit&
MySQLserverneedtobestoppedtostart mysqld_safe .
Also,theremaybeaproblemwithapparmorpermissionstoloadthisinitfile.Readmorehere
https://blogs.oracle.com/jsmyth/entry/apparmor_and_mysql
answeredJun9'16at15:06
VladimirKovalchuk
134 1 12
InUbuntu16.04(MySQLversion5.7.13)Iwasabletoresolvetheproblemwiththestepsbelow:
1.FollowtheinstructionsfromtheinsectionB.5.3.2.2ResettingtheRootPassword:Unixand
UnixLikeSystemsMySQL5.7referencemanual
2.WhenItried#sudomysqld_safeinitfile=/home/me/mysqlinit&itfailed.Theerrorwasin
/var/log/mysql/error.log
20160810T11:41:20.421946Z0[Note]Executionofinit_file'/home/me/mysql/mysqlinit'
started.20160810T11:41:20.422070Z0[ERROR]/usr/sbin/mysqld:File
'/home/me/mysql/mysqlinit'notfound(Errcode:13Permissiondenied)201608
10T11:41:20.422096Z0[ERROR]Aborting
Thefilepermissionofmysqlinitwasnottheproblem,needtoeditapparmorpermission
3.Editby#sudovi/etc/apparmor.d/usr.sbin.mysqld
....
/var/log/mysql/r,
/var/log/mysql/**rw,
#Allowuserinitfile
/home/pranab/mysql/*r,
#Sitespecificadditionsandoverrides.Seelocal/READMEfordetails.
#include<local/usr.sbin.mysqld>
}
4.Do#sudo/etc/init.d/apparmorreload
5.Startmysqld_safeagaintrystep2above.Check/var/log/mysql/error.logmakesurethereis
noerrorandthemysqldissuccessfullystarted
6.Run#mysqlurootp
Enterpassword:
Enterthepasswordthatyouspecifiedinmysqlinit.Youshouldbeabletologinasrootnow.
7.Shutdownmysqld_safeby#sudomysqladminurootpshutdown
8.Startmysqldnormalwayby#sudosystemctlstartmysql
answeredAug10'16at13:37
codegen
59 1 2
Attheinitialstartupoftheserverthefollowinghappens,giventhatthedatadirectoryofthe
serverisempty:
Theserverisinitialized.
SSLcertificateandkeyfilesaregeneratedinthedatadirectory.
Thevalidate_passwordpluginisinstalledandenabled.
Thesuperuseraccount'root'@'localhost'iscreated.Thepasswordforthesuperuserisset
andstoredintheerrorlogfile.
Torevealit,usethefollowingcommand:
shell>sudogrep'temporarypassword'/var/log/mysqld.log
Changetherootpasswordassoonaspossiblebylogginginwiththegeneratedtemporary
passwordandsetacustompasswordforthesuperuseraccount:
shell>mysqlurootp
mysql>ALTERUSER'root'@'localhost'IDENTIFIEDBY'MyNewPass5!';
answeredMar23at5:17
Lahiru
253 1 17
1 Thislookedpromising,butitdoesn'tworkforme.WhenIrun sudogrep'temporarypassword'
/var/log/mysqld.log Iget /var/log/mysqld.log:Nosuchfileordirectory
EricHepperleCodeSlayer2010Apr20at16:17
protectedbyCommunity Oct18'14at4:03
Thankyouforyourinterestinthisquestion.Becauseithasattractedlowqualityorspamanswersthathadtoberemoved,postingananswernowrequires10reputation
onthissite(theassociationbonusdoesnotcount).
Wouldyouliketoansweroneoftheseunansweredquestions instead?