2

I'm trying to get Emoncms working on a shared hosting MediaTemple web server with verified prerequisites like mod_rewrite and LAMP server. I've created the database with user and password, configured the settings.php to the best of my ability.

/ - this is root
/emoncmsdata - Its 777 for data folders /phpfina & /phpfiwa & /phptimeseries
/httpdocs - this is my public folder
/httpdocs/emoncms - this is where the settings.php is and where modules are

But when I access santiapps.com/emoncms/ I get:

Can’t connect to database, please verify credentials/configuration in settings.php

Error message: Access denied for user ‘marskoko’@‘localhost’ (using password: NO).

I've put the database, user and password in the script. I've checked it and reset the password through their plesk.

  1. I know the password for that user is correct because I can log in with the password just fine via terminal using mysql -u user -p pass and I get the MariaDB server and I can then enter USE Emoncms and the prompt reads that I'm connected to Emoncms.

  2. The emoncms.log file created by the application is empty. I found a bunch of these in the web server error.log:

    [Fri Sep 28 20:53:23.620729 2018] [proxy_fcgi:error] [pid 8219:tid 140039956670208] [client 83.139.179.122:35214] AH01071: Got error ‘Primary script unknown\n’

  3. I've checked most of the posts in SO about this user password:NO issue and they all pertain to root, which I am not. I'm using another user called marskoko.

    Access denied for user 'root'@'localhost' (using password: NO)?Unable to authenticate php/Mysql?

  4. I can't stop or start the server, I've tried service mysql stop and I get:

    Redirecting to /bin/systemctl stop mysql.service

    Failed to stop mysql.service: Unit mysql.service not loaded.

    4.a) I have recently been suggested to try:

    service mysqld restart
    

    But I get a similar error:

    Redirecting to /bin/systemctl restart mysqld.service

    Failed to restart mysqld.service: Unit not found.

    But I know its running, otherwise I wouldn't be able to view my other databases.

  5. I've created this php file:

    <?php
    $db = mysqli_connect("localhost","marskoko","myPasshasAdollarSign") or die("Failed to open connection to MySQL server.");
    mysqli_select_db($db, "emoncms") or die("Unable to select database");
    \> 
    

    and ran it and I get this:

    Failed to open connection to MySQL server.

    5.a) When I use mysqli_connect_error() I get:

    Access denied for user 'emonuser'@'localhost' (using password: NO)

    NOTE: The user is different because I wanted to make sure there wasn't some issue with the db or user, so I deleted the db and re-created it and changed the username. The db is still there and I can still access it via MariaDB using mysql command and the same password.

  6. I tried this suggestion:

    ps aux | grep mysql

    and I get this:

    mysql     7766  0.0  0.0 113200  1588 ?        Ss   Sep28   0:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
    mysql     8286  0.7  5.4 1906888 457400 ?      Sl   Sep28   5:12 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/lib/mysql/activacorp.net.err --pid-file=activacorp.net.pid --socket=/var/lib/mysql/mysql.sock --port=3306
    root     15702  0.0  0.0 112600  1068 pts/0    S+   09:17   0:00 grep --color=auto mysql
    
  7. I just tried logging into the db with the user/pass and I tried getting the table of users but got this:

    MariaDB [emoncms]> select * from user;
    ERROR 1146 (42S02): Table 'emoncms.user' doesn't exist
    

Then again I just checked all my databases and neither have the users table in it. They have other tables which Ive added and work with, but not the user table. Maybe phpmyadmin hides that, I dunno.

I dunno what else to try.

bad_coder
  • 11,289
  • 20
  • 44
  • 72
marciokoko
  • 4,988
  • 8
  • 51
  • 91

2 Answers2

0

i think you can resolve this by the steps following

  1. start/stop mysql by using service mysqld start/stop/restart instead of service mysql start/stop/restart

  2. make sure you got the right password for mysql user - root, if no, please reset password by following step 3, else, skip step 3

  3. edit mysql config file, usually /etc/my.cny, add skip-grant-tables under [mysqld], then restart mysql, now you can go into mysql without password, then reset password by using

    update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';

    flush privileges;

  4. that is all, please check it

tyloafer
  • 123
  • 7
  • I do have the right password for that user. I have reset it and tried it via terminal like I said, so I know its the right password for that user. Also restarting with that command doesnt work. I updated my post... About the root user, why are you asking me about the root user, Im using the user i created for this database which is marskoko – marciokoko Sep 29 '18 at 03:37
  • there is no difference so do you have two questions? 1. how to resatrt mysql 2. why you get coinnection error 1. exec `ps aux | grep mysql` to see how mysql start 2. `$db = mysqli_connect("localhost","marskoko","myPasshasAdollarSign") or die(mysqli_connect_error());` to get the specific reason then please show me all the result – tyloafer Sep 29 '18 at 05:28
  • Then I don't have to reset it because the password is indeed correct as confirmed by logging into it via mysql command – marciokoko Sep 29 '18 at 05:29
  • Ok I tried the ps aux and the mysqli command and updated the OP – marciokoko Sep 29 '18 at 13:29
  • I was able to get rid of the error using mysqli_connect() somehow. Now what else can I try? – marciokoko Sep 29 '18 at 17:16
  • nevermind, i didnt get rid of the error. i had accidentally added a > at the end of the php file so there was a parse error hiding the credentials error. – marciokoko Sep 29 '18 at 23:12
  • so can you get into mysql by using shell command `mysql -uemonuser -pmyPasshasAdollarSign -h localhost` or `mysql -uemonuser -pmyPasshasAdollarSign -h 127.0.0.1` – tyloafer Sep 30 '18 at 02:24
0

Ok I figured it out. Digging around the php I tried logging the $password variable in the index.php of emoncms and it logged blank whilst the username, database or other variables logged correctly. I ended up replacing the $password for the actual password in the mysqli line and it works now. So then I just replaced the $password "" for '' and it works now.

marciokoko
  • 4,988
  • 8
  • 51
  • 91