phpBB and mySQL "Could not connect to the database..." - php

I am trying to set up a phpBB forum on a locally hosted webpage. It being done in an openSUSE Linux OS.
I have installed MariaDB (MySQL), and created a new database named new_database using the command CREATE DATABASE new_database;, along with a user named user with the command CREATE USER 'new_user'#'localhost' IDENTIFIED BY 'password';. I also changed the root password to password, just for testing purposes.
When I enter this info into the phpBB installation database settings screen, I get the error
Could not connect to the database, see error message below.
Access denied for user 'new_user'#'localhost' to database 'new_database'.
I am using localhost for the DSN. Any ideas? From everything I've found online it should be working...

After you create the user you have to Grant Privileges, this is how you do it.
GRANT ALL PRIVILEGES ON new_database.* TO 'newuser'#'localhost';
Do not forget to flush.
FLUSH PRIVILEGES
Common Privileges
ALL PRIVILEGES- all access
CREATE- allows them to create new tables or databases
DROP- allows them to them to delete tables or databases
DELETE- allows them to delete rows from tables
INSERT- allows them to insert rows into tables
SELECT- allows them to use the Select command to read through databases
UPDATE- allow them to update table rows
GRANT OPTION- allows them to grant or remove other users' privileges
You can specify the database and table.
new_database.* (Specific Database, all tables)
new_database.table (Specific Database, specific table)
*.* (all databases, al tables)

I had the same issue with a phpBB install and solved the problem by accessing the database through phpMyAdmin and noticing on the splash page it said "User: pits#localhost", which was different from the user (pits_bull) I had created and attached to the database and was trying to connect with.
I tried it with just "pits" and it worked. Not sure whether there is a security issue with that though, or why it worked, but it IS working!

Related

MySQL information_schema.tables is not creating new entries

I have a simple Droplet setup in Digital Ocean and I installed MySQL in it. I also installed PhpMyAdmin for UI control of the databases.
My problem is when I try to import/create Database through PhpMyAdmin or using script (php), the information_schema.tables does not create new entries of the currently imported/created database.
Check your user privileges by witch you are connecting phpmyadmin or your php script, manage that user permissions and add privilege for creating database.

Can't access a newly installed PostgreSQL from a php script

First of all I am new to PostgreSQL coming from MySQL. I have just installed PostgreSQL from the Fedora repositories and created the postgres user as per the fedora wiki pages, by su-ing into the postgres user and creating its role using the psql shell.
# su - postgres
$ psql
> \password
Then I created a test script that is served through nginx that will create a test DB and populate it. I'm trying to log in from the script by using the postgres user and its password via peer authentication, with the following pdo dsn:
new PDO('pgsql:user=postgres password=**********');
However, after struggling with SELinux, the connection fails saying that the peer authentication failed, so I looked into the postgresql logs and found that:
The delivered username (postgres) and the athenticated username (apache) do not match.
So I can deduce that the user that owns the process that's trying to access the db is the user that's being authenticated, so I assume I have to create the corresponding role for the apache user in the db. But why does it do this? Is it some sort of security measure? Is there a way to use the postgres role or am I bound to the apache role?
Do not use the postgres user for applications. It's an administrative role. It's like running a web server as root. Create less-privileged users for your applications. You may also want to CREATE DATABASE ... WITH OWNER myappuser; to give the app ownership of a database, unless you plan to use finer-grained security.
Create a user for your application to use. Set a randomly generated password, and record that password so your app can use it.
Create a database for the app to use, with the app user as the owner of the database. (This isn't ideal, but it's the simple way. To learn more, read the PostgreSQL manual's chapters on security and privileges.)
Modify pg_hba.conf to add an entry for the user on that database that uses md5 authentication, at least for the database(s) of interest. Make sure the entry is above the default peer entries.
Then reload PostgreSQL's configuration - SELECT pg_reload_conf().
Your app can now connect to PostgreSQL using a password, but you can still get simple peer authentication with psql on the command line.

phpMyAdmin and mysql not showing the same database

I have setup WAMP which I managed by using a tutorial and everything seems fine... I am logging into mysql as the root user with full privileges granted and I am able to create databases in mysql and view them by using SHOW DATABASES; so far so good !
...However...
When I access phpMyAdmin and go to the databases section, there are no databases which I have created in mysql, even though phpMyAdmin shows the Database server as User:root#localhost which is the same user I am accessing mysql with.
This situation is also the same when reversed, I can create a database as the root user in phpMyAdmin but the database will not show in mysql when I am logged in as root user and use SHOW DATABASES;
i have tried every soution available ONLINE ..
most of them saying about
$cfg['Servers'][$i]['hide_db'] = '';
i have done that too ....
but nothing seems to work....
plzzzz help

MySQL not showing databases created in phpMyAdmin

I'm trying to build a database for my server in phpmyadmin but when I finish building it I can't access it using PHP and it won't show when I list the databases in MySQL. But when I create a database in mySql it shows up in phpmyadmin. Also I'm running phpmyadmin version 4.0.3, and theres a statement at the bottom of the page saying The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. To find out why click here.
Thanks!
I just had the problem, and realized that I was creating database with names with '_test' suffixes.
It happens that phpmyadmin has a feature to hide some DBs. To change that behaviour, you can navigate to : settings > features > general > Hide databases
By default, hiddent databases have these patterns : information_schema|mysql|performance_schema|test|phpmyadmin
If you Still don't see it, Try to logout and then log in again to cPanel or PHPMyAdmin. It worked for me.
This sounds like a permissions issue. I'd guess that your phpMyAdmin is connecting to MySQL as root (or another user with the superuser privilege) and can therefore see all databases. Your app is probably connected using a different, lower privileged user.
Try running select user(); from your app and from phpMyAdmin and you will know for sure.
Assuming your app is running with a different user, you will need to add privilages for it to access the database you create. Please read the section titled Assigning privileges to user for a specific database in the phpMyAdmin documentation.
This is pure permission issue.
If you logged in without specifying the user, you won't see all the databases just like #t3po7re5 mentioned. What you should do is specify root user in your command.
mysql -uroot -p
It will prompt you to then enter the password. this is the default password if you have not specified or changed the default root password depending on the local server you are using.

Mysql workbench shows wrong database instances

In order to create a new database i use Plesk Panel.
I am also using mysql workbench to administer my database instances.
The problem is that when i connect to a database in my server (via workbench) using its unique credentials (database user and passwd) i'm able to see another database instace as well that i have created for another domain in my server via plesk panel.
This second database instance has different credentials from the ones i used to login to the initial database and therefore shouldn't be visible at all.
Does anyone has a clue of how this can happen?
Both are likely linked to your account. I've used a shared hosting environment (Plesk) before where I could see all the database names on the entire server but without the correct credentials I wasn't able to access any of them or view their table structure (I found out because I didn't want others accessing my database).
I would check with your web host for more information.
You don't connect to a database, but you connect to a server. The user you are connecting with has been given privileges to access db objects according to the domain it belongs to. However, if the user you connected with is allowed to enumerate schemas then you will be able to see all defined schemas (= databases) on this server. That doesn't mean you can access it. No reason to worry unless you don't want users to see schemas they have no rights for.
Use the Server Administration section where you can list all users and see what privileges they have for which db object.
First of all thanks a lot for your time and answers.
The reason behind my problem was the actual name of the database instance I had created, which contained the word "test_".
Every database instance created with this text inside its name was visible to every database user when using mysql workbench.
I know it seems a bit strange but I resolved the issue by just changing the name of the db instance.

Categories