You are on page 1of 22

System Administration

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.


Objectives

After completing this lesson, you should be able to:


• Choose the proper type of MySQL server software
distribution
• Install the MySQL server
• Describe the MySQL server post-installation file structure
• Start and stop the MySQL server
• Upgrade MySQL
• Run multiple MySQL servers on a single host

3-2 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
MySQL Server Distributions

Binary Source

Precompiled
Self-compile
Available per
Release

Operating Systems
Latest Code
Linux

Windows

Mac OS X
Available
Immediately
Oracle Solaris

3-3 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
MySQL Binary Distributions

Binary Distributions
Linux Windows
RPM Files Complete
TAR Files No-install

Advantages of using binary distributions:


• Created by experienced MySQL staff
• Good configuration options for improved performance
• High-quality commercial compilers
• Extensive libraries provided
• Include tested bug fixes, third-party patches, and features

3-4 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
MySQL Source Distributions

• Are used when:


– No binary exists for your particular platform
– You need to enable a source-only feature
– You need to disable a feature that is not needed
– You need to access the most current code
• Require you to compile the source code
• Are provided as compressed .tar archives

3-5 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
MySQL RPM Installation Files for Linux

shared-
server
compat
Distribution-
independent
embed-
client
ded

devel
RPM ndb
Packages
debug-
test
info
Distribution-
specific

shared source

3-6 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Linux MySQL RPM Installation Process

Download Install Start the


RPM files. RPM files. server.

3-7 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Linux MySQL Server Installation Directories

/var/lib/mysql /usr/sbin /usr/bin

mysql <other <InnoDB log mysql


mysqld
(database database files and system <and other user
(server)
directory) directories> tablespace> tools>

/etc /usr /etc/init.d /var/log

mysql
my.cnf my.cnf mysqld.log
(startup script)

3-8 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Starting the MySQL Server on Linux

• The server can be started from a command line:


service mysql start
• Starting the server follows this progression:

mysql.server mysqld_safe mysqld

Starts Starts

Starts
multiple

mysqld_multi
Starts multiple

3-9 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Stopping the MySQL Server on Linux

• Methods for stopping the server:


Script Method Description
mysqladmin Connects to the server as a client to shut down the server (local
or remote)
mysql.server Stops and/or shuts down the local server

mysqld_multi Invokes mysqladmin to stop and/or shut down servers that it


manages

• Stop the server from command line:


service mysql stop

• Check whether the server is running or not:


service mysql status

3 - 10 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.


Improving Installation Security

• Invoke the security program:


mysql_secure_installation

– Prompts for actions to perform


– Applicable to UNIX and Linux operating systems only
• Security improvements
– Sets or changes password for root accounts
– Removes remote root accounts
– Removes anonymous accounts
– Removes the test database

3 - 11 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.


Windows MySQL Server Installation Directory

C:\Program D:<Windows_version-
Files\MySQL\MySQL Server dependent path>\MySQL
<version> Server <version>

\bin my.ini \data

<database
mysqld.exe
directories>

<other client
<log files>
programs>

3 - 12 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.


Running MySQL on Windows

Methods for Running MySQL on Windows

Server Service
• Start manually. • Install manually.
• Stop manually. • Start/stop manually
or automatically.
• Use GUI.

3 - 13 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.


Data Directory

• Example
MySQL
MySQL
data
Data

mysql
mysql Tables in DB
City
test
test
City
Country
Country
world
world Country.frm
Country
Language
Country.frm

• Implications of database directory mapping: CountryLanguage.frm

– Database and table names are case-sensitive (according to


OS setup).
– Databases can be mounted on separate physical devices to
improve performance.

3 - 14 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.


MySQL Server Releases

• Oracle frequently releases new MySQL versions:


– New features
– Bug fixes
• You can check implications before upgrading.
• Upgrade procedure:
Install Check
Stop Back Up Start New
New Upgraded
Server Database Server
Release Tables

– The upgrade might require reconfiguration.


• You can evaluate the impact of the upgrade in a test
environment.

3 - 15 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.


Checking Upgraded Tables

1. Make sure that the MySQL server is running.


2. Execute the following for every upgrade:
mysql_upgrade [options]

3. Check table status.


4. Check and repair tables:
mysqlcheck [options]
5. Upgrade system tables.
6. Mark upgraded tables with the current version.
7. Save the new version in a file:
mysql_upgrade.info

3 - 16 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.


Employing Multiple Servers

• Useful for many administrative purposes, such as:


– Testing a new release of MySQL
– Partitioning client groups into different servers
• Servers must not interfere with each other.
• mysqld_multi allows you to manage multiple similar
servers with different settings.

3 - 17 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.


Multiple Server Options

Data Directory
• datadir option

InnoDB Service Name


Tablespace (Windows)
Files • install option

Server
Network
• Port
• Socket Group Name
• Named Pipe (Linux)
• Shared
memory

Log Files
• datadir

3 - 18 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.


Summary

In this lesson, you should have learned how to:


• Choose the proper type of MySQL server software
distribution
• Install the MySQL server
• Describe the MySQL server post-installation file structure
• Start and stop the MySQL server
• Upgrade MySQL
• Run multiple MySQL servers on a single host

3 - 20 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.


Practice 3-1 Overview:
Installing the MySQL Server
In this practice, you install the MySQL server.

3 - 21 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.


Practice 3-2 Overview:
MySQL Data Directory
In this practice, you review the data directory associated with
the MySQL server.

3 - 22 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.


Practice 3-3 Overview:
Starting and Stopping the MySQL Server
In this practice, you start and stop the MySQL server.

3 - 23 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

You might also like