LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-11-2004, 09:31 PM   #1
legendaryfox
LQ Newbie
 
Registered: Apr 2004
Distribution: Fedora Core 1
Posts: 16

Rep: Reputation: 0
MySQL doesn't like passwords


I've set user accounts on my MySQL database using mysql_setpermission, but in my PHP programs, when i do a mysql_connect and use the username and password, it gives me a denial. However, when I omit the password (leave it ""), i get a resource id #2 (a good thing, right?) What went wrong?


thanks!
 
Old 04-12-2004, 04:13 AM   #2
dhbiker
Member
 
Registered: Dec 2003
Location: Bristol
Distribution: Slackware 10.2
Posts: 196

Rep: Reputation: 30
sounds like you've set up the new accounts wrong, the reason that you can log in without a password is that when you install mysql it adds two accounts %@localhost and %@what_ever_you_called_your_pc that allow connections without passwords. As you can imagine this isn't ideal (security). Here's how to get rid of them (and set up the accounts you want), oh have you set the root password as well?

here's how to do everything (open up a terminal and do everything from there)

set root password: (not the old_password is 'password' when you install mysql!)

Code:
mysqladmin -uroot -pold_password password your_password
to get rid of the unsecure %@localhost accounts log in to mysql as root:
Code:
mysql -uroot -p
(it will ask for password)
use mysql
select * from user;
delete from user where Host="localhost" and Password="";
delete from user where Host="what_ever_your_pc_is_called" and Password="";
flush privileges;
if you now do "select * from user;" you should have nothing in there other than the root account, now to set up your new accounts;

Code:
grant usage on *.* to new_user identified by 'users_password';
this should let that user log into mysql with their password, but it doesn't allow them to do anything useful!

decide what privileges you want the user to have on which databases and then grant them to him/her
Code:
grant insert,select,update,delete on database_name.* to user_name identified by 'users_password';
you can also grant them all privileges on a database by using "grant all on database.* to ...."

hope this helps a bit!

Last edited by dhbiker; 04-12-2004 at 04:15 AM.
 
Old 04-12-2004, 05:48 PM   #3
legendaryfox
LQ Newbie
 
Registered: Apr 2004
Distribution: Fedora Core 1
Posts: 16

Original Poster
Rep: Reputation: 0
THANKS! It worked ^.^


Just a check question - I do this everytiime (except for the admin part and the deleting part) i make a new user, right?
 
Old 04-13-2004, 02:01 AM   #4
dhbiker
Member
 
Registered: Dec 2003
Location: Bristol
Distribution: Slackware 10.2
Posts: 196

Rep: Reputation: 30
yeah, although you don't actually need the grant usage bit, you can go straight to the grant, select etc. on database.* to user blah identified by 'blah', mysql will automatically grant usage on *.*
 
Old 04-13-2004, 02:02 AM   #5
dhbiker
Member
 
Registered: Dec 2003
Location: Bristol
Distribution: Slackware 10.2
Posts: 196

Rep: Reputation: 30
oh yeah, you might want to know that the "file" privilege can be used to attack your system and its recommended that you only grant it to people who really need it.
 
Old 04-13-2004, 02:30 PM   #6
legendaryfox
LQ Newbie
 
Registered: Apr 2004
Distribution: Fedora Core 1
Posts: 16

Original Poster
Rep: Reputation: 0
Many thanks dude!
 
Old 03-08-2009, 01:10 PM   #7
PhooD
LQ Newbie
 
Registered: Feb 2009
Location: Tennessee, USA
Distribution: Mac OSX-BSD
Posts: 5

Rep: Reputation: 0
Exclamation How can I delete all old passwords for MySQL and start again?

I am using a remote Mac running Apple Mac OS X Leopard Server, but also have access via command line, VNC and ftp. I initially set up MySQL using the remote ServerAdmin program and it worked OK (even though it has the
"Cannot load mcrypt extension. Please check your PHP configuration." error displayed.

I opted for no login passwords initially because I intended to use .htaccess instead. I set a password for root and another for me with all privileges. I logged in as me and found I did not have permission to create a database. So I logged in as root and created 3 databases. But when I logged in as me via phpMyAdmin it would not allow me to see these new databases. After 2 days of frustration I decided to do away with passwords on these MySQL accounts and changed them all to "No Password" status and logged out.

Now phpmyadmin will not let me log in as root. I get:
"#1045 - Access denied for user 'root'@'localhost' (using password: YES)".
Even though I told it No password.

I tried moving the MySQL folder, shutting down all services (web, webojects, MySQL) and restarting via ServerAdmin in OSX. Still no go.

So at this point I am screwed and revert to command line. Couldn't get access to anything so logged in as root. Read tons of stuff on line. The site http://dev.mysql.com/doc/mysql-macos...tallation.html says use mysqladmin shutdown. But even as root I get the error "root# mysqladmin shutdown
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
sh:~ root# "
mysqld doesn't exist. I think it is renamed mysqladmin
It will not let me run mysql or access or move, rename or delete certain folders associated with mysql, even logged in as root. I thought I was god as root but I have been put in my place!

I deleted the MySQL folder that is supposed to contain the database and some other files and restarted MySL via ServerAdmin. Each time I restart Apache (web, including php5) and Webobjects and MySQL. There is also a "WebObjects Monitor" used on-line. I found that it said MySQL was running with no instances. I clicked Delete and it disappeared from the list. But still I cannot log in via phpMyAdmin. Thanks for you patience in reading all this but I thought you might prefer a full explanation.
 
Old 03-08-2009, 02:09 PM   #8
PhooD
LQ Newbie
 
Registered: Feb 2009
Location: Tennessee, USA
Distribution: Mac OSX-BSD
Posts: 5

Rep: Reputation: 0
Hey I dont believe this! In the time it took to write this everything fixed itself! Something must have timed out. I went back to phpmyadmin and logged in as root, created databases and assigned them to new users no problem! Logged in as new user and I can see the databases! Still the question remains for others. How DO you get rid of unwanted passwords in MySQL?
 
Old 03-08-2009, 02:27 PM   #9
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
Quote:
Originally Posted by PhooD View Post
How DO you get rid of unwanted passwords in MySQL?
set password for user = password('');

From the mysql docs: link
 
Old 03-08-2009, 11:46 PM   #10
PhooD
LQ Newbie
 
Registered: Feb 2009
Location: Tennessee, USA
Distribution: Mac OSX-BSD
Posts: 5

Rep: Reputation: 0
Thanks for the tip, but even logged in as root it would not let me use mysql commands. There may also be problems with having the right privileges to change passwords so this technique may not solve all problems.
 
Old 03-09-2009, 01:24 AM   #11
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
Works like a charm here either from the command line or through phpmyadmin.

Quote:
Originally Posted by PhooD View Post
I set a password for root and another for me with all privileges.
If you set up your users like so:
Code:
GRANT ALL PRIVILEGES ON *.* TO 'username'@'hostname'  IDENTIFIED BY 'some_pass'
either user should be able to change any other user's password.

Last edited by norobro; 03-09-2009 at 01:26 AM.
 
Old 03-09-2009, 02:22 PM   #12
sureshsujatha
Member
 
Registered: Mar 2009
Posts: 40

Rep: Reputation: 15
Correct me if I am wrong ... but isnt it an incorrect practise to fire commands like "GRANT ALL PRIVILEGES ON *.* TO 'username'@'hostname' IDENTIFIED BY 'some_pass'" from inside your application code.

Shouldnt such things be abstracted to the DBA and DBA only per se?

Last edited by sureshsujatha; 03-14-2009 at 12:28 AM.
 
Old 03-09-2009, 04:36 PM   #13
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
Not sure that I understand your point. The way that I read PhooD's posts, he is the DBA.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL problem - can't use passwords Ook Slackware 4 04-23-2005 06:36 PM
Sync MySQL passwords with local account passwords? turbine216 Linux - Software 2 02-18-2005 03:15 AM
Completely uninstalling MySQL and its passwords passwords...how? I locked myself out! Baix Linux - Newbie 2 01-30-2005 04:10 PM
MySQL Passwords mikz Linux - Software 4 09-07-2004 02:39 PM
MySQL root passwords ridertech Linux - Software 4 05-11-2004 10:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration