Sunteți pe pagina 1din 16

Administration and

Configuration of MySQL
Course Name:
Database Faculty Name:
Administration Ms. Zaiba Khan
with MySQL
Branch- Assistant Professor(CSE)
B.Tech-VI Semester School of
Course Code: Engineering &
Technology
19009300
1
Basic Server Administration

 Different command line tool designed specifically to


help administrators perform tasks
◦ Changing the MySQL
◦ Administrator Password
◦ Reloading MySQL Privileges.

 This tool is called mysqladmin


 Can be found in bin/ directory of your MySQL
installation
For Ex-
[root@host] # /usr/local/mysql/bin/mysqladmin
shutdown
2
Basic Server Administration
 Table invoke different useful commands supported by
mysqladmin:
Command What It Does
Status Return information on server
status
Password Changes a user password
Shutdown Shuts down the MySQL Server
Reload Reload the MySQL grant
tables
Refresh Resets all caches and logs
Variables Return values of all server
variables
Version Returns the server version
Processlist Returns a list of all processes
active on the server
Kill Kills an active server process
ping Tests if the server is alive

3
Basic Server Administration
(Shell Prompt)

4
Starting and Stopping the Server

 On UNIX , MySQL comes with a start and shutdown


script
 This script named as mysql.server available in
support file

[root@host] # /usr/local/mysql/support-files/mysql.server start

 On Windows(Windows 95,98 or Me), MySQL comes


with a start and shutdown script
 Directly by navigating to your MySQL installation
directory & launching mysqld binary by double
clicking it.
C:> c:\mysql\bin\mysqld.exe

5
Tip: Better Safe Than Sorry

 While you can certainly invoke MySQL by directly


running the mysqld from your installation's bin /
directory.

 Using the mysqld_safe wrapper is considered a safe


approach
◦ This wrapper takes care of automatically logging errors
and runtime information to a file or of restarting MySQL
daemon in case of unexpected shutdown.

Note: In older versions of MySQL, mysqld_safe is called


safe_mysqld

6
Starting and Stopping the Server

 On Windows(Windows NT,2000,XP and 2003), which


will more typically be running MySQL in background
 This is accomplished by installing the mysql service
then using the net start command to activate it.
C:> c:\mysql\bin\mysqld --install

 Start the Service via Control Panel(Administrative


Tools Services) or with the command:
C:> net start mysql
 Depending on the version of Windows running ,MySQL
either launch in the foreground (mysqld ) or start as a
service and run invisibly in the background.

7
Starting and Stopping the
Server(Cont..)
 We can also verify if the server is running and this can be done by
using mysqladmin tool with ping command
[root@host]# /usr/local/mysql/bin/mysqladmin ping

mysqld is alive

8
Starting and Stopping the Server

 The mysqladmin utility can also be used to reload the


server’s grant tables, as in the following

[root@host]# /usr/local/mysql/bin/mysqladmin reload

 Once the server is running, you can shut it down at any


time with mysqladmin utility that ships with MySQL,
by invoking it with the shutdown parameter

[root@host]# /usr/local/mysql/bin/mysqladmin shutdown

9
Starting and Stopping the Server

 On Windows, you usually need to open a new DOS


console window or use the Start-> Run dialog box as
follows
C:> c:\mysql\bin\mysqladmin shutdown

 On UNIX, you can also use the provided mysql.server


startup/ shutdown script to shut down the server, as
shown below:

[root@host]# /usr/local/mysql/support-files/mysql.server stop

10
Checking MySQL Server Status

 You can find out the current state of server


◦ Time
◦ Queries per second
◦ Number of currently open tables and so on
Via mysqladmin tool

[root@host]# /usr/local/mysql/bin/mysqladmin status

• The version command offers a more concise summary


[root@host]# /usr/local/mysql/bin/mysqladmin version

 An Equivalent approach is to use the VERSION( ) built-


in function

11
Checking MySQL Server Status
 An Equivalent approach is to use the VERSION( ) built-
in function

 Extended status information is also available via the


extended-status command to mysqladmin or with
the SHOW STATUS command

12
Checking MySQL Server Status
 Extended status information is also available via the
extended-status command to mysqladmin or with
the SHOW STATUS command

13
Checking MySQL Server Status
 A great deal of real time status information is provided:
◦ It contains the amount of traffic the server received since it last
started
 Including no. of bytes sent and received
 The client connection
 Together with a breakdown of how many succeeded
 How many failed
 How many aborted
◦ It also contains statistics on the total no. of queries processed by
the server since startup, together with information on the no. of
the quires in each type(SELECT,DELETE,INSERT,…….)
◦ The number of threads active
◦ The number of current client connections
◦ The number of running queries
◦ The number of open tables

14
Managing MySQL Client Processes
 A complete list of all client processes connected to the
server with the SHOW PROCESSLIST command

15
Managing MySQL Client Processes(Cont..)
 A “regular” user will only be able to see his or her own threads in
the output of SHOW PROCESSLIST
 The PROCESS privilege can, however , see all running threads
 Users with the all powerful SUPER privilege can even kill running
threads, with the KILL command.
mysql> KILL 12;
Query OK, 0 rows affected (0.01 sec)

16

S-ar putea să vă placă și