LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-06-2003, 09:48 AM   #1
edhan
Member
 
Registered: Sep 2003
Location: Singapore
Distribution: Redhat 8.0
Posts: 93

Rep: Reputation: 15
Unhappy MYSQL refuses to connect


Hi

I am getting frustrated with MySQL. I have installed RH8.0 that comes with the MySQL Server. I am using Webmin-1.100 to configure and running the MySQL Server.

I am able to run the MySQL Server without password as root. I tried to create a password for root using the following command:

mysqladmin password
mysqladmin -u root password 'mynewpassword'

But it gives user access denied.

I have noticed that the hostname is root@localhost, is that normal ?

I intention of using the MySQL Server is for my existing database and has the username as mysql. I have created the new account as mysql and unable to set a password for it [ using the module config in Webmin ]. No matter how many times I specify the username and password, it does not register as I can login without the password. It also does not allow me to access the database after login without a password.

My questions are:

1. How can I create a new username and password?
2. After creating it, how can I link this username and password with my existing database?

If anyone can help, I am greatly grateful! Thanks!

Regards
Edward Han
 
Old 09-06-2003, 09:55 AM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
The way I tend to do it is create a new database as root:
mysqladmn create MY_DB_NAME

Then run "mysql" as root an grant permissions to a user:
grant all on MY_DB_NAME.* to SOMEUSER@localhost identified by 'SOMEPASSWORD';

The phpMyAdmin web interface is much better for administering mysql than webmin is.
 
Old 09-06-2003, 07:51 PM   #3
paulg
LQ Newbie
 
Registered: Sep 2003
Location: uk
Distribution: suse 8.1
Posts: 14

Rep: Reputation: 0
When messing with the master table - you may also need to then "flush privileges" before any changes are recognised.

Else {you could rip your hair out}.
 
Old 09-06-2003, 08:34 PM   #4
edhan
Member
 
Registered: Sep 2003
Location: Singapore
Distribution: Redhat 8.0
Posts: 93

Original Poster
Rep: Reputation: 15
Hi

Err.. as I am very new to MySQL, I am a little blur on what you have said. I should have no problem in creating a new database.
I do not understand about run mysql as root to grant all permission for the new database. Do you know the command?

Btw, where I get the phpMyAdmin?

Thanks! Your help is greatly appreciated!

Regards
Edward Han
 
Old 09-07-2003, 02:36 AM   #5
ZenithRS
LQ Newbie
 
Registered: Dec 2002
Posts: 24

Rep: Reputation: 15
Logon to mysql as root with no password (you are able to do this yes?)

mysql -u root mysql

The reason you can logon to mysql as root without a password is that there's a default entry in the mysql user table for root with no password. At the mysql prompt

UPDATE user SET password=PASSWORD('password') WHERE user='root';

Then at the prompt...

GRANT ALL ON *.* TO mysql@localhost IDENTIFIED BY 'password';

will create the user mysql for you.

I also like to delete the root user with the wildcard host to make sure root can only logon to mysql while on the localhost.

Good reading for this is ...

http://www.mysql.com/doc/en/Privilege_system.html

and

http://www.mysql.com/doc/en/User_Acc...anagement.html
 
Old 09-07-2003, 02:43 AM   #6
ZenithRS
LQ Newbie
 
Registered: Dec 2002
Posts: 24

Rep: Reputation: 15
Oh, yeah, I forgot, as mentioned by paulg, you'll have to issue the command

flush privileges;

at the mysql prompt for the changes to take effect.
 
Old 09-07-2003, 02:52 AM   #7
edhan
Member
 
Registered: Sep 2003
Location: Singapore
Distribution: Redhat 8.0
Posts: 93

Original Poster
Rep: Reputation: 15
Hi

Okay. Thanks for the help. I will try out what you have taught me and hopefully everything will be okay.

I will let you know if I have encountered problem.

Regards
Edward Han
 
Old 09-07-2003, 09:40 AM   #8
edhan
Member
 
Registered: Sep 2003
Location: Singapore
Distribution: Redhat 8.0
Posts: 93

Original Poster
Rep: Reputation: 15
Hi

After trying out what you have said. It is still unable to connect with the database. Even though I have grant all permission and rights using Webmin for the user [mysql], it is still unable to connect with the database.

Is there a simple example where I can test a sample of database with the mysql ? It is getting frustrating as I am re-installing the entire RH8.0 more than 8 times already. I am really confused with the mysql as I have no exprience with it.

Also, I tried installing phpMyAdmin but couldn't get it running.

Regards
Edward Han
 
Old 09-07-2003, 10:02 AM   #9
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Why are you reinstalling?

If you want to set an initial root password then:
# Stop mysqld
/etc/rc.d/init.d/mysqld stop

# Start mysqld skipping the gran table
/usr/bin/mysqld_safe --skip-grant-tables &

# Change your password
mqsqladmin -u root password 'newpassword'

# Stop mqsqld processes
killall mysqld

# Start mysql again
/etc/rc.d/init.d/mysqld start
 
Old 09-07-2003, 04:10 PM   #10
Looking_Lost
Senior Member
 
Registered: Apr 2003
Location: Eire
Distribution: Slackware 12.0, OpenSuse 10.3
Posts: 1,120

Rep: Reputation: 45
There's another command line tool you might want to try out

mysql_setpermission -u root

Gives you a menu orientated view to change passwords and access to databases, create users etc.. Give it a go and take your time going through it.

I wouldn't keep reinstalling Red Hat, if you've got to start from scratch , start from scratch with the thing that's causing you the problem
 
Old 09-07-2003, 04:59 PM   #11
ZenithRS
LQ Newbie
 
Registered: Dec 2002
Posts: 24

Rep: Reputation: 15
Quote:
Originally posted by edhan
Hi

After trying out what you have said. It is still unable to connect with the database. Even though I have grant all permission and rights using Webmin for the user [mysql], it is still unable to connect with the database.
Erm.. unable to connect from where? The command line, or from within a PHP script like Webmin? If you mean your script can't connect to the database check that you have mysql support installed for PHP. The package is php-mysql or something very close to that. I know that RedHat does NOT install it by default, so PHP can't connect to mysql databases... get an error mentioning mysqlp_connect().
 
Old 09-07-2003, 07:14 PM   #12
edhan
Member
 
Registered: Sep 2003
Location: Singapore
Distribution: Redhat 8.0
Posts: 93

Original Poster
Rep: Reputation: 15
Hi

I have enable from the service of the RH8.0 to run MySQL. I have installed Webmin-1.100 to activate the MySQL to start or stop.

I am using PHP to try and connect with my database but it simply refused to do so. After many attempts of re-installing and trying to get it running with password, it still can't work.

Now I am deciding to upgrade the current version of 3.25 to 4.0 but unsure of which one to download as I am new to Linux. I look at the MySQL site and found that there are so many version of mysql, so which one do I need to download for RH8.0?

Please advice if you know.

Regards
Edward Han
 
Old 09-07-2003, 07:28 PM   #13
ZenithRS
LQ Newbie
 
Registered: Dec 2002
Posts: 24

Rep: Reputation: 15
Re-read my post.

Having MYSQL installed and running fine doesn't automatically mean that you have mysql support for PHP installed.

I know that RedHat 8 does not install php-mysql unless you do a custom install and select the package php-mysql.

Exactly what is the error message you receive when you try to connect through a PHP script?
 
Old 09-07-2003, 08:27 PM   #14
edhan
Member
 
Registered: Sep 2003
Location: Singapore
Distribution: Redhat 8.0
Posts: 93

Original Poster
Rep: Reputation: 15
Hi

The error I have encountered ins undefined function.

How do you do the custom install with the php-mysql? If I want to upgrade the MySQL for RH8.0, which one should I be downloading ?

Thanks!

Regards
Edward Han
 
Old 09-07-2003, 08:45 PM   #15
ZenithRS
LQ Newbie
 
Registered: Dec 2002
Posts: 24

Rep: Reputation: 15
Undefined function huh? Undefined function mysql_pconnect() ?

OK, all you have to do is install the php-mysql package. Either from your redhat cds, or download it.

Go to www.rpmfind.net and search for php-mysql

In the results you'll find an rpm for "RedHat-8.0 Updates for i386". Filename is php-mysql-4.2.2-8.0.8.i386.rpm

rpm -ivh php-mysql-4.2.2-8.0.8.i386.rpm

Good luck.
 
  


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
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. suziecorbett Linux - Software 8 10-09-2008 01:52 AM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. Dannux Linux - Software 3 03-24-2006 08:44 AM
Gaim refuses to connect cpu886 Linux - Software 1 08-08-2005 03:15 PM
Apollon refuses to connect. Courthold Linux - Software 4 08-01-2004 04:26 PM
KPPP refuses to connect musasabi Linux - Networking 5 07-20-2004 11:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:18 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