Your SlideShare is downloading. ×
My sql administration
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

My sql administration

1,013
views

Published on

mysql administration with command

mysql administration with command

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,013
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
113
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • 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
  • Transcript

    • 1. Mohd Yasin Abd Karimyasin@teras-solution.com
    • 2.  Configuring Monitoring, Starting & Stopping Managing Users and Connection Performing backups Others
    • 3.  Mysqladmin or mysql GUI ◦ MySQL Administrator ◦ MySQL Workbench ◦ phpMyAdmin
    • 4.  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
    • 5.  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
    • 6.  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
    • 7.  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.
    • 8.  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
    • 9.  Configured to listen TCP/IP Port (default 3306) Additional Instances ◦ Different Ports ◦ Different IP‟s using default Port Local connection using Socket
    • 10.  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;
    • 11.  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];
    • 12.  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];
    • 13.  SHOW TABLES; SHOW WARNINGS; SHOW STATUS; FLUSH STATUS; SHOW VARIABLES; SHOW VARIABLES LIKE „%size%‟; SHOW VARIABLES LIKE „sort_buffer_size‟; SHOW GLOBAL STATUS;
    • 14.  to check version number of your MySQL server C:localmysqlbin>mysqladmin -u root version
    • 15.  According to the /etc/my.cnf Usually located in subdirectory /var/lib/mysql/ directory Example : test database ◦ /var/lib/mysql/test
    • 16.  Root or superuser account is used to create and delete database New installation MySQL set password #mysqladmin –u root password new-password
    • 17.  to know what else you can do with "mysqladmin", you should run the "-?" #mysqladmin –?
    • 18.  Creating new user # mysql -u root -p mysql> use mysql; mysql> INSERT INTO user (Host,User,Password) VALUES(%,username,PASSWORD(password)); mysql> flush privileges;
    • 19.  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;
    • 20.  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;
    • 21.  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;
    • 22.  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;
    • 23.  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
    • 24.  Restore database / table from backup # mysql -u username -ppassword databasename < /tmp/databasename.sql
    • 25.  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));
    • 26.  yasin@teras-solution.com