mysql

[root@MYSQL ~]# rpm -qa  mysql mysql-server

[root@MYSQL ~]# yum list all |grep   mysql*

[root@MYSQL ~]# yum install mysql mysql-server

[root@MYSQL ~]# netstat -tlpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      2264/sshd
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      2057/cupsd
tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN      2441/sendmail
tcp        0      0 :::22                       :::*                        LISTEN      2264/sshd
tcp        0      0 ::1:631                     :::*                        LISTEN      2057/cupsd
[root@MYSQL ~]# service mysqld status
mysqld is stopped
[root@MYSQL ~]# service mysqld start
Initializing MySQL database:  Installing MySQL system tables…
OK
Filling help tables…
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password ‘new-password’
/usr/bin/mysqladmin -u root -h MYSQL password ‘new-password’

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

[  OK  ]
Starting mysqld:                                           [  OK  ]

[root@MYSQL ~]# netstat -tlpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      3106/mysqld         
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      2264/sshd
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      2057/cupsd
tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN      2441/sendmail
tcp        0      0 :::22                       :::*                        LISTEN      2264/sshd
tcp        0      0 ::1:631                     :::*                        LISTEN      2057/cupsd

[root@MYSQL ~]# cat /etc/my.cnf 
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[root@MYSQL ~]# cat /etc/my.cnf 
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

################# RAFI ADDED ##################
# WARNING!!!
# Security and optimization settings
# Read mysqld and my.cnf man page for more info
# as the following settings depends upon hardware and your requirements
########################################################################
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

## Go faster and skip some stuff, YMMV
skip-name-resolve
skip-slave-start
skip-external-locking

# PER CLIENT SETTINGS #
# bit high but I got tons of ram here #
sort_buffer_size = 2M
read_buffer_size = 2M
binlog_cache_size = 1M
wait_timeout = 200
interactive_timeout = 300
max_allowed_packet = 12M
thread_stack = 128K
table_cache = 1024
myisam_sort_buffer_size = 1M
tmp_table_size = 12M
max_heap_table_size = 12M

# LOGGING #
log_queries_not_using_indexes  = 1
slow_query_log                 = 1
slow_query_log_file            = /var/lib/mysql/slowquery.log

# CACHES AND LIMITS #
tmp_table_size                 = 12M
max_heap_table_size            = 12M
query_cache_type               = 1
query_cache_limit              = 2M
query_cache_size               = 32M
max_connections                = 500
thread_cache_size              = 50
open_files_limit               = 65535
table_definition_cache         = 4096
table_open_cache               = 1024

# MyISAM #
key_buffer_size                = 32M
myisam_recover                 = FORCE,BACKUP

# SAFETY #
max_allowed_packet             = 16M
max_connect_errors             = 1000000

# BINARY LOGGING #
log_bin                        = /var/lib/mysql/mysql-bin
expire_logs_days               = 14
sync_binlog                    = 1

# INNODB #
innodb_flush_method            = O_DIRECT
innodb_log_files_in_group      = 2
innodb_log_file_size           = 256M
innodb_flush_log_at_trx_commit = 1
innodb_file_per_table          = 1
innodb_buffer_pool_size        = 10G

[root@MYSQL ~]# service mysqld status
mysqld (pid  3106) is running…
[root@MYSQL ~]# service mysqld reload
[root@MYSQL ~]# service mysqld restart
Stopping mysqld:                                           [  OK  ]
Starting mysqld:                                           [  OK  ]

[root@MYSQL ~]# iptables -A INPUT -p tcp –dport 3306 -j ACCEPT

[root@MYSQL ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]

[root@MYSQL ~]# service iptables reload
iptables: Trying to reload firewall rules:                 [  OK  ]

[root@MYSQL ~]# service iptables restart
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]

[root@MYSQL ~]# mysql -u root  
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> show databases;
+——————–+
| Database           |
+——————–+
| information_schema |
| mysql              |
| test               |
+——————–+
3 rows in set (0.00 sec)

mysql> use  information_schema;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> show tables;
+—————————————+
| Tables_in_information_schema          |
+—————————————+
| CHARACTER_SETS                        |
| COLLATIONS                            |
| COLLATION_CHARACTER_SET_APPLICABILITY |
| COLUMNS                               |
| COLUMN_PRIVILEGES                     |
| ENGINES                               |
| EVENTS                                |
| FILES                                 |
| GLOBAL_STATUS                         |
| GLOBAL_VARIABLES                      |
| KEY_COLUMN_USAGE                      |
| PARTITIONS                            |
| PLUGINS                               |
| PROCESSLIST                           |
| PROFILING                             |
| REFERENTIAL_CONSTRAINTS               |
| ROUTINES                              |
| SCHEMATA                              |
| SCHEMA_PRIVILEGES                     |
| SESSION_STATUS                        |
| SESSION_VARIABLES                     |
| STATISTICS                            |
| TABLES                                |
| TABLE_CONSTRAINTS                     |
| TABLE_PRIVILEGES                      |
| TRIGGERS                              |
| USER_PRIVILEGES                       |
| VIEWS                                 |
+—————————————+
28 rows in set (0.00 sec)

mysql> select * from CHARACTER_SETS;
+——————–+———————-+—————————–+——–+
| CHARACTER_SET_NAME | DEFAULT_COLLATE_NAME | DESCRIPTION                 | MAXLEN |
+——————–+———————-+—————————–+——–+
| big5               | big5_chinese_ci      | Big5 Traditional Chinese    |      2 |
| dec8               | dec8_swedish_ci      | DEC West European           |      1 |
| cp850              | cp850_general_ci     | DOS West European           |      1 |
| hp8                | hp8_english_ci       | HP West European            |      1 |
| koi8r              | koi8r_general_ci     | KOI8-R Relcom Russian       |      1 |
| latin1             | latin1_swedish_ci    | cp1252 West European        |      1 |
| latin2             | latin2_general_ci    | ISO 8859-2 Central European |      1 |
| swe7               | swe7_swedish_ci      | 7bit Swedish                |      1 |
| ascii              | ascii_general_ci     | US ASCII                    |      1 |
| ujis               | ujis_japanese_ci     | EUC-JP Japanese             |      3 |
| sjis               | sjis_japanese_ci     | Shift-JIS Japanese          |      2 |
| hebrew             | hebrew_general_ci    | ISO 8859-8 Hebrew           |      1 |
| tis620             | tis620_thai_ci       | TIS620 Thai                 |      1 |
| euckr              | euckr_korean_ci      | EUC-KR Korean               |      2 |
| koi8u              | koi8u_general_ci     | KOI8-U Ukrainian            |      1 |
| gb2312             | gb2312_chinese_ci    | GB2312 Simplified Chinese   |      2 |
| greek              | greek_general_ci     | ISO 8859-7 Greek            |      1 |
| cp1250             | cp1250_general_ci    | Windows Central European    |      1 |
| gbk                | gbk_chinese_ci       | GBK Simplified Chinese      |      2 |
| latin5             | latin5_turkish_ci    | ISO 8859-9 Turkish          |      1 |
| armscii8           | armscii8_general_ci  | ARMSCII-8 Armenian          |      1 |
| utf8               | utf8_general_ci      | UTF-8 Unicode               |      3 |
| ucs2               | ucs2_general_ci      | UCS-2 Unicode               |      2 |
| cp866              | cp866_general_ci     | DOS Russian                 |      1 |
| keybcs2            | keybcs2_general_ci   | DOS Kamenicky Czech-Slovak  |      1 |
| macce              | macce_general_ci     | Mac Central European        |      1 |
| macroman           | macroman_general_ci  | Mac West European           |      1 |
| cp852              | cp852_general_ci     | DOS Central European        |      1 |
| latin7             | latin7_general_ci    | ISO 8859-13 Baltic          |      1 |
| cp1251             | cp1251_general_ci    | Windows Cyrillic            |      1 |
| cp1256             | cp1256_general_ci    | Windows Arabic              |      1 |
| cp1257             | cp1257_general_ci    | Windows Baltic              |      1 |
| binary             | binary               | Binary pseudo charset       |      1 |
| geostd8            | geostd8_general_ci   | GEOSTD8 Georgian            |      1 |
| cp932              | cp932_japanese_ci    | SJIS for Windows Japanese   |      2 |
| eucjpms            | eucjpms_japanese_ci  | UJIS for Windows Japanese   |      3 |
+——————–+———————-+—————————–+——–+
36 rows in set (0.00 sec)

mysql> create database rafi;
Query OK, 1 row affected (0.01 sec)

mysql> create database mohammed;
Query OK, 1 row affected (0.00 sec)

mysql> show databases;
+——————–+
| Database           |
+——————–+
| information_schema |
| mohammed           |
| mysql              |
| rafi               |
| test               |
+——————–+
5 rows in set (0.00 sec)

mysql> GRANT ALL ON rafi.* TO jack@localhost IDENTIFIED BY ‘jackpassword’;
Query OK, 0 rows affected (0.00 sec)

mysql> use rafi
Database changed

mysql> show tables;
Empty set (0.00 sec)

mysql> CREATE TABLE first_table (id INT,name VARCHAR(20),email VARCHAR(20));
Query OK, 0 rows affected (0.02 sec)

mysql> show tables;
+—————-+
| Tables_in_rafi |
+—————-+
| first_table    |
+—————-+
1 row in set (0.00 sec)

mysql> select * from first_table;
Empty set (0.00 sec)

mysql> INSERT INTO first_table (id,name,email) VALUES (007,”yesdani”,”mohammedrafi494@gmail.com”);
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> select * from first_table;
+——+———+———————-+
| id   | name    | email                |
+——+———+———————-+
|    7 | yesdani | mohammedrafi494@gmai |
+——+———+———————-+
1 row in set (0.00 sec)

mysql> quit
Bye

[root@MYSQL ~]# mysql -u jack -p ‘rafi’
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> show tables;
+—————-+
| Tables_in_rafi |
+—————-+
| first_table    |
+—————-+
1 row in set (0.00 sec)

mysql> select * from first_table;
+——+———+———————-+
| id   | name    | email                |
+——+———+———————-+
|    7 | yesdani | mohammedrafi494@gmai |
+——+———+———————-+
1 row in set (0.00 sec)

Advertisements
Posted in: db

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s