Cant connect to MySQL server

Warning: mysqli::mysqli(): (HY000/2003): Can't connect to MySQL server on '10.40.5.18' (111) in /var/www/emoncms/Includes/db.php on line 28

I have checked  "settings.php" and  the details correspond to those I entered in phpmyadmin. I have also made sure that the database exists by trying to open another with the name "emoncms" directly in mysql, and it tells me that the database already exists.  The server is running Ubuntu 12.04 LTS. Any help would be appreciated as it has been really hard work just to get this far!

TrystanLea's picture

Re: Cant connect to MySQL server

Is your mysql server up and running? 

sudo /etc/init.d/mysql start

boxer_ian's picture

Re: Cant connect to MySQL server

yes, service is running

mharizanov's picture

Re: Cant connect to MySQL server

why not try 127.0.0.1 as IP? 

boxer_ian's picture

Re: Cant connect to MySQL server

Many thanks for taking the time to reply, I would never have tried that IP. EMONCMS set up has established all the tables, but EMONCMS falls over at the log in screen. Mod-rewrite is enabled as per the instructions, but I still get the error:

The requested URL /emoncms/user/create was not found on this server

 

Any suggestions please?

TrystanLea's picture

Re: Cant connect to MySQL server

Can you show a print out of your  /etc/apache2/sites-enabled/000-default here? 

The error The requested URL /emoncms/user/create was not found on this server should only occur when mod_rewrite is not enabled

mod_rewrite is required because user/create is not actually a directory but using mod_rewrite it is converted to a query such as emoncms.org?q=user/create, the application then creates the page accordingly. Without mod rewrite it will try and find a file called create in folder user and as that does not exist it will give the not found error.

boxer_ian's picture

Re: Cant connect to MySQL server

ServerAdmin webmaster@localhost

 

DocumentRoot  /var/www

<Directory />

     Options FollowSymLinks

     AllowOverride All

</Directory>

<Directory /var/www/>

    Options Indexes FollowSymLinks MultiViews

    AllowOverride All

    Order allow,deny

   allow from all

</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

<Directory "/usr/lib/cgi-bin">

   AllowOverride None

   Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch

   [ Read 41 lines (Warning: No write permission) ]

boxer_ian's picture

Re: Cant connect to MySQL server

Now resolved. I started with a fresh installation on my server and all now working.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.