Koozali.org: home of the SME Server

MySQL Access

Tom

MySQL Access
« on: January 21, 2002, 03:47:10 AM »
I've just installed SMEServer 5.0 and it's working very well.
I've got one problem though; connecting to the MySQL database.
In another topic someone explains that the password can be found in the "/root/.my.conf" file. I did find the password but it is 74 caracters long! Is that the right one, or is it encrypted in some way?
Anyway, optimistic as I am I tried to type it in, using first root and then admin as users. It wouldn't let me in and I don't feel the urge to keep on experimenting with anymore users!

Can anyone tell me where I'm wrong? (I'm a Linux newbie, so please be gentle :o)

Tom Peck

Re: MySQL Access
« Reply #1 on: January 21, 2002, 04:29:12 AM »
You have the right password.

Connect using "root" and that password.  Once you have created a connection to the database, I'd recommend creating a new user to use for you MySQL connections - there are many tutorials on the net on how to achieve this.

Des Dougan

Re: MySQL Access
« Reply #2 on: January 21, 2002, 04:31:33 AM »
It is the right one, yes. The good news is that you don't need to type it in at all - logging in to MySQL as root will rasd the password from the ~/.my.cnf file.

Des Dougan

Tom

Re: MySQL Access
« Reply #3 on: January 22, 2002, 04:04:46 PM »
Thanks for your replies - but I still can't log on :(

No matter which user and password I try, I get the message:
ERROR 1045: Acces denied for user: 'root@localhost' (USING password: YES)

Is it possible to reset the password, or does that mess up the entire SMEServer?

Jonny J

Re: MySQL Access
« Reply #4 on: January 27, 2002, 07:19:16 PM »
I have to agree with Tom (tom_AT_kvintus.dk), i´m in the same situation and i have tried the password from .my.cnf and the password from (etc/openldap/ldap.pw) and the result is the same every time:

******
MySQL Connection Failed: Access denied for user: 'root@localhost' (Using password: YES)
******

So my question is, are there anyone who has solved the problem them selves ?? in that case i would like to hear from you.

Damien Curtain

Re: MySQL Access
« Reply #5 on: January 28, 2002, 02:08:34 AM »
Jonny J wrote:
>
> I have to agree with Tom (tom_AT_kvintus.dk), i´m in the same
> situation and i have tried the password from .my.cnf and the
> password from (etc/openldap/ldap.pw) and the result is the
> same every time:
>
> ******
> MySQL Connection Failed: Access denied for user:
> 'root@localhost' (Using password: YES)
> ******
>
> So my question is, are there anyone who has solved the
> problem them selves ?? in that case i would like to hear from
> you.

You shouldn't need to enter the password, assuming your trying this from root's account. mysql will stat the .my.cnf file in your home dir and use the password defined in there.

But if you believe the passwords somehow differ and need to reset the password, you can always just skip the grants table on startup of mysql and drop in a new password, you should use the one in the .my.cnf file.

eg.
[root@sak /root]# service mysqld stop                                            
Stopping MySQL:                                            [   OK   ]

[root@sak /root]# /usr/libexec/mysqld --user=mysql --skip-grant-tables >/dev/null &

[root@sak /root]# mysql -u root mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 3.23.36

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

mysql> update user set password=password('password from /root/.my.cnf') where user='root';                      
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2  Changed: 2  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye

[root@sak /root]# ps -efa | grep mysql | head -1
mysql     7143  6918  0 04:31 pts/1    00:00:00 /usr/libexec/mysqld --user=mysql

[root@sak /root]# kill -9 7143
[1]+  Killed                  /usr/libexec/mysqld --user=mysql --skip-grant-tables

[root@sak /root]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 3.23.36

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

--
 Damien

Jonny J

Re: MySQL Access
« Reply #6 on: January 29, 2002, 01:27:14 AM »
Thanx i´ll try that, but wont i risk disabling the IMP-mailserver ? it uses the password from the .my.cnf file

Damien Curtain

Re: MySQL Access
« Reply #7 on: January 29, 2002, 01:58:36 AM »
The risk is all yours. Though you wont affect webmail as it doesnt use root's account, it has its own.

See the user table for more info.
--
 Damien

Tom

Re: MySQL Access
« Reply #8 on: January 29, 2002, 02:39:05 AM »
I've just reset my password - and it WORKS!!!

Many thanks to you Damien for saving the day :)

Just a question:
What does the lines: "ps -efa | grep mysql | head -1" And "kill -9 7143" do?

Damien Curtain

Re: MySQL Access
« Reply #9 on: January 29, 2002, 02:50:49 AM »
Tom wrote:

> Just a question:
> What does the lines: "ps -efa | grep mysql | head -1" And
> "kill -9 7143" do?

Oh dont just run that. The 1st line just told me the pid of mysql and the second line killed that process.

Thats because I had mysql running without the grants table, and needed to restart it properly.
--
 Damien

Tom

Re: MySQL Access
« Reply #10 on: January 29, 2002, 03:20:39 AM »
Ahh, that's why I got some strange responses :)

Thanks again for the explanation.

BillR

Re: MySQL Access
« Reply #11 on: February 19, 2002, 11:30:36 PM »
Here is a model of the grant statement I use successfully for PHP/MYSQL connection to the database
(from MYSQL site - http://www.mysql.com/doc/A/d/Adding_users.html)

shell> mysql --user=root mysql
mysql> GRANT ALL PRIVILEGES ON *.* TO someuser@localhost
    ->     IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
mysql> GRANT ALL PRIVILEGES ON *.* TO somuser@"%"
    ->     IDENTIFIED BY 'some_pass' WITH GRANT OPTION;

Rob Shiras

Re: MySQL Access
« Reply #12 on: May 20, 2003, 09:09:53 PM »
Try resetting the root mysql password. See:
http://www.mysql.com/doc/en/Resetting_permissions.html

Tom Peck

Re: MySQL Access
« Reply #13 on: May 21, 2003, 03:43:05 AM »
Woha - you did realise that topic was over a year old, didn't you :)

Rob Shiras

Re: MySQL Access
« Reply #14 on: May 23, 2003, 09:30:07 AM »
I will pay more attention to the dates from now on.  Thanks.