how do you set a mySQL root password?

Hello,

I’m trying to follow a mySQL setup guide and it advised me to use the command:

opensuse11:~ # mysqladmin -u root -p rootpassword

to set root password.

Now, here’s what I’ve done:

Please report any problems with the /usr/bin/mysqlbug script!

Starting service MySQL                                                                                                                      done
linux-2fs6:/usr/sbin # mysqladmin -u root password -p 88dabatase54
Enter password: 
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
linux-2fs6:/usr/sbin # mysqladmin -u root password -p 88dabatase54
Enter password: 
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
linux-2fs6:/usr/sbin # mysqladmin -u root password -p 88dabatase54
Enter password: 
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
linux-2fs6:/usr/sbin # mysqladmin -u root password -p 88dabatase54
Enter password: 
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
linux-2fs6:/usr/sbin # mysqladmin -u root password -p 88dabatase54
Enter password: 
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
linux-2fs6:/usr/sbin # mysqladmin -u root password -p 88dabatase54
Enter password: 
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
linux-2fs6:/usr/sbin # mysqladmin -u root password -p88dabatase54
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'

Am I that retarded that I can’t retype my 88dabatase554? I’ve also tried the machine root pass in one of the above cases … can someone please help? Is there a default password one must use the very first time in setting a password? Is this not the first logical step after starting and installing it?

Thanks,

Alex

p.s: the guide says there’s no default password … so is that simply wrong advice? … argh .

omg omg… did it lock my dumb ass out? Here’s what I got on another step:

linux-2fs6:/usr/sbin # mysqladmin -u root password -palex
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'

what’s going on here now?

Where did you read that you use -p. You just type the password after the word password, like this:

mysqladmin -u root password “alex”

Quote the password to be safe, in case you have shell metacharacters in it.

wow, thanks ken_yap. My source is:

source: Install & Configure LAMP (Apache/MySQL/PHP) in openSUSE 11.0 | SUSE & openSUSE (scroll down like a page or two)

I realize it’s from 2008 but it says suse 11.0 so I thought it would be relevant.

Do you happen to know if phpMyAdmin got removed from suse 11.4 x64? I can’t find it in yast2 anywhere!

Thanks again!

It’s in a contrib repo now, search for it at software.opensuse.org/search.

Don’t believe everything you read. In this case the man page for mysqladmin or the online documentation from MySQL would have set you on the right path.

In fact if you had read the webpage you quoted more carefully you would have seen that your syntax doesn’t work and the author provides the correct syntax.

ok.

Thanks again. Going to try the official documentation guides. I just stopped short of watching some guy’s youtube video … ugh. why didn’t they make xampp for 64 bit!!! gah. oh well. maybe I’ll learn more this way.

If you are setting up mysql for the first time, it is easier to enter
mysql -u root
without a password as there is none. Then
SET PASSWORD FOR ‘root’@‘localhost’ = PASSWORD(‘password’);
SET PASSWORD FOR ‘root’@‘HOST_NAME’ = PASSWORD(‘password’);
(replace ‘HOST_NAME’ with whatever appears as your host name when you open a console)

There are two anonymous users in mysql.user which you need to delete or deal with in a way which is appropriate to what you are going to do. Otherwise, anyone will be able to log on without a password.

Actually the easiest way to secure an installation is to run the provided script /usr/bin/mysql_secure_installation which prompts for the root password to set, removes the test database as well as removes the anonymous accounts.

On 2011-05-14 03:06, bananapeal wrote:
> Do you happen to know if phpMyAdmin got removed from suse 11.4 x64? I
> can’t find it in yast2 anywhere!

I have the vague recollection that it was removed because unsafe or too
difficult to maintain.

…]

Yes, that is. Search the factory mail list for this topic (Apr 2010):

Subject: [opensuse-factory] phpMyAdmin on Factory?


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

That could do with turning into a How-to as this question gets asked regularly and I have previously answered as above but the 15 threads where this suggestion appears are scattered across several forums.

I would second a how-to LAMP article … just because it’s one-click easy in windows to set up a development server and when you’re just beginning to learn how to use something i think it’s better to get something you can play around with up rather than learn advanced setup techniques from the get-go.

And yes indeed, mysql_secure_installation is a nice and easy way to get rid of the anons etc.

As for me, I’ll try and get a little more mysql under my belt before continuing with the documentation.

Actually the RPM package should be modified to invoke this script as a optional post-install action (it may already, I haven’t checked) after asking the user. Users installing non-interactively will miss it, but at least it will catch the eye of vast majority of users who install from YaST or zypper interactively.

I cannot ever recall it being offered either during an installation or after I have installed mysql from the repo using YaST since openSUSE started. It certainly would be a useful option. I discovered the advice I gave in the mysql documentation.

On 2011-05-15 02:06, ken yap wrote:
>
> john_hudson;2339679 Wrote:
>> That could do with turning into a How-to as this question gets asked
>> regularly and I have previously answered as above but the 15 threads
>> where this suggestion appears are scattered across several forums.
>
> Actually the RPM package should be modified to invoke this script as a
> optional post-install action (it may already, I haven’t checked) after
> asking the user. Users installing non-interactively will miss it, but at
> least it will catch the eye of vast majority of users who install from
> YaST or zypper interactively.

Questions during install of an rpm have to be limited, as they are
inconvenient.

Years ago, the installation sent emails to root, telling the most important
things to know. I don’t know why this has disappeared.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

It’s already done for packages like Flash Player where you have to agree to the license. In any case there are options to ignore packages that require interaction or to automatically agree.

On 2011-05-15 16:06, ken yap wrote:
>
> It’s already done for packages like Flash Player where you have to agree
> to the license. In any case there are options to ignore packages that
> require interaction or to automatically agree.

Licenses are the only exceptions allowed currently. And, at least here, all
licenses pop within seconds one of another.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

I’m not interested in arguing the exact mechanism, but I think we agree that it’s something the devs can deal with one way or another. They could just run the script anyway, give the root account a random password and tell the user what’s been done. Or pester the first user to run the script, which is less desirable because people may ignore it.

Other distros deal with this adequately, notably one starting with D, so it’s not rocket science.

I generally follow the prescribed method from cyberciti. It has never failed me when I’ve inherited a machine with a MySQL instance that suddenly I “own” and need to reset the root password:

Reset MySQL root password