Koozali.org: home of the SME Server

Obsolete Releases => SME Server 7.x => Topic started by: MasthaX on May 07, 2007, 08:25:19 PM

Title: mysql acces denied(solved)
Post by: MasthaX on May 07, 2007, 08:25:19 PM
Im getting acces denied when i try to use MYSQL from command prompt when i start mysql and run query's it works. I cant connect to mysql with PHP because root doesnt have access it says.

Code: [Select]

#mysql

// welcome mysql blablaba

-> CREATE TABLE `users`;

works

but
Code: [Select]

#mysql -h localhost -u root -p  samp_db < ~/data/query.sql


this doesnt work. When i do this it asks for a password. I know root hasnt got a standard password so if i just press enter it says acces denied. When i enter my root password it says access denied again. So how can i solve this?
Title: Re: mysql acces denied
Post by: byte on May 07, 2007, 08:42:18 PM
Quote from: "MasthaX"
So how can i solve this?


Have a read of this...

http://wiki.contribs.org/MySQL#Login_as_MySQL_root_user
Title: mysql acces denied(solved)
Post by: MasthaX on May 07, 2007, 09:10:52 PM
i did, but still without any luck.

FE i cant log into phpmyadmin

When i use root without password it doenst work.
When i use root with my normal root password it doesnt work.
When i use admin with admin/root password it doenst work.
Title: mysql acces denied(solved)
Post by: Confucius on May 07, 2007, 10:23:05 PM
Somebody is missing the point here...

I quote from the reference given to you:

Quote

Login as MySQL root user

To login as MySQL root user, simply type 'mysql' at the SME Server shell, this will log you in with root privileges.
Title: mysql acces denied(solved)
Post by: cjensen on May 07, 2007, 10:42:26 PM
As described by Confucius and Byte, if you try 'logging in' to MySQL as root rather than 'logging in' to your server as root and then 'entering' MySQL, you run the risk of changing your root password for MySQL which creates it's own bit of fun ;-)

Craig
Title: mysql acces denied(solved)
Post by: MasthaX on May 07, 2007, 11:41:17 PM
I can access it by shell just cant access it from outside of the shell. FE in my PHP pages.
Title: mysql acces denied(solved)
Post by: cjensen on May 08, 2007, 12:12:48 AM
In your PHP pages you need to create/use a db script to access mysql with a 'non-root' user (one you already created)

You DON'T want to use 'root' to access databases in your PHP.  Create a non-root user in mysql and grant permissions.

Most apps have a 'config.inc.php' or some similar script which allows setting up your db connection settings.

create the db:

Code: [Select]
mysqladmin create mydatabase

enter mysql:

Code: [Select]
[root@station70 ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3040 to server version: 4.1.20

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

mysql>


grant permissions:

Code: [Select]
mysql> grant all on mydatabase.* to nonrootuser@localhost identified by '3d0JYcSoyT4ogrvsMYP19OylGXze/odfjPajCMFl098WDiq';

where mydatabase is the db, nonrootuser is the user, and the string between '' is the password.

Craig
Title: mysql acces denied(solved)
Post by: MasthaX on May 08, 2007, 01:33:15 AM
Thankyou this worked for me! :lol: