Wednesday, January 15, 2014

To add a new user to a MySQL database from the Linux command line

This method should work from any operating system that uses the MySQL client application from a terminal.
First we need to log into MySQL on a server so lets do that right now.

 
mysql -u root -p
Then enter your password and hit enter. Now we want to create a database which our new user will have privileges on. If you already have a database you can skip this step.


mysql > create database new_database;
 
Now with our new database in place called new_database we can move on and set up a user for this schema.


mysql > grant usage on *.* to new_database_user@localhost identified by user_password';
 
Now we want the new user to be able to do almost everything in the new database so we run:

mysql > grant all privileges on new_database.* to new_database_user@localhost;
Now to make sure all the settings we entered stick we run:


mysql > flush privileges;
 
Now you should be able to easily log in to the database called new_database on the localhost. If you wanted the user to be able to access the database from any location than you would run the following line instead of the one above:


mysql > grant usage on *.* to new_database_user@'%' identified by 'user_password';
 
Hope this helps people remember how to add users really is in MySQL on the command line.

Tuesday, January 7, 2014

Automated backup of mySql database

To make back up mysql database automatically,we may use task scheduler(for windows) or cron for linux server.

at winodws, we can execute a batch file using task scheduler. The content for batch file is:
--
@echo off
echo Running Rsa dump...
-h -u -p --result-file=
echo Done!

--


for my case the batch file was:
--
@echo off
echo Running Rsa dump...
G:\BACK_UP_Database\mysqldump\newer\mysqldump -h 10.76.12.51 -uroot -p*paul*db# --result-file="G:\BACK_UP_Database\RSA\backup_%DATE%.sql" rsadb
echo Done!
--

it should be noticeable that the user and password is stick to the -u and -p parameter. If we provide space among them then password will be prompt for to input.

The short date format should not contain slash. It causes problem to create file with that name. we may set the short date format as yyyy-MMM-dd .

After that we will have to configure the task manager according to our requirements.

Thursday, January 2, 2014

Java Desktop Applicaiotn in Netbeans: To open a JFrame by clicking a button of another

Double click the specific button in the add the Event Listener on Click Event (ActionListener) 
 
 
public void actionPerformed(ActionEvent e) {
        //  this.setVisible(false);
        this.dispose();
        new FrmMain().setVisible(true); // Main Form to show after the Login Form..
    }

Java Desktop Application using Netebans: How to position the form in the center screen?

In design mode:
select your JFrame(on Design mode), and then go to  Properties, Bindings,Events, Code. 
We need "Code" and set properties Generate Center (true) that's all. 


--
Another way through code:
 
JFrame frame = new JFrame("FooRendererTest");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.getContentPane().add(mainPanel); // or whatever...
  frame.pack();
  frame.setLocationRelativeTo(null);  // *** this will center your app ***
  frame.setVisible(true);