Created a mysql database but can't seem to find it anywhere - mysql

I just cloned a repo from github and bundle installed everything and created a mysql db via rake db:create. I migrated the database and everything....however, I have no idea where it is located? Usually when I use sqlite, it's in the db/ folder...but this database is not. where can I find it?

Look in your MySQL config file. Usually it's called my.cnf. Where to find this config on your system, we can't say :-)
Look for datadir in a config file
[mysqld]
datadir=/var/lib/mysql/

MySQL works a bit differently than sqlite. Whereas sqlite writes a database directly to a file (in your db/ directory in the case of rails), MySQL writes it to a server (usually located on the same machine as your application, but not always). I would be surprised if an app you cloned off of github let you create a mysql database right off the bat. You need to set up a mysql server and set a password for it. If you're running Ubuntu -- as I am -- these are some good instructions. Then you need to configure your config/database.yml file accordingly.

Related

Mnesia : ejabberd : Export all tables as SQL queries to a file

I need to migrate mnesia to mysql from ejabberd.
I have tried many ways from ui : From ui there is a node. On selection of node I will have many options out of which one option is backup. On that page there is a option of Export all tables as SQL queries to a file: host(0.0.0.0),I tried to take sql backup but file is empty
I also tried these commands:
ejabberdctl export2odbc localhost /var/lib/ejabberd/new_file.sql. This is also a blank file generating no error.:
ejabberdctl export2sql localhost /tmp/sql /var/lib/ejabberd/new.sql. This command does not execute as export2sql does not exist.
Is there any other way to take sql dump from Mnesia
Version : ejabberd 16.01 mysql 5.6.xx
The sql export command was added in 16.04 and named as export_sql and later renamed to export2sql in 16.06. So there's no way to take a dump directly, but you have two alternatives:
If you can upgrade ejabberd, then its straight forward, upgrade the server, take a dump of the sql.
Take a backup of the relevant folders, like database/spool directory, config directory, etc.
Upgrade the server to the latest version or at least version 17.07 (the reason being since version 17.06 most of the tables can be exported to sql file, but 17.03-17.06 suffers a bug.
Configure ejabberd to use mysql as a backend database.
Make sure the following modules have the db_type: sql option.
mod_announce, mod_caps, mod_irc, mod_last, mod_muc, mod_offline, mod_privacy, mod_private, mod_pubsub, mod_roster, mod_shared_roster, mod_vcard, mod_vcard_xupdate
Restore the spool directory and make sure you have the same permissions
for all the files and sub-directories as before.
Run the ejabberd2sql with hosts and the sql filename as parameters
Note: If you only need the sql dump you might want to revert back the configuration after the dump.
If you cannot upgrade the server, you can install the latest version of ejabberd in another machine, copy the database directory, follow the same procedure above and you can get the dump of your sql.

Use XAMPP-phpmyadmin database of windows in Linux XAMPP

I was on windows and using XAMPP(installed somewhere else than C:/ )
Now i have moved on to LINUX and installed LAMPP.
So, i have this XAMPP folder from windows and i copied the project files from htdocs and now i need the database which i didn't exported while i was on windows.
I tried to copy the phpmyadmin folder from the old XAMPP folder but couldn't get it to work.
So how can i access the previous OS phpmyadmin to use my existing databases -
using linux (MINT - rosa-cinnamon)
Thanks in Advance !
If you want to move databases between hosts - especially when there are differences in the MySQL daemon version, operating systems (-versions) or storage schema - you should create a MySQL dump at host A and import it on host B: http://dev.mysql.com/doc/refman/5.7/en/mysqldump-sql-format.html
If this is no option for you anymore, you can try to move the old MySQL data directory (Configured in my.ini on windows, somewhere in the xampp directory) to the location where the new MySQL daemon stores its data files (Normally configured at /etc/mysql.my.cnf). A few more hints on this:
Ensure to modify the file permissions on the data files at the new location that the MySQL daemon can work with them.
On Windows, MySQL table names are case insensitive. On Linux they are case sensitive. Keep that in mind, if your application complains about missing tables.
And of course: Test this with backups only!

What is the windows path to the MySQL connections file?

I come from the oracle world where the tnsnames.ora file contain all the sql connection information.
I cannot seem to find the file containing such information for mysql. Could someone with a windows machine tell me where I can find it please.
MySQL doesn't need a connections file analogous to the .tns file. MySQL has nothing like a TNS. Connection parameters typically are configured explicitly in your application.
You can optionally create a file called .my.cnf that contains a user's default parameters for connecting.
See also What is the location of mysql client “.my.cnf” in Windows? that shows how to use mysql --help to find out the location of all the config files.
Most people just configure one set of connection parameters in their .my.cnf file, but you can configure multiple sets of connection parameters under different [client] groups, and invoke MySQL client tools to use the respective connection. There's an excellent blog that describes how to set this up here: http://datacharmer.blogspot.com/2011/03/hidden-options-file-trick.html
Re your updated info:
Sorry, I had to boot up a Windows box and install MySQL Workbench to check where the connection info is stored. I don't normally use Windows.
Right, for MySQL Workbench, the connection data is in for example,
C:\Users\Uncle Iroh\AppData\Roaming\MySQL\Workbench\connections.xml
But you're not expected to edit this by hand, and you'll probably ruin it if you try. It's undocumented, and presumably the format could change if you change versions of MySQL Workbench. You should create or edit connections in the Workbench GUI.
There is no such thing in MySQL. Check for a config file called my.ini or my.cnf. If MySQL is using a non-default port (not 3306), it will be detailed there. Otherwise, connect using:
mysql -u user -p
This is an executable (mysql.exe) you'll find in the bin directory of the installation (probably). For example, on my Windows box it's here: C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin\mysql.exe

Attaching an existing database with MySQL

Disclaimer: I have never used MySQL before!
I have a folder containing a number of .frm, .myd and .myi files that I believe are a MySQL database. I have pulled these files from a defunct server for a client who has not used the server or database for some years but is now looking to resurect some of the data for a new venture.
I have downloaded the latest free edition of MySQL, along with MySQL Workbench and am looking to connecct the existing database to the new installation; the equivalent to an "Attach" if I were using MS SQL Server.
I have found a few articles that say if I simply copy the folder into the data folder for MySQL and restart the service the database will show up. I have tried this (using both the data folder within the installation folder and also the "MySQL Datafiles" folder created during the intial configuration but when I restart the service nothing shows up.
How should I go about attaching this database?
Ok. I found the answer, the folder I was adding the database to was the wrong one.
Though I had found 2 "data" folders, there was a 3rd hiding in C:\ApplicationData; once I added my data files in here and restarted the MySQL service I could see the data.
On Windows 8 the default folder where MySql databases are stored is:
C:\ProgramData\MySQL\MySQL Server 5.6\data
5.6 is the version.
Please note it is ProgramData not Program Files which is easy to overlook.
Copying there and restarting the service worked fine for me. I'm even copying the DBs from an earlier 5.X version.

Mac OS X mySQL custom database path (MAMP PRO)

I'm using MAMP (OS-X 10.6.6) and I want to move my mySQL db folder to my dropbox folder.
The MySQL server MAMP runs stores its databases in
/Library/Application Support/appsolute/MAMP PRO/db/mysql
..and I can't get it to follow symlinks or aliases to the mysql folder.
Is there a way to change the path mySQL uses for storing its databases? On the MAMP forum they say it's not possible, but I imagine there must be some kind of config file for whatever mySQL server it is that MAMP is running that can be changed to specify an alternative location for the used DBs..?
Anyone know how to acheive this? Storing the DB's on dropbox is the last element I need to solve to be able to work on my projects from my different computers.
Just realized that its just the finder 'alias' type that won't work. creating a proper unix symlink works fine. so doing this solves the problem and keeps the databases on dropbox.
ln -s /Users/username/Dropbox/MAMP_db/mysql /Library/Application\ Support/appsolute/MAMP\ PRO/db/mysql
mwb's method works. Remember, you also need to be be running Apache/MySQL server as user. Those settings are in MAMP PRO (Server -> General)
If you are going to be using dropbox to access the database on another machine, you will need to have identical paths to Dropbox as well.