Koozali.org: home of the SME Server

mysql acces denied(solved)

Offline MasthaX

  • ***
  • 52
  • +0/-0
mysql acces denied(solved)
« 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?
There's no place like 127.0.0.1

Offline byte

  • *
  • 2,183
  • +2/-0
Re: mysql acces denied
« Reply #1 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
--[byte]--

Have you filled in a Bug Report over @ http://bugs.contribs.org ? Please don't wait to be told this way you help us to help you/others - Thanks!

Offline MasthaX

  • ***
  • 52
  • +0/-0
mysql acces denied(solved)
« Reply #2 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.
There's no place like 127.0.0.1

Offline Confucius

  • *****
  • 235
  • +0/-0
mysql acces denied(solved)
« Reply #3 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.

Offline cjensen

  • *
  • 133
  • +0/-0
    • http://acenet-tech.org
mysql acces denied(solved)
« Reply #4 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

Offline MasthaX

  • ***
  • 52
  • +0/-0
mysql acces denied(solved)
« Reply #5 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.
There's no place like 127.0.0.1

Offline cjensen

  • *
  • 133
  • +0/-0
    • http://acenet-tech.org
mysql acces denied(solved)
« Reply #6 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

Offline MasthaX

  • ***
  • 52
  • +0/-0
mysql acces denied(solved)
« Reply #7 on: May 08, 2007, 01:33:15 AM »
Thankyou this worked for me! :lol:
There's no place like 127.0.0.1