When I do a mysqldump in commmand line, I use the .sql extension to save the file, however, I've installed an auto-backup module on my website and the files are being saved as .mysql automatically. Is this unusual and do I use them the same way, by sourcing them into the database? I.E. Are the suffixes interchangeable?
Edit: Can I source a .mysql file the same way I can source a .sql file?
Background info: I've installed the Backup and Migrate module on Drupal and the backups are creating .mysql files, which I've never seen before.
Please note that I am not asking the difference between MySQL and SQL.
The suffix you use is unimportant whether it's .sql, .mysql, .txt or whatever.
Reason is by default, mysqldump writes information as SQL statements to the standard output.
You can get more details by this.
Related
my problem is that when i use mysql to create database it described that it should create db.opt file, but it doesn't. How to fix that, i'm using mysql mysql-8.0.32-winx64 portable version
I have tried to enable that option innodb_file_per_table=ON in my.cnf file;
Also, i have tried to enable server with that argument "--skip-opt", and also imported it in my.cnf;
It seems that noone is faced that problem before and yeah i know that i doesn't really need that file it is just for my homework, by that file i should show that my databases have right CHARACTER SET and COLLATE.
For all that i using comand line interface.
MySQL 8.0 is working as designed. The db.opt file and other metadata files are no longer used, because this version of MySQL implements metadata in a different way.
https://dev.mysql.com/doc/refman/8.0/en/data-dictionary-file-removal.html
The metadata files listed below are removed from MySQL. Unless otherwise noted, data previously stored in metadata files is now stored in data dictionary tables.
...
db.opt files: Database configuration files. These files, one per database directory, contained database default character set attributes.
I have no idea what homework you would be doing that requires direct access to db.opt. That file is normally only used by internal code of MySQL 5. I've been using MySQL since 2001, but I've never had any need to read that file directly.
I have multiple tables to create in my current project (each CREATE in its own .sql file) and the order of creation is important, so I'd like one file to create them all in the proper order when I create a new database. This is not a show-stopper, just an inconvenience. In MySQL (using phpMyAdmin) I'd like a single .sql file that will execute multiple other .sql files. I'm looking for something equivalent to Oracle's ability with the "#" sign (or keyword "start"):
#create_users.sql
#create_services.sql
Does MySql/phpMyAdmin have a similar command as Oracle to do this?
The mysql client has a command source that you can put into a .sql file. It reads another .sql file that you name.
This is analogous to the command of the same name in some POSIX shell scripting languages.
You might like to read this manual page to understand other built-in commands of the MySQL client: https://dev.mysql.com/doc/refman/en/mysql-commands.html
Re your comment: You asked in your question above if MySQL/phpMyAdmin has a similar command. MySQL does.
phpMyAdmin is not a product of MySQL, it's an independent community tool, and it does not have a similar command. phpMyAdmin has an import tab, with which you can upload one .sql file at a time.
The .sql files read by phpMyAdmin don't support all the same built-in commands that the command-line mysql client supports. For example, it does not support the source command, because that would require the web application phpMyAdmin to somehow read additional files from your computer. Web applications can't do that (and it's a good thing they can't).
What do I have to do to these files so that I can copy and paste the files into another program using only default windows functions? Copying and pasting it directly leads to an unstable database and the data within each table does not transfer.
As we answered in your other (nearly identical) question Export table from Xampp MySQL from file directory, this is not recommended and can lead to inconsistency. I could repeat here what I said there, but the answer is the same: if the MySQL service is stopped and if the entire datadir is copied and replaced, and if the MySQL versions are similar enough, then you might be able to accomplish this...but it's not supported and not recommended and you're much more likely to lose data than have success. File-level backups are not recommended for MySQL databases, you should export to an SQL file.
I recently installed a new version of XAMPP. I copied and pasted database folders from the old xampp's mysql/data to the same folder in the newer version. The database names are displayed in phpMyAdmin but it does not show any data.
I know I can do a simple import/export sql to resolve this but I'd like to know why copying and pasting the database folders not working? Do I have to do something else in order to make this work?
I'm going to backup my database regularly using an auto backup tool. Apart from backing up mysql/data folder, do I also need to backup some other folders or files to have a proper database backup?
why copying and pasting the database folders not working? >> as far as I know we need to use import feature, because it will register the database to mysql's infomation_schema.
So even if the database file is stored in the correct folder, it won't show up on the phpmyadmin because it's not registered. And I think mysql didn't do any directory scanning to determine it's database line up.
To back up automatically, there are several ways you can do. Moreover if you use linux OS, you have more freedom to do that, for example create a php script to backup your db and then execute it regulary by using cron job.
hope this can help you.
I've exported a MySQL v4.0.25 script to a sql file and since I can't find an installer for 4.0 anymore the only option left is to use 4.1..
Now, I'm getting the common 1064 error since v4.0 doesn't have utf-8 (only latin-1) and v4.1 gives me a syntax error.
I'd be okay with editing the files manually but, one of the scripts is a file 12GB big and the other one is 5GB so I can't even find an editor able to open a file that large and a problem at hands with this migration (the files are that big because they are a copy of 2 production DBs with over 10years use).
How can I fix or bypass this problem? Any chance I can tell the import script to ignore the lines with errors (and I don't even know how many are there..)?
If it's still possible, dump the data structures in sql and the data tables in csv format using mysqldump --tab=path. This way, any modifications you will need to do will be on the much smaller sql file, keeping the large data files untouched. They you could later import the whole thing using mysqlimport command.
Alternatively, you could always use the mysql --force option for importing your sql file.
More information:
MySQL Reference Manual: mysqldump --tab=path option
MySQL Reference Manual: mysqlimport
MySQL Reference Manual: mysql --force
For manually editing the files:
If you are using Linux as your operating system, then there is a big variety of commands in your hand: more, less, sed, etc. sed is good for substitutions, similar to your question. A nice tutorial can be found at http://www.grymoire.com/Unix/Sed.html
In Windows, I sometimes use PowerShell. I had similar post on StackOverflow about "mysqldump without database name" where there is an example of how to replace a string in a dump file.