LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 08-11-2009, 11:35 AM   #1
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, USA
Distribution: Centos 7 , Linux Mint 18.1 Under VMware in Win7
Posts: 498

Rep: Reputation: 34
MySQL Initial User Logon ID


I'm running Suse 11.1.

MySQL is installed.

I downloaded and installed the software for MySQLAdmin and MySQLBrowser, this was one software package so both got installed at the same time.

My question is this; When I log into MySQL to use the Admin Tools it doesn't like my root password. So I log in as 'localhost' with the id of 'root' and no password and I get right into the main Admin menu.

Why doesn't it accept the root password and how can I change the root login to need to have a password.

Will just changing the password in MySQL Admin do the trick?

Thanks
 
Old 08-11-2009, 12:30 PM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
First of all it's important to understand that the system root and the mysql root don't have any relationship.

In a default MySQL install, the MySQL root user does not have a password. It would be quite useless to have one as you would not know it so you have to contact MySQL. Or it's public knowledge so it does not secure anything.

There are a few steps that are often advised (or at least I have seen them show up on a number of occasions). The first one is to set a password for root. The second one is to remove the anonymous user and the third one is to remove the test database.

Below the steps using the normal mysql client. I don't have experience with mysqladmin.

Code:
root@webserver:/etc/rc.d# mysql
mysql> use mysql;
^^
You're now using the mysql database that holds the permissions.
Note that I don't specify root with the -u option as the mysql client will try to determine the user based on his/her current system login. I think this only works in Linux/Unix and not in Windows but not 100% sure.
Code:
mysql> select host, user, password from user;
+-----------+------+----------+
| host      | user | password |
+-----------+------+----------+
| localhost | root |          |
| webserver | root |          |
| webserver |      |          |
| localhost |      |          |
+-----------+------+----------+
4 rows in set (0.00 sec)

mysql> delete from user where user <> 'root';
Query OK, 2 rows affected (0.01 sec)
^^
The first query shows all currently defined users and the second one deletes the 'anonymous' users.
Code:
mysql> update user set password=password('your_password’);
Query OK, 2 rows affected (0.01 sec)
Rows matched: 2  Changed: 2  Warnings: 0
^^
You have now set a password for the two root users (and they are identical).
Code:
mysql> delete from user where host <> 'localhost';
Query OK, 1 row affected (0.01 sec)
^^
I prefer to delete the root user that is not tied to localhost as there is, in my opinion, no need to access a mysql server as root from an external machine. One can always use e.g. ssh and run the mysql client from there.
Code:
mysql> select host, user, password from user;
+-----------+------+-------------------------------------------+
| host      | user | password                                  |
+-----------+------+-------------------------------------------+
| localhost | root | *58364B2092FC2BF7A21616D9442D8250D2627B5B |
+-----------+------+-------------------------------------------+
1 row in set (0.00 sec)
^^
Just to verify the result.
Code:
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
^^
Flush the privileges so they are reflected; the alternative is to restart the mysql server.

You can now try to login as the root user with the new password.

Code:
root@webserver233:/etc/rc.d# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
root@webserver233:/etc/rc.d# mysql -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.37 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>
PS
I do not really know why it's advised to remove the test database.

Last edited by Wim Sturkenboom; 08-13-2009 at 12:02 AM. Reason: made an sql statement bold
 
Old 08-12-2009, 12:20 PM   #3
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, USA
Distribution: Centos 7 , Linux Mint 18.1 Under VMware in Win7
Posts: 498

Original Poster
Rep: Reputation: 34
Your answer and description regarding my issue is just terrific.

One could only hope that everyone who posts replies makes things this clear and with examples to explain the details.

Much thanks.
 
Old 08-12-2009, 09:47 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.5
Posts: 17,559

Rep: Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424
Removing the test db is just for tidiness. It doesn't do anything. I think they just supply it for convenience.
 
Old 08-13-2009, 12:01 AM   #5
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Quote:
Originally Posted by swamprat View Post
Your answer and description regarding my issue is just terrific.

One could only hope that everyone who posts replies makes things this clear and with examples to explain the details.

Much thanks.
Thanks.

You were lucky. I did write a setup document once for a server so it was a matter of copy and paste. Else it probably would not have been as complete as now.
 
Old 08-13-2009, 11:49 AM   #6
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, USA
Distribution: Centos 7 , Linux Mint 18.1 Under VMware in Win7
Posts: 498

Original Poster
Rep: Reputation: 34
Wim,

That's what it's all about; being at the right place at the right time.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Error install MySql initial database r3cursive Slackware 11 03-31-2009 03:59 PM
Initial PHP configuration after starting MySQL and Apache studioq Linux - Newbie 2 09-28-2006 12:23 AM
User Logon ajkannan83 General 0 06-28-2006 05:19 AM
php mysql initial connect to create db spoody_goon Programming 10 05-07-2005 10:20 AM
newbie seeking help with initial mysql installation marvc Linux - Software 14 04-14-2003 08:05 PM

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

All times are GMT -5. The time now is 10:32 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration