Storing MySQL credentials on a file

MySQL allows you to store credentials in a file called ~/.my.cnf. The contents can look like this: [mysqldump] user=myuser password=mypassword We have to modify the file permissions and give read/write permissions to the owner only: chmod 600 ~/.my.cnf And done. We can now use it: mysqldump mydatabase mysqldump is going to read the credentials from that file.

Common tasks when working with MySQL

How to install MySQL server in Ubuntu It’s pretty simple: sudo apt-get install mysql-server How to connect to MySQL using Java This is a useful and simple snippet: import java.sql.Connection; import java.sql.DriverManager; public class Test { public static void main(String[] args) { try { Class.forName("com.mysql.jdbc.Driver"); Connection c = DriverManager.getConnection( "jdbc:mysql://localhost/?user=root&password="); c.close(); System.out.println("Success"); } catch (Exception e) { e.printStackTrace(); } } } How to connect to MySQL using C# Go to http://www.

Create a connection to MySQL in Java

This time we are going to create a basic connection to MySQL in Java and pull some data from it. // Compile it: // javac // // Try it: // java -classpath mysql-connector-java-5.1.27-bin.jar:. MySQL import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Properties; public class MySQL { public Connection getConnection() throws SQLException { Connection conn = null; Properties p = new Properties(); p.put("user", "username"); p.put("password", "superpassword"); String cs = "jdbc:mysql://localhost/demo"; conn = DriverManager.

How to Move a WordPress Blog to a New Domain or Location

Before trying the queries in this page, I recommend you to read this full article to learn more about the process. To update WordPress options with the new blog location, use the following SQL command: UPDATE wp_options SET option_value = replace(option_value, '', '') WHERE option_name = 'home' OR option_name = 'siteurl'; After that you will need to fix URLs of the WordPress posts and pages, which translated from post slug, and stored in database wp_posts table as guid field.