Liquibase refuses to create a database that doesn't exist - mysql

I'm trying to run
liquibase update
on a database that doesn't exist yet. I would expect it to create the database for me (I'm running with root, so it shouldn't be a problem), but instead I'm getting:
/vagrant/liquibase$ ./liquibase update
Liquibase Home is not set.
Liquibase Home: /vagrant/liquibase
Liquibase update Failed: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'test_project'

Connection url parameters to the rescue again!
url: jdbc:mysql://localhost/dev_project?allowMultiQueries=true&createDatabaseIfNotExist=true
the createDatabaseIfNotExist=true part did the trick

Related

Symfony - App uses wrong database name, CLI uses the correct one

hoping to get help with possibly a silly problem. I can't get Symfony to connect to the correct database.
My config line in .env is as follows
DATABASE_URL="mysql://root:root#127.0.0.1:3306/main?serverVersion=mariadb-10.4.27"
Creating a database using CLI works just fine and the database named "main" is created
bin/console doctrine:database:create
Created database `main` for connection named default
Running migration works OK and a table is created in the database
bin/console doctrine:migrations:migrate
WARNING! You are about to execute a migration in database "main" that could result in schema changes and data loss. Are you sure you wish to continue? (yes/no) [yes]:
> yes
[notice] Migrating up to DoctrineMigrations\Version20230117183120
[notice] finished in 28.6ms, used 22M memory, 2 migrations executed, 3 sql queries
Yet, when I try to access the site from the browser I get the following error
An exception occurred in the driver: SQLSTATE[HY000] [1049] Unknown database 'root'
Clearing the cache doesn't seem to help, I don't see any reference in the code to a database named root. Any clues on how to make Symfony to connect to the "main" database?
Cheers
P.

Failing to upgrade sonarqube using mysql

I am trying to configure/start SonarQube with MySQL.
I installed everything including sonar DB and sonar user with proper permission.
when I browse 127.0.0.1/sonar, I get 'under maintenance'.
when I browse to /setup to upgrade, I get this message
Database connection cannot be established. Please check database status and JDBC settings.
here is my config
jdbc.default.driverClassName=com.mysql.jdbc.Driver
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
jdbc.default.username=sonar
jdbc.default.password=hpP#ssw0rd
Fail to execute database migration: org.sonar.db.version.v60.AddUuidPathColumnToProjects
java.lang.IllegalStateException: Fail to execute ALTER TABLE projects ADD (uuid_path VARCHAR (1500) NULL)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Duplicate column name 'uuid_path'
2017.02.15 10:43:05 ERROR web[][o.s.s.p.d.m.PlatformDatabaseMigration] DB Migration or container restart failed. Process ended with an exception
org.jruby.exceptions.RaiseException: (StandardError) An error has occurred, all later migrations canceled:
Fail to execute database migration: org.sonar.db.version.v60.AddUuidPathColumnToProjects

Talend MySQl Database error

I am trying to create a new database connection in talend studio and it is showing me this error:
Connection failure. You must change your database settings.
I have configured MySQl installer and also I have searched about this error and saw some answers but neither of them were clear, how can I fix this problem.
The exception thrown says that Talend was unable to connect to the database "demo". Try to create a database with the name "demo" with another SQL tool before connecting to it with talend.

Xampp-Mysql-Eclipse connection error

I have installed eclipse and xampp in my mac and tried to connect with mysql server from eclipse using mysql-5.7.9-osx10.10-x86_64 connector.
I have the user "root#localhost" granted with all privileges to all databases.
1) I'm able to connect only mysql database in phpmyadmin server.
Unable to connect any other database. Am getting an error :
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown
database 'test'
2)After connecting with mysql database using
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root","1234");
I created a table adminlogins in mysql database, and used command
"select * from mysql.adminlogins"
but I am getting an error
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table
'mysql.adminlogins' doesn't exist.
I have tried all possible ways creating new user and granting all permissions. I am unable to figure out where am going wrong please some help me with this.
mysql database is reserved for system use. It is not recommended to create your own tables there. That said, the cause of your error is that the table was not created where you think it was if it was created at all.
Regardless, try creating the table in another database. If it does not work, post the exact commands that you used to create it with the messages that were returned.

When run "sonar-runer" throw exception :"Caused by: Unknown database status: FRESH_INSTALL"

I need help
First , it throw exception
cannot load class 'com.mysql.xxx.JDBC'",so I copy the
sonarqube-4.0/extensions/jdbc-driver/mysql/mysql-connector-java-5.1.26.jar
to the /usr/lib/jvm/java-7-sun/jre/lib/ext/
Then I run sonar-runner again, it throws this exception:
Unknown database status: FRESH_INSTALL
My heart is broken , plz help me
I saw this error when the database is empty (no tables are created). Usually tables are created during first start of sonar.
Can you reach sonar by web interface?
Make sure that settings in your conf/sonar.properties file in Sonar directory are correct, these lines should be uncommented.
sonar.jdbc.url: jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
sonar.jdbc.username: mysqlusername
sonar.jdbc.password: mysqlpassword
Then check if your conf/sonar-runner.properties file in sonar-runer directory has the same settings.
#----- MySQL
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
#----- Global database settings
sonar.jdbc.username=mysqlusername
sonar.jdbc.password=mysqlpassword
Also make sure that the line for default embeded database is commented.
#sonar.jdbc.url: jdbc:h2:tcp://localhost:9092/sonar
Sonar stopped supporting the property "sonar.jdbc.schema" from 4.2 version. Please refer link http://jira.codehaus.org/browse/SONAR-5000. To fix the issue on PostgreSQL based sonar deployment, execute the following SQL command on the database:
ALTER USER $dbUser$ SET search_path to $soanrQubeSchema$
I just encountered the same problem, and I solved it by restarting sonar server after creating proper user and database in mysql.
In fact, sonar server will fill the empty mysql database with many tables after restarting, and that removed the "FRESH_INSTALL" problem.