Here I need to connect a database (sample) that resides somewhere in drive say
E:\mysql_files\sample
When I try to copy the sample database to the data folder of Mysql, the don't list the database when I use mysql> show databases; I too searched for it. To make them list I need to copy ib* files to the same path. But I can't copy those files while mysqld.exe is running.
Also tried other ways like connecting from external computer mysql -u root -p {password} -h {127.0.0.1} -D {database_name} (with and without path). All shows database does not exist.
Can somebody help me through this...
Original databases created by Mysql are stored in C:\ProgramData\MySQL\MySQL Server 8.0\Data\
And I need to connect to the database which is in E:\mysql_files\sample
Related
I am attempting to back up a MySQL database on a Linux server before I install some upgrades to the software (Omeka) which is using the database.
The command supplied by Omeka documentation for that is the following:
mysqldump -h localhost -u username -p omeka_db_name > omeka_db_backup.sql
However, when I run this, I get the ever so helpfully vague message of "permission denied." It does this if I run the command as sudo. It does this no matter what directory I try to save the backup file to. It doesn't prompt me for a MySQL password when I run mysql dump, but it does when I run "mysql" command and it accepts the password I put in so I know the issue isn't that I'm using the wrong credentials.
I cannot navigate to the MySQL folder directly in shell and when I use WinSCP to access the server, the MySQL folder is listed as owned by "MySQL" and not by "root." So I'm assuming that I don't have permission to copy anything from this folder and that is my problem. I don't want to willy nilly assign ownership of the MySQL folder to root because I'm afraid it might break MySQL's ability to read and write from this folder.
All I want to do is copy the database files somewhere as backup. Heck, I'll copy the whole MySQL folder someplace if I have to do that. How can I do that without breaking MySQL?
Root has permissions for everything. There may be some additional safeguards, depending (there is some security software that limits root permissions).
You can just use:
mysqldump -h localhost -u username -p omeka_db_name > /path/to/some/other/directory/omeka_db_backup.sql
And put backup in directory you can normally access. If you use the mysqldump you don't need to write to mysql dir.
I'm using XAAMP and the information about database is as follows
I was trying to upload employees sample database from https://launchpad.net/test-db/ through CMD but I don't have much knowledge about mariaDB commands and all the information's on google is for mysql.
My command line for C:\xampp\mysql\bin\mysql.exe opens as below not as normal mysql.
Notice the MariaDB[<none>]>
I have set a custom password for the database in phpmyadmin for root.
What is the command line to upload the large mysql database from the folder
C:\xampp\mysql\employees_db
Actually that is very easy:
First, you need to unzip the database in C:\xampp\mysql\bin\ folder
Then, you have all the *.sql files in that folder, right?
Now, open a command line and type the following commands:
cd C:\xampp\mysql\bin\
mysql.exe -u root -p yourDatabasePassword < employees.sql
I have a backup.mysql file that I created using mysqldump.
How can I use that to restore the database? I opened the file in Sublime Text, and here is what its beginning looks like!
The dump you produced is a SQL script you can run with any tool you want. As OP from this question How do I restore a dump file from mysqldump?, if you try to restore it with MySQL Administrator or other software providing specific backup/restore functions, it can throw an error because it asks for a particular format (his own format); but if the dump has been produced correctly, you can run it with any MySQL client, for example with the command line tool :
mysql -h hostname -u username -p yourschema < ./path/to/the/script.mysql
Copy your backup.sql file to the working directory: C:\xampp\mysql\bin. (or whatever your path)
In your command prompt or terminal switch to the MySQL directory. cd c:\xampp\mysql\bin (or whatever your path)
Open the MySQL Database system mysql –h localhost –u root (or whatever your credentials)
You need to re-grant permissions: GRANT ALL ON your_db_here.* to 'root'#'localhost'; (or whatever your credentials)
You need to re-create the database: CREATE DATABASE your_db_here;
Start using the database: USE your_db_here;
Import the dump file that you created: source backup.mysql
Using DESCRIBE commands and "SELECT * FROM" commands ensure that your database has been restored properly.
Copying database backup files from xamp/mysql/data of windows to linux in path /var/lib/mysql, but it is creating only empty database in phpmyadmin of linux.
Please some one help me to solve this issue, i have only these files backup with me
The best way is-
Step1: Take backup from windows by mysqldump-
mysqldump -uroot -proot123 -A > backup.sql
Step2: Move this backup to linux, you can use winscp tool for it.
Step3: Now restore this backup to linux machine.
mysql -uroot -proot123 < backup.sql
Modification:
It seems your db engine is myisam and you just coppied file/folder from window to linux, so give permissions as per below-
chown -R mysql.mysql /var/lib/mysql
First create a .my.cnf file containing the mysql root password in your users home folder, on linux.
On windows, there exists a .my.ini or something which serves the same purpose. That way you will not have to reenter your passwords a lot during the next steps, which you are very likely to repeat several times until you get them right, I fear. :)
Since unix/linux and windows have different ways to save files, you might very likely run into errors during a simple copy-restore process, depending on how you copy files.
Your best bet is likely copying the original mysql folders to another windows machine and save them accordingly, such that mysql can find them. (With an installed mysql instance, of course.) I don't know what else you might need, if the databases are not found instantly, since I never had to do this prior and have no test setup here to check this case out.
When the databases are found through the mysql on the WINDOWS server, from the mysql cli prompt there look up which encoding etc the db uses:
SELECT SCHEMA_NAME 'database', default_character_set_name 'charset', DEFAULT_COLLATION_NAME 'collation' FROM information_schema.SCHEMATA;
Then create a new database on the LINUX server with the same name and the same encoding's from MYSQL CLI:
create database <db-name> character set <charset> collate <collation>;
Then on the WINDOWS server in a CMD window, do a mysqldump which should look familiar on windows like on linux:
mysqldump <db-name> > <db-name>.sql
Then copy the dump over to the LINUX server and replay it:
mysql <db-name> < <db-name>.sql
Afterwards you will have to recreate a user (if you know which user and password your web app used to access the database, create a new user with these credentials and grant him full access on your database.
If you do not happen to know the credentials anymore, create an arbitrary user and then change the database credentials in the configfile of your web application.
In case you have problems, check the unix file permissions of the files you copied, such that mysql can access them.
Good luck, mate.
I just want to know how to back up data From MYSQL database and Still be able to use that data
again on reinstalling MYSQL ?
NOTE-- i got into this problem after changing my ROOT password . I posted a question regarding fixing this .But unfortunately don't got the solution .So i decided the last step will be to BACK UP my data !
Here is a LINK to that
post
Can't connect after changing MySQL root password in WAMP
P.S----I HAVE NO ACCESS TO PHPMYADMIN
go to your wamp installation drive, and then go to wamp folder
traverse it if the drive is C: and installation folder is WAMP
C:\wamp\mysql\data\
you will see the folder as the name of your database here
copy it to other place and paste it after reinstall phpmyadmin in the same position
Okay, assuming that you know the new/old/current root passwords run the following
mysqldump -u root --all-databases -p
This should ask you the password and dump sql onto the stdout.
To save it to backup.sql,
mysqldump -u root --all-databases -p > backup.sql