Skip to main content

Mysql Scripts in Linux Command Line Terminal

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 :
service /etc/init.d/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...
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

Popular posts

Using Flash in your HTML

Edit your Publish settings for Flash SWFs and HTML to reflect how you want your Flash SWF to appear in your web page. Export your Flash movie as HTML. Locate your HTML file on your computer, right-click, and select "Open With". Choose either NotePad or another text editor. Copy the source code from the HTML file. Paste it into your web page's source code in the appropriate location where you want your SWF file to display. Edit the file path to reflect the location of the SWF file on your web server, and upload both your HTML and SWF file to the appropriate directories on your server. ( Note:  this also applies if you're using PHP, JSP, ASP, CGI, or other web page extensions.) Your code should look something like this: <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="320" HEIGHT="240" id="You...

Enter your email address: