I am having a problem creating and selecting MySQL databases from my php script.
I have a fresh installation of Linux Debian 8, which came with an Apache 2 webserver installed. I connect to the server using the local IP of the server.
I installed the rest of the LAMP stack, PHP 7.0.12 and MySQL 5.5.2. Being a beginner in the Linux environment, I found the command line interface of MySQL quite intimidating. Hence I also installed MySQL workbench to create databases.
With all that done, I created two databases using Workbench that I needed for my sites. I am also a beginner in web programming and web development. Next I followed tutorials that show how to write simple PHP scripts and those worked. Then when I got into linking MySQL and PHP, things started going wrong.
Initially I had problem connecting to the database server using 'mysql_connect()', however, I found out after a bit of googling that mysqli_connect() is what works in PHP7. After the connection was successfully made, I created a Database using mysqli_query() from the PHP code, and also selected it using mysqli_select_db().
However, I could not select the databases I had initially created using workbench using mysqli_select_db(). I tried a lot of ways, like putting the php file and the db in the same folder, specifying the exact path of the db, but none worked. I am guessing it must be some problem regarding the location the php script looks at for finding the database.
Every tutorial I am looking into, uses some tool called PHPMyAdmin. Is it necessary to have PHPMyAdmin? From what I see, PHPMyAdmin is just a explorer and UI for working with databases, and so is workbench. So what is going missing here? The following are the things I would like to know:
1. Is there any way to specify to mysqli_select_db() to look for a database at a particular path/location?
2. What is the default location where the mysqli_##() commands look for or create databases at?
3. How to change this location?
4. What exactly does PHPMyAdmin do? What help would it be to use it?
5. Out of the context of MySQL and PHP, how to change the default webpage and the server directory of webpages of Apache 2 running on Linux?
Thanks in advance.