SlideShare a Scribd company logo
Mohd Yasin Abd Karim
yasin@teras-solution.com
   Configuring
   Monitoring, Starting & Stopping
   Managing Users and Connection
   Performing backups
   Others
My sql administration
   Mysqladmin or mysql
   GUI
    ◦ MySQL Administrator
    ◦ MySQL Workbench
    ◦ phpMyAdmin
   OS packages place files in many areas and
    varies
    ◦ e.g. /usr/lib, /var/lib, /var/log, /etc
   Source rpm, yum, .tar.gz, exe
   Online/repo update
    ◦ #yum update mysql-*
   For Ms Windows Environment
    C:>cd localmysqlbin
    C:localmysqlbin>

Local folder normally Program Files folder
   Start MySQL process before create database
   To configure MySQL start at boot time
         #chkconfig mysqld on


   Or using GUI tools such as OS Services
    Management
   After boot time using the services commands

      #service mysqld start
      #service mysqld stop
      #Service mysqld restart

   Remember to restart mysqld process every
    time after configuration changed
   to know whether your MySQL server is alive

       #pgrep mysqld


   Should get response process ID numbers
   Or
       #mysqladmin –u root –p ping

   The "mysqld is alive" message tells you that
    your MySQL server is running ok. If your
    MySQL server is not running, you will get a
    "connect ... failed" message.
   my.cnf
    ◦ Watch out for /etc/my.cnf, /etc/mysql/my.cnf
   To get the server listening on all
    interfaces, use 0.0.0.0 as the bind address.
    i.e.:
    --bind-address=0.0.0.0
   Configured to listen TCP/IP Port (default
    3306)
   Additional Instances
    ◦ Different Ports
    ◦ Different IP‟s using default Port
   Local connection using Socket
   Login to MySQL server
       #mysql –h hostname –u root -p


   Create a database
       msql> create database [databasename];


   List all databases on the MySQL server
       msql> show databases;
   Swicth to a database

       msql> use [db_name];


   To see all the tables in the db
       msql> show tables;


   To delete a db
       msql> drop database [databasename];
   To see database‟s field formats
       msql> describe [table name];


   To delete a table
       msql> drop table [table name];


   Show all data in a table

       msql> SELECT * FROM [table name];
   SHOW   TABLES;
   SHOW   WARNINGS;
   SHOW   STATUS; FLUSH STATUS;
   SHOW   VARIABLES;
   SHOW   VARIABLES LIKE „%size%‟;
   SHOW   VARIABLES LIKE „sort_buffer_size‟;
   SHOW   GLOBAL STATUS;
   to check version number of your MySQL
    server

     C:localmysqlbin>mysqladmin -u root version
   According to the /etc/my.cnf
   Usually located in subdirectory
    /var/lib/mysql/ directory
   Example : test database
    ◦ /var/lib/mysql/test
   Root or superuser account is used to create
    and delete database
   New installation MySQL set password

      #mysqladmin –u root password new-password
   to know what else you can do with
    "mysqladmin", you should run the "-?"

     #mysqladmin –?
   Creating new user

     # mysql -u root -p
     mysql> use mysql;
     mysql> INSERT INTO user (Host,User,Password)
     VALUES('%','username',PASSWORD('password'));
     mysql> flush privileges;
   Change a user password from unix shell

     # mysqladmin -u username -h hostname.org -p password
     'new-password'


   Change user password from MySQL prompt
     # mysql -u root -p
     mysql> SET PASSWORD FOR 'user'@'hostname' =
     PASSWORD('passwordhere');
     mysql> flush privileges;
   Update root password

     # mysqladmin -u root -p oldpassword newpassword


   Allow the user “bob” to connect to server
    from localhost using password „passwd‟
     # mysql -u root -p
     mysql> use mysql;
     mysql> grant usage on *.* to bob@localhost identified by
     'passwd';
     mysql> flush privileges;
   Give user privileges for a db.

     # mysql -u root -p
     mysql> use mysql;
     mysql> INSERT INTO db
     (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv
     ,Create_priv,Drop_priv) VALUES
     ('%','databasename','username','Y','Y','Y','Y','Y','N');
     mysql> flush privileges;

     or

     mysql> grant all privileges on databasename.* to
     username@localhost;
     mysql> flush privileges;
   To update info already in table

     mysql> UPDATE [table name] SET Select_priv = 'Y',Insert_priv
     = 'Y',Update_priv = 'Y' where [field name] = 'user';


   Delete a rows from table
     mysql> DELETE from [table name] where [field name] =
     'whatever';

   Update database permissions/privileges
     mysql> flush privileges;
   Dump all databases for backup
    # mysqldump -u root -ppassword --opt >/tmp/alldatabases.sql


   Dump one database for backup
    # mysqldump -u username -ppassword --databases
    databasename >/tmp/databasename.sql


   Dump a table from a database
    # mysqldump -c -u username -ppassword databasename
    tablename > /tmp/databasename.tablename.sql
   Restore database / table from backup
    # mysql -u username -ppassword databasename <
    /tmp/databasename.sql
   Example
    mysql> create table [table name] (personid int(50) not null
    auto_increment primary key,firstname varchar(35),middlename
    varchar(50),lastnamevarchar(50) default „yasin');


    mysql> CREATE TABLE [table name] (firstname
    VARCHAR(20), middleinitial VARCHAR(3), lastname
    VARCHAR(35),suffix VARCHAR(3),officeid VARCHAR(10),userid
    VARCHAR(15),username VARCHAR(8),email VARCHAR(35),phone
    VARCHAR(25), groups VARCHAR(15),datestamp DATE,timestamp
    time,pgpemail VARCHAR(255));
   yasin@teras-solution.com

More Related Content

What's hot (20)

PDF
Troubleshooting MySQL Performance
Sveta Smirnova
 
PDF
MySQL database replication
PoguttuezhiniVP
 
PDF
My SQL 101
Dave Stokes
 
PDF
Highload Perf Tuning
HighLoad2009
 
PPTX
ProxySQL & PXC(Query routing and Failover Test)
YoungHeon (Roy) Kim
 
ODP
Database Connection With Mysql
Harit Kothari
 
PDF
MySQL Performance Schema in Action
Sveta Smirnova
 
PDF
Mysql database basic user guide
PoguttuezhiniVP
 
PPT
A brief introduction to PostgreSQL
Vu Hung Nguyen
 
PDF
Percona Toolkit for Effective MySQL Administration
Mydbops
 
PDF
Developers’ mDay 2021: Bogdan Kecman, Oracle – MySQL nekad i sad
mCloud
 
PDF
Introduction to MySQL InnoDB Cluster
I Goo Lee
 
ODP
Caching and tuning fun for high scalability
Wim Godden
 
PDF
Memcached Presentation @757rb
Ken Collins
 
PDF
15 MySQL Basics #burningkeyboards
Denis Ristic
 
PDF
Capturing, Analyzing, and Optimizing your SQL
Padraig O'Sullivan
 
PDF
MariaDB Optimizer
JongJin Lee
 
PDF
Top Node.js Metrics to Watch
Sematext Group, Inc.
 
DOCX
Mater,slave on mysql
Vasudeva Rao
 
Troubleshooting MySQL Performance
Sveta Smirnova
 
MySQL database replication
PoguttuezhiniVP
 
My SQL 101
Dave Stokes
 
Highload Perf Tuning
HighLoad2009
 
ProxySQL & PXC(Query routing and Failover Test)
YoungHeon (Roy) Kim
 
Database Connection With Mysql
Harit Kothari
 
MySQL Performance Schema in Action
Sveta Smirnova
 
Mysql database basic user guide
PoguttuezhiniVP
 
A brief introduction to PostgreSQL
Vu Hung Nguyen
 
Percona Toolkit for Effective MySQL Administration
Mydbops
 
Developers’ mDay 2021: Bogdan Kecman, Oracle – MySQL nekad i sad
mCloud
 
Introduction to MySQL InnoDB Cluster
I Goo Lee
 
Caching and tuning fun for high scalability
Wim Godden
 
Memcached Presentation @757rb
Ken Collins
 
15 MySQL Basics #burningkeyboards
Denis Ristic
 
Capturing, Analyzing, and Optimizing your SQL
Padraig O'Sullivan
 
MariaDB Optimizer
JongJin Lee
 
Top Node.js Metrics to Watch
Sematext Group, Inc.
 
Mater,slave on mysql
Vasudeva Rao
 

Viewers also liked (6)

PDF
openark-kit: MySQL utilities for everyday use
Shlomi Noach
 
PDF
common_schema 2.0: DBA's Framework for MySQL
Shlomi Noach
 
PDF
MySQL DevOps at Outbrain
Shlomi Noach
 
PDF
Pseudo gtid & easy replication topology management
Shlomi Noach
 
PDF
Managing and Visualizing your Replication Topologies with Orchestrator
Shlomi Noach
 
PDF
Pseudo GTID and Easy MySQL Replication Topology Management
Shlomi Noach
 
openark-kit: MySQL utilities for everyday use
Shlomi Noach
 
common_schema 2.0: DBA's Framework for MySQL
Shlomi Noach
 
MySQL DevOps at Outbrain
Shlomi Noach
 
Pseudo gtid & easy replication topology management
Shlomi Noach
 
Managing and Visualizing your Replication Topologies with Orchestrator
Shlomi Noach
 
Pseudo GTID and Easy MySQL Replication Topology Management
Shlomi Noach
 
Ad

Similar to My sql administration (20)

PDF
Mysql administration
beben benzy
 
PPTX
MySQL DBA OCP 1Z0-883
Kwaye Kant
 
DOCX
Multiple instances second method
Vasudeva Rao
 
PPT
Raj mysql
firstplanet
 
PDF
MySQL for Oracle DBAs
Mark Leith
 
PDF
Chef solo the beginning
A.K.M. Ahsrafuzzaman
 
PDF
Multiple instances on linux
Vasudeva Rao
 
PPTX
Distribuido
Jose Rojas
 
PPT
My two cents about Mysql backup
Andrejs Vorobjovs
 
PDF
MySql cheat sheet
Lam Hoang
 
PPT
Architecting cloud
Tahsin Hasan
 
DOCX
Multiple instance on windows
Vasudeva Rao
 
PDF
MariaDB, MySQL and Ansible: automating database infrastructures
Federico Razzoli
 
PDF
Passwordless login with unix auth_socket
Otto Kekäläinen
 
PPT
Mysql
Mindtree
 
PDF
TrinityCore server install guide
Seungmin Shin
 
TXT
Intalacion de owncloud
Fredy Ntn Bautista
 
PDF
Service discovery and configuration provisioning
Source Ministry
 
Mysql administration
beben benzy
 
MySQL DBA OCP 1Z0-883
Kwaye Kant
 
Multiple instances second method
Vasudeva Rao
 
Raj mysql
firstplanet
 
MySQL for Oracle DBAs
Mark Leith
 
Chef solo the beginning
A.K.M. Ahsrafuzzaman
 
Multiple instances on linux
Vasudeva Rao
 
Distribuido
Jose Rojas
 
My two cents about Mysql backup
Andrejs Vorobjovs
 
MySql cheat sheet
Lam Hoang
 
Architecting cloud
Tahsin Hasan
 
Multiple instance on windows
Vasudeva Rao
 
MariaDB, MySQL and Ansible: automating database infrastructures
Federico Razzoli
 
Passwordless login with unix auth_socket
Otto Kekäläinen
 
Mysql
Mindtree
 
TrinityCore server install guide
Seungmin Shin
 
Intalacion de owncloud
Fredy Ntn Bautista
 
Service discovery and configuration provisioning
Source Ministry
 
Ad

More from Mohd yasin Karim (10)

PPT
1. centos tutorial
Mohd yasin Karim
 
PPT
3. introduction of centos
Mohd yasin Karim
 
PPT
5. centos security
Mohd yasin Karim
 
PPT
4. Centos Administration
Mohd yasin Karim
 
PPT
6. centos networking
Mohd yasin Karim
 
PPT
2. introduction to linux
Mohd yasin Karim
 
PPTX
Microsoft<sup>®</sup> office training
Mohd yasin Karim
 
PPTX
Phpmyadmin administer mysql
Mohd yasin Karim
 
PPTX
Mysql workbench 5
Mohd yasin Karim
 
PPTX
Mysql an introduction
Mohd yasin Karim
 
1. centos tutorial
Mohd yasin Karim
 
3. introduction of centos
Mohd yasin Karim
 
5. centos security
Mohd yasin Karim
 
4. Centos Administration
Mohd yasin Karim
 
6. centos networking
Mohd yasin Karim
 
2. introduction to linux
Mohd yasin Karim
 
Microsoft<sup>®</sup> office training
Mohd yasin Karim
 
Phpmyadmin administer mysql
Mohd yasin Karim
 
Mysql workbench 5
Mohd yasin Karim
 
Mysql an introduction
Mohd yasin Karim
 

Recently uploaded (20)

PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 

My sql administration

  • 2. Configuring  Monitoring, Starting & Stopping  Managing Users and Connection  Performing backups  Others
  • 4. Mysqladmin or mysql  GUI ◦ MySQL Administrator ◦ MySQL Workbench ◦ phpMyAdmin
  • 5. OS packages place files in many areas and varies ◦ e.g. /usr/lib, /var/lib, /var/log, /etc  Source rpm, yum, .tar.gz, exe  Online/repo update ◦ #yum update mysql-*  For Ms Windows Environment C:>cd localmysqlbin C:localmysqlbin> Local folder normally Program Files folder
  • 6. Start MySQL process before create database  To configure MySQL start at boot time #chkconfig mysqld on  Or using GUI tools such as OS Services Management
  • 7. After boot time using the services commands #service mysqld start #service mysqld stop #Service mysqld restart  Remember to restart mysqld process every time after configuration changed
  • 8. to know whether your MySQL server is alive #pgrep mysqld  Should get response process ID numbers  Or #mysqladmin –u root –p ping  The "mysqld is alive" message tells you that your MySQL server is running ok. If your MySQL server is not running, you will get a "connect ... failed" message.
  • 9. my.cnf ◦ Watch out for /etc/my.cnf, /etc/mysql/my.cnf  To get the server listening on all interfaces, use 0.0.0.0 as the bind address. i.e.: --bind-address=0.0.0.0
  • 10. Configured to listen TCP/IP Port (default 3306)  Additional Instances ◦ Different Ports ◦ Different IP‟s using default Port  Local connection using Socket
  • 11. Login to MySQL server #mysql –h hostname –u root -p  Create a database msql> create database [databasename];  List all databases on the MySQL server msql> show databases;
  • 12. Swicth to a database msql> use [db_name];  To see all the tables in the db msql> show tables;  To delete a db msql> drop database [databasename];
  • 13. To see database‟s field formats msql> describe [table name];  To delete a table msql> drop table [table name];  Show all data in a table msql> SELECT * FROM [table name];
  • 14. SHOW TABLES;  SHOW WARNINGS;  SHOW STATUS; FLUSH STATUS;  SHOW VARIABLES;  SHOW VARIABLES LIKE „%size%‟;  SHOW VARIABLES LIKE „sort_buffer_size‟;  SHOW GLOBAL STATUS;
  • 15. to check version number of your MySQL server C:localmysqlbin>mysqladmin -u root version
  • 16. According to the /etc/my.cnf  Usually located in subdirectory /var/lib/mysql/ directory  Example : test database ◦ /var/lib/mysql/test
  • 17. Root or superuser account is used to create and delete database  New installation MySQL set password #mysqladmin –u root password new-password
  • 18. to know what else you can do with "mysqladmin", you should run the "-?" #mysqladmin –?
  • 19. Creating new user # mysql -u root -p mysql> use mysql; mysql> INSERT INTO user (Host,User,Password) VALUES('%','username',PASSWORD('password')); mysql> flush privileges;
  • 20. Change a user password from unix shell # mysqladmin -u username -h hostname.org -p password 'new-password'  Change user password from MySQL prompt # mysql -u root -p mysql> SET PASSWORD FOR 'user'@'hostname' = PASSWORD('passwordhere'); mysql> flush privileges;
  • 21. Update root password # mysqladmin -u root -p oldpassword newpassword  Allow the user “bob” to connect to server from localhost using password „passwd‟ # mysql -u root -p mysql> use mysql; mysql> grant usage on *.* to bob@localhost identified by 'passwd'; mysql> flush privileges;
  • 22. Give user privileges for a db. # mysql -u root -p mysql> use mysql; mysql> INSERT INTO db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv ,Create_priv,Drop_priv) VALUES ('%','databasename','username','Y','Y','Y','Y','Y','N'); mysql> flush privileges; or mysql> grant all privileges on databasename.* to username@localhost; mysql> flush privileges;
  • 23. To update info already in table mysql> UPDATE [table name] SET Select_priv = 'Y',Insert_priv = 'Y',Update_priv = 'Y' where [field name] = 'user';  Delete a rows from table mysql> DELETE from [table name] where [field name] = 'whatever';  Update database permissions/privileges mysql> flush privileges;
  • 24. Dump all databases for backup # mysqldump -u root -ppassword --opt >/tmp/alldatabases.sql  Dump one database for backup # mysqldump -u username -ppassword --databases databasename >/tmp/databasename.sql  Dump a table from a database # mysqldump -c -u username -ppassword databasename tablename > /tmp/databasename.tablename.sql
  • 25. Restore database / table from backup # mysql -u username -ppassword databasename < /tmp/databasename.sql
  • 26. Example mysql> create table [table name] (personid int(50) not null auto_increment primary key,firstname varchar(35),middlename varchar(50),lastnamevarchar(50) default „yasin'); mysql> CREATE TABLE [table name] (firstname VARCHAR(20), middleinitial VARCHAR(3), lastname VARCHAR(35),suffix VARCHAR(3),officeid VARCHAR(10),userid VARCHAR(15),username VARCHAR(8),email VARCHAR(35),phone VARCHAR(25), groups VARCHAR(15),datestamp DATE,timestamp time,pgpemail VARCHAR(255));

Editor's Notes

  • #10: By default MySQL listens on all your interfaces for database queries from remote MySQL clients. You can see this using netstat -an. Your server will be seen to be listening on IP address 0.0.0.0 (all) on TCP port 3306. Multiple MySQL Instances