MySql Commands on LINUX

Different types of Useful mysql commands that are used to access mysql  services on linux machine  .

1. Login to mysql root user

#mysql –u root –p


#mysql -u root -h -p

2. Create new database


3. Provide privilegesto the database and users

>GRANT ALL ON DUMPDB.* TO user1@localhost IDENTIFIED BY ‘root’;

>mysql -u user1 –p


4. To change mysql user password:

>SET PASSWORD FOR ‘user name’@'localhost’ = PASSWORD(‘root’);



5. To login without password

#mysql -u $MYSQL_ROOT -p $MYSQL_PASS -h

Create the .my.cnf and add

#vi  ~/my.cnf/


Provide authentication

#chmod 0600  /etc/my.cnf

6. Forgot password recovery

When you have forgot your password, you can recover it by typing the below commands.

#/etc/init.d/mysqld stop

#mysqld_safe –skip-grant-tables &

#mysql –u root

>use mysql;

>update user set password=PASSWORD(“password”) where User=’root’;

>flush privileges;


#/etc/init.d/mysqld restart

Both comments and pings are currently closed.

Comments are closed.

Copyright ©
Copyright © NewWpThemes Techmark Solutions -