SHOW TABLES WHERE Tables_in_mydbname LIKE '%reward%'
suppose mydbname is 'blogposts'
SHOW TABLES WHERE Tables_in_blogposts LIKE '%reward%'
suppose mydbname is 'blogposts'
SHOW TABLES WHERE Tables_in_blogposts LIKE '%reward%'
mysqldump -u username -p database --ignore-table=database.table1
--ignore-table=database.table2 > database.sql
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
Eg:
String today = "2013/06/25";
SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
try {
Date date = formatter.parse(today);
long dateInLong = date.getTime();
System.out.println(date);
System.out.println(dateInLong);
System.out.println(new Timestamp(dateInLong));
} catch (Exception e) {
e.printStackTrace();
}
o/p:
Tue Jun 25 00:00:00 IST 2013
1372098600000
2013-06-25 00:00:00.0
SELECT table_name, table_type, engine
->FROM information_schema.tables
->WHERE table_schema = 'db5'
->ORDER BY table_name DESC;
Retrieving the data from the query as collection of pair.
Suppose the query is "Select username, count(id)..". If the query
returns a list String, Long pair then the query actually
returns it as list<Object[]>. So collect the result in a
variable List<Object[]>.
And then iterate over the object array. To get the values,
Cast the corresponding object.
Query q1 = em.createQuery("SELECT e.name, e.salary
FROM Employee e");
List<Object[]> result1 = q1.getResultList();
for (Object[] resultElement : result1) {
String name = (String)resultElement[0];
Double salary = (Double)resultElement[1];
...
}
Query q2 = em.createQuery("SELECT e.name, e.salary,
e.department FROM Employee e");
List<Object[]> result2 = q2.getResultList();
for (Object[] resultElement : result2) {
String name = (String)resultElement[0];
Double salary = (Double)resultElement[1];
Department dept = (Department)resultElement[2];
...
}
Query q3 = em.createQuery("SELECT COUNT(e),
SUM(e.salary) FROM Employee e");
Object[] result3 = (Object[])q3.getSingleResult();
Long count = (Long)result3[0];
Double sum = (Double)result3[1];
FROM
Foo
WHERE
Id = :id AND
Bar IN (:barList)
To check in a set of results or values.
UseQuery.setParameterList()
, Javadoc here.
# /etc/init.d/mysql stop
Stopping MySQL database server: mysqld.
# mysqld_safe --skip-grant-tables &
[1] 5988 Starting mysqld daemon with databases from /var/lib/mysql mysqld_safe[6025]: started
# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>
mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit
# /etc/init.d/mysql stop
Stopping MySQL database server: mysqld STOPPING server from pid file /var/run/mysqld/mysqld.pid mysqld_safe[6186]: ended [1]+ Done mysqld_safe --skip-grant-tables
# /etc/init.d/mysql start
# mysql -u root -p
http://www.cyberciti.biz/tips/recover-mysql-root-password.html