I created a new Symfony 4 project and want to create a new database. I'm following this tutorial but can't get it to work. When running
php bin/console doctrine:database:create
I always get the same error:
In AbstractMySQLDriver.php line 112:
An exception occurred in driver: SQLSTATE[HY000] [1045] Access denied for user 'user_1'#'localhost' (using password: YES)
In PDOConnection.php line 50:
SQLSTATE[HY000] [1045] Access denied for user 'user_1'#'localhost' (using password: YES)
In PDOConnection.php line 46:
SQLSTATE[HY000] [1045] Access denied for user 'user_1'#'localhost' (using password: YES)
Following the tutorial, I configured database url in .env file, but it doesn't seem to change anything.
DATABASE_URL=mysql://user_1:secretPassword#127.0.0.1:3306/db_name
My config/packages/doctrine.yaml configuration:
parameters:
env(DATABASE_URL): ''
doctrine:
dbal:
# configure these for your database server
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci
url: '%env(resolve:DATABASE_URL)%'
orm:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
Tried everything and nothing seems to work. Any help would be greatly appreciated.
Possibly, your user has no permissions to CREATE DATABASE operation.
Grant privileges to your user with grant CREATE on *.* to 'user_1'#'localhost'; in MySQL console.
refer to this similar issue
Possible reasons of the issue :
collation of your database
mysql credentials are invalid
Check connection with current credentials.
Example for *nix
mysql -uuser_1 -p
When check mysql server's port
mysql> SHOW GLOBAL VARIABLES LIKE 'PORT';
Try to replace localhost for 127.0.0.1 in your .env(or other .env.*) file.
Related
I'm using Rails 4.0, every time I run a migration I get this error:
mysqldump: Got error: 1045: Access denied for user 'regan'#'localhost' (using password: NO) when trying to connect
Could not dump the database structure. Make sure `mysqldump` is in your PATH and check the command output for warnings.
I think the migrations are still working ok, but I'm getting a lot of failing tests (I just received this project already built).
How do I fix this error?
I assume you don't have the users password setup in the database.yml file. The common scenario is that you setup a password in the mysql installation and now not providing it.
Your database.yml file should look some thing like this.
development:
adapter: mysql2
encoding: utf8
database: <my db>
username: <my user>
password: <my password>
host: localhost
port: 3306
I am totally new to ruby on rails, trying to set up a project with connection to mysql.
In mysql i've created databases, granted privileges to user like this:
GRANT ALL PRIVILEGES ON testdb_development.* TO 'rails_user'#'localhost' IDENTIFIED BY 'test';
In the database.yml file i've configured:
adapter: mysql2
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: rails_user
password: test
host: localhost
I am trying to test the connection with schema dump
rails db:schema:dump
Bizarrely, the access denied message is giving me a weird localhost IP (172.20.0.1), i'm not sure if this is why its failing, but unsure how to resolve from there?
rails aborted!
Mysql2::Error: Access denied for user 'rails_user'#'172.20.0.1' (using password: YES)
Tried setting password like this also, to no avail - I cannot even login using this rails_user at all with access denied error
SET PASSWORD FOR 'rails_user'#'localhost' = PASSWORD('test');
I have looked through a lot of similar solutions but have been unable to resolve my issue so hopefully someone can help.
I have joined a Rails project and need to pull data via a dump.sh file to enable me to work locally. Whenever I run the required command, I receive this error:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
If I try mysql -u root I see the exact same error message.
Trying mysql -u root -p requires my password to be entered (it is the same password in the database.yml file) which is kind of weird - surely this step should not work based on my error message?
My database.yml file looks like this for development:
development:
adapter: mysql2
database: database_development
host: localhost
port: 3306
username: root
password: "password_is_here"
pool: 5
timeout: 5000
I feel like I am missing something really basic here, but cannot for the life of me work out what it is :-/
EDIT: Forgot to mention, the database exists and has been migrated so rake db:create and rake db:migrate are not the issues.
EDIT2: My test database has the same information
I have seen this error before, that was because the database.yml contain some special characters that can't see in normal mode of text editor. I suggest to try to create totally new database.yml file from scratch then input database info again manually, restart the server to check the result.
Using Rails 3.2, mysql2 gem, MariaDB 5.5. I got the following error while trying to deploy the app for the first time:
Mysql2::Error: Access denied for user 'abc'#'%' to database 'app_production'
I'm not sure why the percent sign % in 'abc'#'%'.
Here's my database.yml:
production:
adapter: mysql2
encoding: utf8
reconnect: true
host: db.domain.com
port: 3306
database: app_production
pool: 5
username: abc
password: some_password_here
socket: /run/mysqld/mysqld.sock
My /etc/mysql/my.cnf has bind 0.0.0.0, firewall is temporarily disabled with sudo iptables -F.
This error due to permission on database access for the user, so you have to grant access permission for this user on above database. Find below command to grant permission. run these command on mysql terminal
GRANT ALL PRIVILEGES ON app_production.* TO 'abc'#'%' WITH GRANT OPTION
FLUSH PRIVILEGES
It sounds like the user abc is not set up with MySQL. Go to your MySQL client and make sure that user is created (with that database).
I have a problem using the heroku db:push command to transfer a MySQL database to heroku. I've tried using the same command for another app with a sqlite3 database and everything went fine.
C:\Users\reg\Team-Omni>heroku db:push
Loaded Taps v0.3.9
Auto-detected local database: mysql://127.0.0.1/omni_dev?encoding=utf8
Warning: Data in the app 'growing-mist-42' will be overwritten and will not be recoverable
.
Are you sure you wish to continue? (y/n)? y
Failed to connect to database:
Sequel::DatabaseConnectionError -> Mysql::Error: Access denied for user 'reg'#'localhost
' (using password: NO)
if i remove the password for the mysql anonymous account, the error changes to
Sequel::DatabaseConnectionError -> Mysql::Error: Access denied for user ''#'localhost' to database 'omni_dev'
--additional information--
my .gems file:
rails -v 2.3.8
andre-geokit --version 1.5.0 --source http://gems.github.com
You are getting that error because you are not specifying the password for the local database connection. Apparently the username is configured as 'reg' (maybe in the MySQL config file). This doesn't have anything to do with the Heroku PostgreSQL database, it's a problem connecting to your local MySQL database (named omni_dev).
Try the following connection string:
mysql://USERNAME:PASSWORD#127.0.0.1/omni_dev?encoding=utf8
for the appropriate values of USERNAME and PASSWORD.
I've had this problem as well, but I was passing a password. My local app worked fine, but when using heroku db:push, I got the same error as redge.
Adding a port in the database.yml fixed the problem. So, a working database.yml has the following entries:
database: DATABASE
username: USER
password: PASSWORD
adapter: mysql
encoding: utf8
socket: /Applications/MAMP/tmp/mysql/mysql.sock
port: 8889