LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   MYSQL refuses to connect (https://www.linuxquestions.org/questions/linux-newbie-8/mysql-refuses-to-connect-89871/)

edhan 09-06-2003 09:48 AM

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

david_ross 09-06-2003 09:55 AM

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.

paulg 09-06-2003 07:51 PM

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}.

edhan 09-06-2003 08:34 PM

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

ZenithRS 09-07-2003 02:36 AM

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

ZenithRS 09-07-2003 02:43 AM

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.

edhan 09-07-2003 02:52 AM

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

edhan 09-07-2003 09:40 AM

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

david_ross 09-07-2003 10:02 AM

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

Looking_Lost 09-07-2003 04:10 PM

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

ZenithRS 09-07-2003 04:59 PM

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().

edhan 09-07-2003 07:14 PM

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

ZenithRS 09-07-2003 07:28 PM

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?

edhan 09-07-2003 08:27 PM

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

ZenithRS 09-07-2003 08:45 PM

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.


All times are GMT -5. The time now is 10:36 AM.