Installer can't connect to the database

Started by altiris, July 01, 2014, 01:14:50 PM

Previous topic - Next topic

altiris

Hey everyone, I am new to SMF and this website! I am very eager to setting up my own SMF site. I am setting up the latest version of SMF on a CentOS 6.5 server with mysql 5.1.73, php-5.3.3 and apache-2.2.15. However, I am having a bit of trouble with setting this up, I have reached the point in the installer where it asks for my Database Server Settings. I created a new database and user for SMF called smf and granted all privileges to the user smf. These are the commands that I used to create the database, user, and to grant privileges (smf is the username and also databasename and password is a placeholder for what my actual password would be)
CREATE USER 'smf'@'localhost' IDENTIFIED BY 'password';
CREATE DATABASE IF NOT EXISTS smf;
GRANT ALL PRIVILEGES ON smf.* TO 'smf'@'localhost' IDENTIFIED BY 'password';


When I input the username, password, and database name  and localhost as the server name into the installer I get this error message

Critical Error!
Cannot connect to the database server with the supplied data.

If you are not sure about what to type in, please contact your host.
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock # Debian squeeze: /var/run/mysqld/mysqld.sock' (2)


If I put my fully qualified domain name in the "Server name" instead of localhost (the installer originally had my fully qualified domain name in there) I get this error message

Cannot connect to the database server with the supplied data.

If you are not sure about what to type in, please contact your host.
Access denied for user 'smf'@'mycomputer.mydomain.com' (using password: YES)

kat


ziycon

Can you manually connect to the database via the command line on the server using those details?
mysql -u{username} -p {database}

From what you've said it would be:
mysql -usmf -p smf

altiris

#3
Quote from: K@ on July 02, 2014, 05:24:20 AM


Is this all self-hosted?
Yes this all self hosted at my home, I have direct access to everything.

altiris

Quote from: ziycon on July 02, 2014, 05:26:28 AM
Can you manually connect to the database via the command line on the server using those details?
mysql -u{username} -p {database}

From what you've said it would be:
mysql -usmf -p smf
I entered that command into the terminal and I was connected into mysql so what I assume this would mean yes?

ziycon

Quote from: altiris on July 02, 2014, 12:32:07 PM
Quote from: ziycon on July 02, 2014, 05:26:28 AM
Can you manually connect to the database via the command line on the server using those details?
mysql -u{username} -p {database}

From what you've said it would be:
mysql -usmf -p smf
I entered that command into the terminal and I was connected into mysql so what I assume this would mean yes?
Did you enter the db password when promoted and did it connect with no issues?

altiris

Quote from: ziycon on July 02, 2014, 01:07:20 PM
Quote from: altiris on July 02, 2014, 12:32:07 PM
Quote from: ziycon on July 02, 2014, 05:26:28 AM
Can you manually connect to the database via the command line on the server using those details?
mysql -u{username} -p {database}

From what you've said it would be:
mysql -usmf -p smf
I entered that command into the terminal and I was connected into mysql so what I assume this would mean yes?
Did you enter the db password when promoted and did it connect with no issues?
Yes I entered the password when promoted and it didnt give any errors so no it did not connect with any issues.

ziycon

If you create a new file php file in your web root directory with the below code in it, next browse to this page in your browser, does it contain information about mysql or mysqli?

<?php
phpinfo
();

altiris

Quote from: ziycon on July 03, 2014, 04:42:46 AM
If you create a new file php file in your web root directory with the below code in it, next browse to this page in your browser, does it contain information about mysql or mysqli?

<?php
phpinfo
();

Yes, it gives information about both mysql and mysqli.

ziycon


altiris

#10
Quote from: ziycon on July 03, 2014, 12:15:47 PM
Completely missed the sock error part, have a look here, http://www.tech-recipes.com/rx/762/solve-cant-connect-to-local-mysql-server-through-socket-tmpmysqlsock/ [nofollow]
That is a nice read, I noticed that my mysql socket is in /var/lib/mysql/mysql.sock instead of being in /tmp/mysql.sock like the article says it should be? Will it be safe to change this? I have owncloud, roundcube and bacula using mysql, will this have any effect on them? Do I only need to change the socket for installing SMF and then I can change it back to /var/lib/mysql/mysql.sock ?

ziycon

You just need to update your my.cnf with the location of your mysql.sock file and any application using mysql will pick it up through the config file, everything should work like normal.

altiris

#12
Quote from: ziycon on July 04, 2014, 02:37:55 AM
You just need to update your my.cnf with the location of your mysql.sock file and any application using mysql will pick it up through the config file, everything should work like normal.
I see, I will try it and report back. Alright so I changed the socket to socket=/tmp/mysql.sock in /etc/my.cnf and when I restart mysqld it fails to start. If I put the socket back to socket=/var/lib/mysql/mysql.sock then mysql will start again. I have looked online and it has to do with SELinux preventing MySQL to write to any other location.

Now, as a test to see if changing the socket will make SMF work, I have disabled SELinux (just for testing) and changed the socket at /tmp/mysql.sock and mysql restarts successfully (unlike before with SELinux on). However, when I try to get SMF to connect to the database (both with trying my fully qualified domain name and localhost like I did in OP) I got the same error(s). I try going logging into my mail server using roundcube and I get an error saying that it can't connect to the database, so now I know this has to do with permissions. I have posted a question about this on the CentOS forum and hopefully I will receieve some aid about permissions and SELinux when changing the mysql socket.

Is there a way I can just change SMF to use/var/lib/mysql/mysql.sock rather than /tmp/mysql.sock ?

kat

Quote from: altiris on July 04, 2014, 02:07:28 PMI will try it and report back.

* K@ wonders what the report's gonna be...

altiris

Quote from: K@ on July 15, 2014, 11:40:33 AM
Quote from: altiris on July 04, 2014, 02:07:28 PMI will try it and report back.

* K@ wonders what the report's gonna be...
I already reported back, it started at "Now, as a test". I shouldve wrote EDIT or something but it says that I edited it at the bottom, sorry. I also went to CentOS forums about this and while they couldnt offer too much help in this field, they said that its not recommended to change the mysql.sock to the /tmp folder.

altiris

Can anyone else offer any insight on what the problem could be? Is it a bug?

Arantor

Is MySQL listening on port 3306? Or sockets only?

altiris

Quote from: ‽ on July 27, 2014, 12:58:28 PM
Is MySQL listening on port 3306? Or sockets only?
Its using port 3306

altiris

I found the issue, mysql.sock was duplicated twice , once in /etc/php.d/mysql.ini an also in /etc/php.d/pdo_mysql.ini 

The pdo_mysqlini file should contain only extension=pdo_mysql.so  (remove anything else)

For people experiencing a problem like this, use the command grep -i mysql /etc/php.d/*.ini to check for duplicates.

Advertisement: