In MySQL user always tries to connect with the server via command line interface such as remote login like 'ssh' then they troubled themselves in using graphical interface and get the required output quickly. So they need to automate that task. In this Blog I am going to suggest you a way to do this ...
First of all we need to know that a MySQL service is kept in /etc/init.d/mysqld and we need to invoke that in order to use mysql server and client.
To do this use following command in terminal :
When mysql server is started make a directory like /home/anduril/shubham_Script and after entering into that directory use this command in your terminal.
It will create a file with the name connect_string.sh you can give any name you want. Press 'i' to edit and enter the following text :
Where mysql is plateform -u stands for username in this case it is root and the switch -p demands for password which is concatenated with the switch -p and in this case it is root. Users can also specify their host with the switch -h and the host name with a space between them.
In the 5th command we have used a file named 'queries_mysql_script.sql' and saved our queries in this file and run our script.
In the Last statement we have used -e switch to enter our command at the terminal and have fun .
This small script could be very useful when you need to take daily dump and forward it in zip . I hope it helps you.
First of all we need to know that a MySQL service is kept in /etc/init.d/mysqld and we need to invoke that in order to use mysql server and client.
To do this use following command in terminal :
service /etc/init.d/mysqld start
or
service mysqld start
or
service mysqld start
When mysql server is started make a directory like /home/anduril/shubham_Script and after entering into that directory use this command in your terminal.
vi connect_string.sh
It will create a file with the name connect_string.sh you can give any name you want. Press 'i' to edit and enter the following text :
mysqlshow -u root -proot
mysqladmin version -u root -proot
mysqladmin variables -u root -proot
mysqladmin ping -u root -proot
mysql -u root -proot
echo Execute SQL from Linux command line interface:
mysql -h localhost -u root -proot -e "select host,db,user from db" mysql
After enterning all text press esc and use ':wq' to exit from vim...mysqladmin version -u root -proot
mysqladmin variables -u root -proot
mysqladmin ping -u root -proot
mysql -u root -proot
echo Execute SQL from Linux command line interface:
mysql -h localhost -u root -proot -e "select host,db,user from db" mysql
Where mysql is plateform -u stands for username in this case it is root and the switch -p demands for password which is concatenated with the switch -p and in this case it is root. Users can also specify their host with the switch -h and the host name with a space between them.
In the 5th command we have used a file named 'queries_mysql_script.sql' and saved our queries in this file and run our script.
In the Last statement we have used -e switch to enter our command at the terminal and have fun .
This small script could be very useful when you need to take daily dump and forward it in zip . I hope it helps you.
Comments
Post a Comment