This seems like it should be pretty easy but I am running into problems trying to create a database following these instructions: http://symfony.com/doc/master/book/doctrine.html
I edit the parameters.yml and config.yml file and then run this command from terminal:
php app/console doctrine:database:create
The error I am getting is:
Could not create database for connection named `learn_symfony`
SQLSTATE[28000] [1045] Access denied for user 'root'#'localhost' (using password: YES)
How do I resolve this error and create the database?
The problem is that you are probably trying to connect on a server that isn't configured properly.
There is nothing to do with doctrine.
Tell me, are you trying to connect to a home-made server ? Is it a LAMP or WAMP stack ?
EDIT
If you are running on a recently installed server, you have to edit the MySQL configuration and set a password to the root account or set on the directive allowNullPassword
EDIT 2
If your server is LAMP, the file you have to change is located at /etc/my.cnf
EDIT 3
That file is for various mysql configurations.
About the allow null i was mistaking with phpMyAdmin.
Try setting a password for the root with this command
mysqladmin -u root password MYVERYNEWANDSECRETPASSWORD
Related
I am building a basic CRUD app using Laravel 7 Homestead in a Vagrant VM. The root address http://crud-app.local.test works, but when I add a defined route (http://crud-app.local.test/cats) I get this error page:
Error message in browser when navigating to '/cats' route.
So far I have:
Verified my MySQL password matches in the .env file and in practice
Changed the MYSQL password so that it's no longer empty (and made sure it matches what's in the .env file)
Ran php artisan config:cache
Ran php artisan config:clear followed by php artisan cache:clear
Changed 127.0.0.1 to localhost
Made sure the database defined in the .env file exists (crud)
Ran php artisan migrate (no errors, and the cats table exists in the crud database)
Restarted and re-provisioned the machine (vagrant reload --provision)
I'm at a loss now.
Make sure that you give "root" permissions to read from the database that you've created. As it's root#localhost rather than root#127.0.0.1 sometimes mysql differentiates. Just check the permissions that root#localhost has for the database and if you update them, flush the privileges.
I am admittedly new to Laravel and back end development but I'm trying to open a Laravel project in my browser and am receiving an error message instead. I'm inheriting this project from a client who was working with another group of developers and they have since gone AWOL so I'm on my own to try to figure out what the issue is here.
The first error messages were:
**Warning:** require(C:\xampp\htdocs\vizzue\bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in **C:\xampp\htdocs\vizzue\bootstrap\autoload.php** on line **17**
**Fatal error:** require():Failed opening required 'C:\xampp\htdocs\vizzue\bootstrap/../vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in **C:\xampp\htdocs\vizzue\bootstrap\autoload.php** on line **17**
To try to fix that error (from a solution I found on here), I ran composer install in the terminal to try to download the missing files. That switched the previous error messages to Whoops, looks like something went wrong. (Not very helpful).
So then I found more advice on here to get more detailed errors for my problem and was outputted a long list of errors under four separate headings.
Heading 1
SQLSTATE[HY000] [1045] Access denied for user 'homestead'#'localhost' (using password: YES) (SQL: select * from `sessions` where `id` = hA02gV6ShpNslkw0N8Wrgm8QmyA0ZxoXfCNHsVTK limit 1)
Heading 2
PDOException
SQLSTATE[HY000] [1045] Access denied for user 'homestead'#'localhost' (using password: YES)
Heading 3
QueryException
SQLSTATE[HY000] [1045] Access denied for user 'homestead'#'localhost' (using password: YES) (SQL: select * from `sessions` where `id` = hA02gV6ShpNslkw0N8Wrgm8QmyA0ZxoXfCNHsVTK limit 1)
Heading 4
PDOException
SQLSTATE[HY000] [1045] Access denied for user 'homestead'#'localhost' (using password: YES)
My PHP version is: PHP 7.2.28
My Laravel version is: Laravel Framework 5.4.36
Also, I have created a .env by copying the .env-example file.
EDIT:
I found the database information inside of the database/migrations directory so I actually DO have the database files. I'm still having an error, however. I ran php artisan generate:key and that was fine. But when I ran php artisan migrate I got the following error:
In Connection.php line 647:
could not find driver (SQL: select * from information_schema.tables where ta
ble_schema = homestead and table_name = migrations)
In Connector.php line 68:
could not find driver
first you have change the name of .env.example to .env then configure your database names settings in it. after that run composer install to install your project dependencies. make sure your webserver is up and running
You should configure your .env file to enable laravel access on your database. If you don't have one just copy the .env.example file and rename it to .env.
And then change the following properties:
DB_DATABASE=YOUR_DATABASE_NAME
DB_USERNAME=USER_NAME
DB_PASSWORD=PASSWORD
and then you should run php artisan key:generate to generate a new encryption key
EDIT
For your new problem you should run composer update and then composer require doctrine/dbal
if that does not work
You might need to comment out the following in your php.ini file.
;extension=pdo_mysql.so
As said here
Here is the basic installation process for a laravel project. I'll try to explain each of them so that you'll be able to figure out your mistakes on your own.
Getting the source code
You first need to get the source code of your app . Most of the time it's done via git . For instance , you'll need to type git clone https://github.com/miracuthbert/saas-boilerplate.git yoursaasproject to clone the repository hosted on github here
Install dependencies
Go to the root of the directory of the source code you previously got by typing
cd projectname.
The laravel framework uses composer as its dependencies manager. So you need to install it . (What you already did)
Then, from the root of your project, type the following intructions in the same order :
composer install
composer update
Environment configuration
The environment variables of the laravel framework are managed through a dot env file. An example file named .env.example is generally provided. You'll find it at the root of your project's folder. Assuming you are using a terminal with a bash prompt, type the following command to copy the .env.example to a .env file :
cp .env.example .env
After getting your new .env file, type
php artisan key:generate
to generate secure key in your .env file
Depending on the type of database management system you intend to use, here are some specific configurations to add in your .env file :
MySQL
If you choose MySQL as your DBMS, set the following values in your .env file :
DB_CONNECTION
DB_DATABASE
DB_USERNAME
DB_PASSWORD
homestead is the default DB_USERNAME and localhost is the default database host. Localhost is totally fine for working locally but you need to change your DB_USERNAME to an actual user of your DBMS with the corresponding password.
Sqlite
If you use sqlite, create a new sqlite database by typing :
`touch database/database.sqlite`
After setting up your database, enter the following command to create and populate tables :
php artisan migrate --seed
You may also need to edit other variables in the .env. The official laravel documentation is your best companion for that.
This is to the best of my knowledge what you need to do.
As for the driver error, here are few potential solutions adapted from an answer to a similar problem question asked here :
Be sure to configure the 'default' key in app/config/database.php
For mysql, this would be 'default' => 'mysql',
If you are receiving a [PDOException] could not find driver error, check to see if you have the correct PHP extensions installed. You need pdo_mysql.so and mysql.so installed and enabled. Instructions on how to do this vary between operating systems.
For Windows, the mysql extensions should come pre-downloaded with the official PHP distribution. Just edit your php.ini and uncomment the lines extension=pdo_mysql.so and extension=mysql.so
Also, in php.ini, make sure extension_dir is set to the proper directory. It should be a folder called extensions or ext or similar inside your PHP install directory.
There are other instructions given in the original answer but I'm only recommending those I understand. It was initially written for a postgres dbms.
If there are still problems, take a look at laragon. It's a bit like xamp (that you appear to be using on windows OS), but more powerful and easier to use.
The main backend languages and frameworks can be set up easily in few minutes. That includes php with laravel/symfony, ruby and Ruby on Rails, python and Django.
It allows you to manage multiple versions of the same programming language without any hassle and is fully extendable.
If you're new to Laravel or backend development, and working on the windows operating system, this is a must have.
This question already has answers here:
php mysqli_connect: authentication method unknown to the client [caching_sha2_password]
(17 answers)
Closed 3 years ago.
I'm running MySQL version 8 on PHP 7.0.
I'm getting the following error when I try to connect to my database from PHP:
Connect Error: SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
PHP might show this error
Warning: mysqli_connect(): The server requested authentication method unknown to the client [caching_sha2_password] in D:\xampp\htdocs\reg\server.php on line 10
How can I fix this problem?
#mohammed, this is usually attributed to the authentication plugin that your mysql database is using.
By default and for some reason, mysql 8 default plugin is auth_socket. Applications will most times expect to log in to your database using a password.
If you have not yet already changed your mysql default authentication plugin, you can do so by:
1. Log in as root to mysql
2. Run this sql command:
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password
BY 'password';
Replace 'password' with your root password. In case your application does not log in to your database with the root user, replace the 'root' user in the above command with the user that your application uses.
Digital ocean expounds some more on this here Installing Mysql
You have to change MySQL settings.
Edit my.cnf file and put this setting in mysqld section:
[mysqld]
default_authentication_plugin= mysql_native_password
Then run following command:
FLUSH PRIVILEGES;
Above command will bring into effect the changes of default authentication mechanism.
I've tried a lot of other solutions, but only this works for me.
Thanks for the workaround.
Check your .env
MYSQL_VERSION=latest
Then type this command
$ docker-compose exec mysql bash
$ mysql -u root -p
(login as root)
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
ALTER USER 'root'#'%' IDENTIFIED WITH mysql_native_password BY 'root';
ALTER USER 'default'#'%' IDENTIFIED WITH mysql_native_password BY 'secret';
Then go to phpmyadmin and login as :
host -> mysql
user -> root
password -> root
None of the answers here worked for me. What I had to do is:
Re-run the installer.
Select the quick action 're-configure' next to product 'MySQL Server'
Go through the options till you reach Authentication Method and select 'Use Legacy Authentication Method'
After that it works fine.
Faced the same problem, I was not able to run wordpress docker container with mysql version 8 as its default authentication mechanism is caching_sha2_password instead of mysql_native_password.
In order to fix this problem we must reset default authentication mechanism to mysql_native_password.
Find my.cnf file in your mysql installation, usually on a linux machine it is at the following location - /etc/mysql
Edit my.cnf file and add following line just under heading [mysqld]
default_authentication_plugin= mysql_native_password
Save the file then log into mysql command line using root user
run command FLUSH PRIVILEGES;
I'm using Laravel Lumen to build a small application.
For me it was because I didn't had the DB_USERNAME defined in my .env file.
DB_USERNAME=root
Setting this solved my problem.
In my.cnf file check below 2 steps.
check this value -
old_passwords=0;
it should be 0.
check this also-
[mysqld] default_authentication_plugin= mysql_native_password Another
value to check is to make sure
[mysqld] section should be like this.
preferences -> mysql -> initialize database -> use legacy password encryption(instead of strong) -> entered same password
as my config.inc.php file, restarted the apache server and it worked. I was still suspicious about it so I stopped the apache and mysql server and started them again and now it's working.
This question already has answers here:
php mysqli_connect: authentication method unknown to the client [caching_sha2_password]
(17 answers)
Closed 3 years ago.
I'm running MySQL version 8 on PHP 7.0.
I'm getting the following error when I try to connect to my database from PHP:
Connect Error: SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
PHP might show this error
Warning: mysqli_connect(): The server requested authentication method unknown to the client [caching_sha2_password] in D:\xampp\htdocs\reg\server.php on line 10
How can I fix this problem?
#mohammed, this is usually attributed to the authentication plugin that your mysql database is using.
By default and for some reason, mysql 8 default plugin is auth_socket. Applications will most times expect to log in to your database using a password.
If you have not yet already changed your mysql default authentication plugin, you can do so by:
1. Log in as root to mysql
2. Run this sql command:
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password
BY 'password';
Replace 'password' with your root password. In case your application does not log in to your database with the root user, replace the 'root' user in the above command with the user that your application uses.
Digital ocean expounds some more on this here Installing Mysql
You have to change MySQL settings.
Edit my.cnf file and put this setting in mysqld section:
[mysqld]
default_authentication_plugin= mysql_native_password
Then run following command:
FLUSH PRIVILEGES;
Above command will bring into effect the changes of default authentication mechanism.
I've tried a lot of other solutions, but only this works for me.
Thanks for the workaround.
Check your .env
MYSQL_VERSION=latest
Then type this command
$ docker-compose exec mysql bash
$ mysql -u root -p
(login as root)
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
ALTER USER 'root'#'%' IDENTIFIED WITH mysql_native_password BY 'root';
ALTER USER 'default'#'%' IDENTIFIED WITH mysql_native_password BY 'secret';
Then go to phpmyadmin and login as :
host -> mysql
user -> root
password -> root
None of the answers here worked for me. What I had to do is:
Re-run the installer.
Select the quick action 're-configure' next to product 'MySQL Server'
Go through the options till you reach Authentication Method and select 'Use Legacy Authentication Method'
After that it works fine.
Faced the same problem, I was not able to run wordpress docker container with mysql version 8 as its default authentication mechanism is caching_sha2_password instead of mysql_native_password.
In order to fix this problem we must reset default authentication mechanism to mysql_native_password.
Find my.cnf file in your mysql installation, usually on a linux machine it is at the following location - /etc/mysql
Edit my.cnf file and add following line just under heading [mysqld]
default_authentication_plugin= mysql_native_password
Save the file then log into mysql command line using root user
run command FLUSH PRIVILEGES;
I'm using Laravel Lumen to build a small application.
For me it was because I didn't had the DB_USERNAME defined in my .env file.
DB_USERNAME=root
Setting this solved my problem.
In my.cnf file check below 2 steps.
check this value -
old_passwords=0;
it should be 0.
check this also-
[mysqld] default_authentication_plugin= mysql_native_password Another
value to check is to make sure
[mysqld] section should be like this.
preferences -> mysql -> initialize database -> use legacy password encryption(instead of strong) -> entered same password
as my config.inc.php file, restarted the apache server and it worked. I was still suspicious about it so I stopped the apache and mysql server and started them again and now it's working.
I am trying to set up the MAMP development environment in MAC OS X Yosemite(10.10.2).
I am following this tutorial.
But problems happen when I try to set MySQL root password using command /usr/local/mysql/bin/mysqladmin -u root password 'yourpasswordhere'. I get a error message :
"/usr/local/mysql/bin/mysqladmin: connect to server at 'localhost'
failed error: 'Access denied for user 'root'#'localhost'
(using password: NO)'".
MAMP PRO has a great UI ...
... as for MAMP without the PRO, I don't remember. But I think it required adding MAMP's SQL to your PATH.
if u use mamp then why to set the password from the trmnl ,u can easily set it up through mamp it self