0

I have been trying to setup a local instance for a new application. I am new to MYSQL and I cannot understand how to actually connect this database to the actual web application sitting in the /var/www folder in my computer.

I have created a database in command line terminal:

mysql> create database mydatabase
    -> ;
Query OK, 1 row affected (0.00 sec)  

mysql> create user 'host'@'website.local' identified by 'hmypassword';
Query OK, 0 rows affected (0.00 sec)

mysql> create user 'host'@'%' identified by 'mypassword';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on database.* to 'host'@'%';
Query OK, 0 rows affected (0.01 sec)


mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye


mysql -u host -h 127.0.0.1 -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 52
Server version: 5.5.37-0ubuntu0.14.04.1 (Ubuntu)

How to actually connect this database to the website? I also don't understand how to make a schema for this database. Whenever I try to refresh my web browser I get the following message:

Could not access database!

SQLSTATE[HY000] [2002] Connection refused
0
0

You create database mydatabase and then you grant on database.* The correct is:

grant all privileges on mydatabase.* to 'host'@'%';
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.