![]() Since the dump files are just SQL commands, you can restore the database backup by telling mysql to run the commands in it and put the data into the proper database. ![]() After reinstalling with the desired port number. It is also simple to back up all of the databases on a server: mysqldump -all-databases > all_databases.sqlĪfter taking the backup, remove mysql and reinstall it. In the code above, database_one is the name of the first database to be backed up, and database_two is the name of the second. Multiple databases can be backed up at the same time: mysqldump -databases database_one database_two > two_databases.sql If you want to back up a single database, you merely create the dump and send the output into a file, like so: mysqldump database_name > database_name.sql These dumps are just files with all the SQL commands needed to recreate the database from scratch. The mysqldump command is used to create textfile “dumps” of databases managed by MySQL. Try(conn = DriverManager.The best way to do this is take backup of required database and reconfigure the server. Also you should always close the database connection once you complete interacting with database by calling close() method of the Connection object.įrom Java 7, there is another nice statement called try-with-resources that allows you to simplify the code above as follows: // db parameters Therefore, when you create a Connection object, you should always put it inside a try catch block. in such cases, JDBC throws a SQLException. When connecting to MySQL, anything could happens e.g., database server is not available, wrong user name or password, etc. String url = "jdbc:mysql://localhost:3306/mysqljdbc" Ĭonn = DriverManager.getConnection(url, user, password)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |