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

or

#mysql -u root -h myserver-sever.com -p

2. Create new database

>CREATE DATABASE DUMPDB;

3. Provide privilegesto the database and users

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

>mysql -u user1 –p

Password:

4. To change mysql user password:

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

>FLUSH PRIVILEGES;

>exit

5. To login without password

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

Create the .my.cnf and add

#vi  ~/my.cnf/

[client]user=rootpassword=root_passwdhost=192.168.1.2

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;

>exit

#/etc/init.d/mysqld restart

Both comments and pings are currently closed.

Comments are closed.

Copyright ©Solutions@Experts.com
Copyright © NewWpThemes Techmark Solutions - www.techmarksolutions.co.uk