Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Installing SilverStripe /

Getting SilverStripe up and running on your computer and on your web server.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

[Warning] mysql_connect() [function.mysql-connect]: Access denied for user


Reply


8 Posts   11217 Views

Avatar
jonny da pigg

Community Member, 8 Posts

20 April 2011 at 7:38pm

How do and ta for even reading this, if you are, if you're not then i take it back. Rights I'm a noob to this so be gentle. i'm getting the error (in full below) when I'm publishing my site to my live server. I'm fairly certain this will turn out to be something simple that i've missed as all the other errors i've had since starting with ss have (various conflicting programs not giving me access tomy localhost myphpadmin being the worst as i had to uninstall everything to reinstall from scratch only to find out i had to disable one). any how that's off topic and one for a blog tutorial.
i published my site from the WebMatrix control panel (ftp) all was going well, did ?flush=1 on the live site and got this. (i've starred out password etc but they have been checked and they are correct) line 57 is highlighted in red

[Warning] mysql_connect() [function.mysql-connect]: Access denied for user '*****'@'localhost' (using password: YES)
GET /testsite/?flush=1

Line 57 in /home/mydomain/public_html/tynesidetshirts/sapphire/core/model/MySQLDatabase.php

Source

48     * Connect to a MySQL database.
49     * @param array $parameters An map of parameters, which should include:
50     * - server: The server, eg, localhost
51     * - username: The username to log on with
52     * - password: The password to log on with
53     * - database: The database to connect to
54     * - timezone: (optional) The timezone offset. For example: +12:00, "Pacific/Auckland", or "SYSTEM"
55     */
56    public function __construct($parameters) {
57       $this->dbConn = mysql_connect($parameters['server'], $parameters['username'], $parameters['password'], true);
58
59       if(self::$connection_charset) {
60          $this->query("SET CHARACTER SET '" . self::$connection_charset . "'");
61          $this->query("SET NAMES '" . self::$connection_charset . "'");
62       }

Trace

* mysql_connect(localhost,*****,********,1)
Line 57 of MySQLDatabase.php
* MySQLDatabase->__construct(Array)
Line 97 of DB.php
* DB::connect(Array)
Line 121 of main.php

any of this make sense to anyone? personally i'm coming from the visual design side of things with a decent html knowledge. the way that silverstripe creates these site is amazing to me and i'm getting there with the understanding but this error (as i said earlier i've had a few and managed to work around) has got me stumped. it's going to be something daft...
i'm running xp, xampp and MySQL client version: 4.1.22(from server control panel)
cheers in advance
jonny

Avatar
martimiz

Forum Moderator, 1132 Posts

20 April 2011 at 9:43pm

Looks like PHP (not SilverStripe) is telling you that user '****', using the provided password, has no access to the database on server 'localhost', so it can't connect. just to make sure, check again the following data in your live /mysite/_config.php file against the mysql login data provided by your live server host:

$databaseConfig = array(
   "type" => 'MySQLDatabase',
   "server" => 'your mysql server', <--- !!!
   "username" => '*********',
   "password" => '*********',
   "database" => 'your live database name',
   "path" => '',
);

Avatar
jonny da pigg

Community Member, 8 Posts

21 April 2011 at 7:18pm

Edited: 22/04/2011 7:51am

aye i thought it would be something like that but it all checks out... i'm gonna take everything down, triple check it all, reupload and and i'll post my results.
cheers

ps, please ignore the twat below, i've got further on and i'm nearly there, see my last post.
ta

Avatar
jonny da pigg

Community Member, 8 Posts

21 April 2011 at 8:31pm

Edited: 21/04/2011 9:28pm

rights then, had missed a letter on the db and username (swine cos it was a copy and paste job, how d'you f00k that one up) any how, i created a new database with myphpadmin, imported the misspelled one, changed the _ss-set_enviroment.php and the mysite/_config.php file to the new one, ?flush=1 and same error (laptop not gone to server yet). now i had a look at the WebMatrix side of it and the warning at the bottom there has the old username on it, but the right db name. anyone know where else is this info is stored?
cheers again

quick update, site is now showing on my laptop, kind of. themes page types all there, content all gone pages etc, hadn't actually got any real content in other than a jquery banner embedded in the home page, which is still there, so i'm sort of lying. but the page structure is back to the default, the spine of the site. when i have a look at the database files via the webmatrix panel (see the pic)
any ideas?

Attached Files
Avatar
N3mA

Community Member, 3 Posts

6 September 2012 at 8:02pm

Hi,

I am a SilverStripe newbie. I am working with a project which has a database in mysql and they use silverstripe. I want to run a project on localhost but have a problem with connecting the database.

My question is, how can I connect current database with silverstripe and run the project?

Thanks in advance!

Avatar
jonny da pigg

Community Member, 8 Posts

6 September 2012 at 10:13pm

how do, forgot all about this post. you should just be able to export the database from the existing silverstripe, install silverstripe to your system and import the database through your localhost myphp admin. this make sense? just make sure that the database tables are in the correct case if you think anything's missing. the problem i had above was that when i installed to the server and imported the database it didn't overwrite because the tables started with an uppercase letter and the server side ones didn't. windows/linux disagreement it seemed. took me a while to work that out, had to rename a lot of tables....

Avatar
Rossel

Community Member, 18 Posts

2 August 2013 at 10:11pm

Just had a similar problem, my error was that my mysql password contained symbols, including a backslash. I wouldnt have thought that this would be a problem but for some reason in my mysite/_config.php the installer had repeated the backslash multiple times when altering the file. So in the installer check it was telling me that everthing was correct but the installer would fail because the _config.php file had the wrong password.

...maybe this could help someone.

Avatar
Christy

Community Member, 58 Posts

4 September 2013 at 9:27am

It did, thank you. My problem was an underscore in the database user name.