Rake trouble finding MySQL after uninstalling Rails 3.0.0 - mysql

So I thought I had fixed the problem posted in this question and I uninstalled Rails 3.0.0 with sudo gem uninstall rails -v 3.0.0, but then I had troubles with other things. I took rogerdpack's advice to a different level and uninstalled all of my ruby gems and mysql, then reinstalled them. Now I get the following:
Icarus:temporary atg$ rails shopping -d mysql
create ........
Icarus:temporary atg$ cd shopping/
Icarus:shopping atg$ rake db:create
(in /Users/atg/temporary/shopping)
Couldn't create database for {"reconnect"=>false, "encoding"=>"utf8", "username"=>"root", "adapter"=>"mysql", "database"=>"shopping_development", "pool"=>5, "password"=>nil, "socket"=>"/tmp/mysql.sock"}, charset: utf8, collation: utf8_unicode_ci (if you set the charset manually, make sure you have a matching collation)
What does this mean and how can I fix it?
All help is appreciated and thanks in advance!

I restarted after the install and everything worked again. So the key fix was to uninstall and reinstall everything, and then to restart so that changes can take effect.

Related

PHPMyAdmin - How to fix #1006 - Can't create database 'database_name' (errno: 13 “permission denied”) in Ubuntu 20.04?

In my Ubuntu 20.04 (Desktop/Laptop not server) OS based machine I recently install XAMPP (Version: 7.4.7).
Now when I try to create a database it shows #1006 - Can't create database 'database_name' (errno: 13 "permission denied").
I am not quite familiar with Ubuntu in recent times (last use Ubuntu 18.04), so I can't figure out in which file I need to do the configuration or in which directory I need to allow the permission so that the problem is fixed. Can anyone help me to fix the issue?
N.B: Will I need to install MySQL separately(although XAMPP is included), because mysql command is not working from terminal.
Thanks
When you want to create database, you do it with html view ? (using your browser like phpmyadmin) or direcly from XAMMP ?
I never use XAMPP sorry.
Did you try to install it separately ?
sudo apt update
sudo apt install mysql-server

RMariaDB: caching_sha2_password error when connecting to MySQL

I'm new to using database connections with R (under Ubuntu 16.04), and am running into some trouble. Following the documentation I've seen online, I tried something like this:
con <- DBI::dbConnect(RMySQL::MySQL(),
dbname='IFsHistSeries',
host='127.0.0.1')
This got me an error message that read:
Failed to connect to database: Error: Can't initialize character set unknown (path: compiled_in)
From what I was able to find using the google, it seems that RMariaDB is more up-to-date than RMySQL, so I gave that a shot instead:
con <- DBI::dbConnect(RMariaDB::MariaDB(),
dbname='IFsHistSeries',
host='127.0.0.1')
This resulted in an equally-cryptic error message:
Failed to connect: Plugin caching_sha2_password could not be loaded:
So then I tried something really foolish -- installing MariaDB using the instructions at https://downloads.mariadb.org/mariadb/repositories/. There were some dependency problems that managed to completely break MySQL so that now nothing works at all anymore. I'm planning to completely uninstall MySQL and MariaDB and start over from scratch. What I want to know for next time is:
Do I need to install MariaDB? Or will ordinary MySQL work with RMariaDB? (The relationship between the two databases confuses me a little.)
Do I need to do something special when setting up MySQL to make sure that the caching_sha2_password plugin works? I'm worried that this has something to do with the way I initially set up the password for my root user.
Any ideas at all would help a lot. Thanks!
--craig
OK... this seemed to work. First, I removed MySQL and MariaDB and installed 8.0.12 MySQL using the download from https://dev.mysql.com/downloads/mysql/ and followed instructions at https://dev.mysql.com/doc/refman/8.0/en/binary-installation.html.
I uninstalled all of my drivers and just reinstalled unixODBC
sudo apt-get remove unixodbc unixodbc-dev tdsodbc odbc-postgresql libmyodbc libsqliteodbc
sudo apt-get install unixodbc unixodbc-dev
Things went awry before when I installed libmariadbclient-dev. Instead, I ran
sudo apt-get install libmariadb-client-lgpl-dev
This installed the MariaDB client without breaking MySQL. I really don't know what the difference between the two is.
To get rid of the error with the caching_sha2_password plugin, I needed to change the default authentication mode when starting the MySQL server:
sudo ./mysqld_safe --user=mysql --default-authentication-plugin=mysql_native_password &
At this point, I could run
con <- dbConnect(RMariaDB::MariaDB(),
host='127.0.0.1',
user='root',
password='password')
Without any trouble.

rake db:create not working for legacy rails app (2.3.5) using MySQL (5.5.28)

I'm a new Rails Developer, and I'm working on a legacy Rails app. Whenever I run the rake db:create command, I get an error that the database couldn't be created. I have found many StackOverflow questions related to this, but in troubleshooting nearly all permutations of solutions, I couldn't resolve the issue.
I created the three Dbs (dev, prod, test), created the user with all access privileges to these dbs, and ran rake db:create.
I'm running Mac OS X Lion, MySQL 5.5.28, Rails 2.3.5, Ruby 1.8.7. Here are my settings
development:
adapter: mysql
encoding: utf8
database: adva_development
username: adva
password: ****
host: localhost
socket: /tmp/mysql.sock
Here's the error:
Couldn't create database for {"adapter"=>"mysql", "username"=>"adva", "host"=>"localhost", "encoding"=>"utf8", "database"=>"adva_development", "socket"=>"/tmp/mysql.sock", "password"=>"****"}, charset: utf8, collation: utf8_unicode_ci (if you set the charset manually, make sure you have a matching collation)
I have done the following troubleshooting:
Verified user and password are correct, and the user has access to the DB. (Double checked user access with SELECT * FROM mysql.db WHERE Db = 'adva_development' \G; User has all privileges.)
Verify the socket is correct. I don't really understand sockets, but I can plainly see it at /tmp/mysql.sock.
Checked collation and character set. I found out I had created the DB in latin charset and collation, so I recreated them. I ran show variables like "collation_database"; and show variables like "character_set_database"; and came back with utf8 and utf8_unicode_ci respectively.
I followed the instructions in this question. After uninstalling mysql gem, I ran the following but came up with the same error:
gem install --no-rdoc --no-ri mysql -- --with-mysql-dir=/usr/local/mysql-5.5.28-osx10.6-x86_64/bin --with-mysql-config=/usr/local/mysql-5.5.28-osx10.6-x86_64/bin/mysql_config
Following Matt's suggestion, here's what a rake --trace db:create reveals:
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:create
Couldn't create database for {"database"=>"adva_development", "adapter"=>"mysql", "host"=>"127.0.0.1", "password"=>"woof2adva", "username"=>"adva", "encoding"=>"utf8"}, charset: utf8, collation: utf8_unicode_ci (if you set the charset manually, make sure you have a matching collation)
After 3 days and six or seven hours, I have pretty much run out of options. I tried various random things, like replacing localhost with 127.0.0.1 to no avail.
Could there be something wrong related to my specific environment? Mac OS X Lion + MySQL 5.5.28? I plan on trying on setting up everything in a Linux environment.
Thanks!
You can try changing localhost to 127.0.0.1 and removing socket to use TCP/IP instead of a local socket.
Or try to verify if your database server uses the same socket as Rails:
mysqladmin variables | grep socket
If this doesn't help, then try to connect to the database server with pure Ruby and create a new database:
require 'rubygems'
require 'mysql'
begin
db = Mysql.new('localhost', 'root', 'yourpassword')
db.query('create database sample_database;');
rescue Mysql::Error => e
puts e
ensure
db.close unless db.nil?
end
and see if this runs. You should have mysql gem installed (gem install mysql)
Make sure you running a more recent version of the mysql gem. I ran into this problem with version 2.8. Upgrading to 2.9 fixed the issue.
change 'localhost' into '127.0.0.1' (loop back address) , hope its works

Use mutated vowel as database password in rails

I have an rails application with an mySQL database and not the permission to change the database password of the user. The problem is that the password contains a mutated vowel like: asÖs8ss when I try to run rake db:migrate the migration fails with this error:
rake aborted!
special characters are not allowed
I tried to escape the Ö in this ways:
\xC3\x96
\u00D6
But this doesn't help. I also added encoding: UTF8 to the database connection and #encoding: utf-8 to the top of the database.yml but nothing helps to solve my problem.
Has anyone an idea how to escape the Ö right or to fix this somehow?
UPDATE I am using JRuby, if this help?
After I updated to the newest version of JRuby and run bundle update I got it to work. Also you have to make sure, all your files are utf-8 on my windows machine I had to configure my editor, because default was ANSI.
I need to run db:migrate with this command:
jruby -J-Dfile.encoding=UTF-8 -S rake db:migrate RAILS_ENV=production

Create MySQL database in OS X Lion

I am trying to set up a dev environment on my Mac laptop, and I have run into some trouble when installing mysql. When I try to create a database, I get the following error:
ERROR 1006 (HY000): Can't create database 'SummerGypsy_development'
(errno: 2
From what I have gathered, this means there was some problem in creating the database on the disc.
Here is how I installed mysql:
First, using Homebrew, I executed:
brew install mysql
Once that finished, I tried running mysql_install_db, but got an error. To remedy this error, I ended up running
mysql_install_db --basedir=/usr/local/
I can run mysql, but creating a database does not work. I ran
mysqladmin variables | grep datadir
To find where mysql was trying to create the database. The output was: /usr/local/mysql/data
/usr/local/mysql and /usr/local/mysql/data directories do not actually exist, and I have a feeling that the datadir is pointing here because of the basedir I passed into mysql_install_db. As a quick fix, I tried creating both directories, and then running
chown -R mysql:mysql /usr/local/mysql
to give mysql permissions in this directory. This did not fix the problem, though.
Does anyone have any suggestions?
you need to change the permissions in the data.
chown -R mysql:mysql /usr/local/mysql/data
You might want to try installing from the .dmg file (installer, system preferences pane, and startup script) that is distributed directly from MySQL. There is a thread on Getting MySQL work on OSX 10.7 Lion that you might want to take a look at. These steps helped me get MySQL running on OSX Lion. Hope this helps.
I tried lot of the suggestions including the file permission reset with no luck. But i then restarted the mysql using the command "./mysqld_safe &" (excluding quotes) and it worked.