I have installed homestead on my machine and cloned a project from a remote repository, now I am trying to create a DB for my project.
This is how my .env file looks like:
APP_ENV=local
APP_DEBUG=true
APP_KEY=base64:e7K7SUDgogNqTtP9TO1CfpbXFAC6FmLLSJ1l6K8pbWs=
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=localhost
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
I have tried to connect to DB using sequel pro standard option:
Host: localhost
Password: secret
But I get:
Unable to connect to host 127.0.0.1, or the request timed out.
Be sure that the address is correct and that you have the necessary
privileges, or try increasing the connection timeout (currently 10
seconds).
MySQL said: Can't connect to MySQL server on '127.0.0.1' (61)
What am I doing wrong?
Some options:
Check the service of mysql is running;
Check the user and passowrd are correct;
Check the privilege of the user, try root user
For Mysql Connection you should have check username and password. and .env file
DB_HOST=localhost
DB_DATABASE=Your Database name
DB_USERNAME=username
DB_PASSWORD=password
Along With that, you can update database.php file for database configurations.
I had to add the port 33060 to be able to connect. Hope that will help others who got stuck like me.
I have some problem with Laravel 7 Homestead. I solve the error with this step:
Use mysql port 33060
Clear laraver config. php artisan config:clear
Reload vagrant vagrant reload --provision
And make sure your database name and password is correct.
Happy coding.
Related
i have react with asp.net core website . it worked fine on localhost but when published on iis remote server the timeout error occurs.
the front-end (react client) and back-end(server) asp.netcore webapi work independently.
before uploading i changed the following in program.cs in webapi.
usUrl("https://localhost:4000")
to useUrl("https://www.virtualcollege.pk:4000")
i also changed the front-end baseurl similarly.
moreover, the connectionstrings in appsettings.json is correct for both databases.
i added migration and updated the databases successfully.
the website is live but timeout error occur :
virtualcollege.pk
i also tried the url with "https://myip-address:4000"
thanks in advance for help.
if i remove port number from url and publish on local folder than upload to remote server . the webapi.exe on local machine runs as follows:
You have to open incoming request for 4000 port. Try some methods below.
Windows Server
Please check this link or this one
Ubuntu/Debian
sudo ufw allow 4000/tcp
sudo ufw status // check status
CentOS
First, you should disable selinux, edit file /etc/sysconfig/selinux so it looks like this:
SELINUX=disabled
SELINUXTYPE=targeted
Save file and restart system.
Then you can add the new rule to iptables:
iptables -A INPUT -m state --state NEW -p tcp --dport 4000 -j ACCEPT
and restart iptables with /etc/init.d/iptables restart
I have installed and run laravel in my windows server(hosted server) with the use of "php artisan serve" command. It worked well with "http:localhost:8000" inside the server but when I try with public url of server like "http:example.com:8000" it doesn't worked for me.
I couldn't understand.Inside the windows server worked fine but outside not working.
Also I checked the firewall with the 8000 port, no issue.
edit hosts file and add domain to local
127.0.0.1 example.com
I am trying to connect a Laravel to Google mysql instance locally.
.env file
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:GptV9AIxUX7TuPkKxbLs54DLjivt2wCmuG37qsnqxJU=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=**********
DB_USERNAME=**********
DB_PASSWORD=**********
DB_SOCKET=/cloudsql/[INSTANCE NAME]
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
I am using this cloud_sql_proxy command:
~/Downloads/cloud_sql_proxy -instances=/cloudsql/[INSTANCE_ID]=tcp:3306
and it working properly,
2018/07/18 13:46:29 Listening on 127.0.0.1:3306 for /cloudsql/[INSTANCE ID]
2018/07/18 13:46:29 Ready for new connections
I also enabled enabled Google Cloud SQL and Cloud SQL Admin API for my project.
The error I receive is:
SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from `campaigns`)
Below are my observation in struggle to find a solution.
In Stackdriver logging error that I see is
severity: "ERROR"
textPayload: "2018-07-18T05:57:08.204597Z 859643 [Note] Aborted connection 859643 to db: '[DB_NAME]' user: '[DB_USER]' host: 'cloudsqlproxy~173.194.90.33' (Got an error reading communication packets)"
When I check ~/Downloads/cloud_sql_proxy info:
2018/07/18 14:10:50 Using gcloud's active project: [PROJECT ID]
2018/07/18 14:10:55 must set -dir: using a unix socket for [INSTANCE NAME]
I am actually not able to relate if this is related to error.
I have tried connecting cloud sql using service account, its connects properly but still not able to resolve this issue.
Thanks in advance.
There are two ways to connect to Cloud SQL: via TCP or via a Unix Socket.
If you are using a Unix Socket, you need to specify -dir /cloudsql (or similar) as a directory to create your socket in. Full command looks something like this:
./cloud_sql_proxy -dir=/cloudsql -instances=myProject:uscentral1:myInstance
You would then use DB_SOCKET=/cloudsql/myProject:uscentral1:myInstance to connect. (You don't need a host or port - you're connecting via the unix socket)
If you are using TCP, you apply the port you want to listen to your instance name. So the command looks like this:
./cloud_sql_proxy -instances=myProject:us-central1:myInstance=tcp:3306
In this case, you use DB_HOST=127.0.0.1 and DB_PORT=3306 (but not DB_SOCKET).
i tried to create a new database in Doctrine, with php app/console doctrine:database:create but i got an error : i fixed it thanks to this website
now i've got a second error, but i can't find any solution :
afther this :
pc11:Symfony Paul$ php app/console doctrine:database:create
i've got this error :
Could not create database for connection named symfony
SQLSTATE[28000] [1045] Access denied for user 'root'#'localhost' (using password: NO)
i tried without "symfony" but it did not work :
pc11:~ Paul$ php app/console doctrine:database:create
Could not open input file: app/console
Would you know how to fix this?
Thanks
You're probably missing database configuration, it tries to connect to MySQL as the user root without a password and fails to get the permission to create the database.
Check your parameters.ini for settings related to the database connection.
You need to set the password for root#localhost to be blank. There are two ways:
The MySQL SET PASSWORD command:
SET PASSWORD FOR root#localhost=PASSWORD('');
Using the command-line mysqladmin tool:
mysqladmin -u root -pCURRENTPASSWORD password ''
Solution
This worked for me on Mac OS X with MAMP (or MAMP Pro).
Add database.unix_socket in app/config/parameters.xml
parameters:
database.driver: pdo_mysql
database.host: localhost
database.port: 8888
database.name: my-database-name
database.user: root
database.password: root
database.unix_socket: /Applications/MAMP/tmp/mysql/mysql.sock
Add unix_socket in app/config/config.xml
# Doctrine Configuration
doctrine:
dbal:
# ...
unix_socket: "%database.unix_socket%"
I was having the same problem.
If you want to try with php you have to change app/console to bin/console
Using Robotframework 2.6.3 and the python database library, I want to connect to MySql Database.
I have downloaded the DatabaseLibrary and MySQLdb however when I try to connect using:
Library DatabaseLibrary
DatabaseLibrary.Connect To Database MySQLdb cts1 root password 172.16.7.20
I get the following error, when I run this using pybot:
OperationalError: (2003, "Can't connect to MySQL server on '172.16.7.20' (10061)")
Note:
cts1 - is the DB name and 172.16.7.20 - is the IP address of DB.
This works when I use mysql under the command prompt. Why would it not be able to connect?
The issue was I did not provide any PORT into robotframework and it does not correctly use the default port of 3306. Once I put the port in, it worked.