Mysql Installation Steps on RHEL 5 for Database versions 5.5.x ,5.6.x and 5.7.x


=========================================================
RHEL – 5 And Mysql DB version 5.5.30
=========================================================

[root@hostname ~]# uname -a

Linux hostname 2.6.18-308.el5 #1 SMP Fri Jan 27 17:17:51 EST 2012 x86_64 x86_64 x86_64 GNU/Linux

[root@hostname ~]# cat /etc/redhat-release

Red Hat Enterprise Linux Server release 5.8 (Tikanga)

[root@hostname ~]# rpm -qa | grep -i mysql

[root@hostname ~]# rpm -qa | grep -i mysql*


[root@hostname lib]# cd mysql/

[root@hostname mysql]# ls

ibdata1 ib_logfile1 metastore performance_schema RPM_UPGRADE_MARKER-LAST

ib_logfile0 hostname.err mysql RPM_UPGRADE_HISTORY test

[root@hostname mysql]# cd ..

[root@hostname lib]# ls -ltr

drwxr-xr-x 6 mysql mysql 4096 Nov 2 22:02 mysql

[root@hostname lib]# rm -rf mysql/

[root@hostname ~]# useradd -g dba -u 888 -d /export/home/mysql -m mysql

[root@hostname ~]# passwd mysql

Changing password for user mysql.

New UNIX password:

BAD PASSWORD: it is too short

Retype new UNIX password:

passwd: all authentication tokens updated successfully.

[root@hostname ~]# su – mysql

[mysql@hostname ~]$ pwd

/export/home/mysql

[mysql@hostname ~]$ ls -ltr

total 0

[mysql@hostname ~]$ exit

logout

[root@hostname ~]# cd /export/home/mysql/

[root@hostname mysql]# ls -ltr

-rw-r–r– 1 root root 2087280 Nov 2 14:49 MySQL-shared-5.5.30-1.rhel5.x86_64.rpm

-rw-r–r– 1 root root 55074410 Nov 2 14:50 MySQL-server-5.5.30-1.rhel5.x86_64.rpm

-rw-r–r– 1 root root 18235430 Nov 2 14:50 MySQL-client-5.5.30-1.rhel5.x86_64.rpm

[root@hostname mysql]# rpm -ivh MySQL-shared-5.5.30-1.rhel5.x86_64.rpm MySQL-server-5.5.30-1.rhel5.x86_64.rpm MySQL-client-5.5.30-1.rhel5.x86_64.rpm Preparing… ########################################### [100%]

1:MySQL-client ########################################### [ 33%]

2:MySQL-shared ########################################### [ 67%]

3:MySQL-server ########################################### [100%]

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 hostname 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.

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

[root@hostname ~]# su – mysql

[mysql@hostname ~]$ mysql_install_db

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 hostname 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!

[mysql@hostname ~]$ exit

logout

[root@hostname ~]# service mysql start

Starting MySQL…. [ OK ]

[root@hostname ~]# /usr/bin/mysqladmin -u root password ‘root123’

[root@hostname ~]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2.Server version: 5.5.30 MySQL Community Server (GPL)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> use mysql;

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 databases;

+——————–+
| Database |
+——————–+
| information_schema |
| mysql |
| performance_schema |
| test |
+——————–+

4 rows in set (0.00 sec)

mysql> select user,host,password from user;

+——+———–+————————————–
| user | host | password |
+——+———–+————————————–
| root | localhost | *FAAFFE644E901CFAFAEC7562415E5FAEC243B8B2 |
| root | hostname | |
| root | 127.0.0.1 | |
| root | ::1 | |
| | localhost | |
| | hostname | |

+——+———–+————————————–

6 rows in set (0.00 sec)

mysql> delete from user where user=”;

Query OK, 2 rows affected (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> select user,host,password from user;

+——+———–+————————————–

| user | host | password |

+——+———–+————————————–

| root | localhost | *FAAFFE644E901CFAFAEC7562415E5FAEC243B8B2 |

| root | hostname | |

| root | 127.0.0.1 | |

| root | ::1 | |

+——+———–+——————————————-+

4 rows in set (0.00 sec)


mysql> update user set password=password(‘root123′) where user=’root’ and host=’hostname′;

Query OK, 1 row affected (0.00 sec)

Rows matched: 1 Changed: 1 Warnings: 0

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> insert into user(host,user,password,select_priv) values (‘%’,’root’,password(‘root123′),’Y’);

Query OK, 1 row affected, 3 warnings (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> select user,host,password from user;

+——+———–+——————————————-+

| user | host | password |

+——+———–+——————————————-+
| root | localhost | *FAAFFE644E901CFAFAEC7562415E5FAEC243B8B2 |
| root | hostname | *FAAFFE644E901CFAFAEC7562415E5FAEC243B8B2 |
| root | 127.0.0.1 | |
| root | ::1 | |
| root | % | *FAAFFE644E901CFAFAEC7562415E5FAEC243B8B2 |

+——+———–+——————————————-+

5 rows in set (0.00 sec)

mysql> grant all on *.* to ‘root’@’%’ with grant option;

Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> select user,host,password from user;

+——+———–+————————————–

| user | host | password |

+——+———–+——————————————-+
| root | localhost | *FAAFFE644E901CFAFAEC7562415E5FAEC243B8B2 |
| root | hostname | *FAAFFE644E901CFAFAEC7562415E5FAEC243B8B2 |
| root | 127.0.0.1 | |
| root | ::1 | |
| root | % | *FAAFFE644E901CFAFAEC7562415E5FAEC243B8B2 |

+——+———–+————————————–

5 rows in set (0.00 sec)

mysql> exit

Bye

[root@hostname ~]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf

[root@hostname ~]# vi /etc/my.cnf

[root@hostname ~]# service mysql restart

Shutting down MySQL. [ OK ]

Starting MySQL.. [ OK ]

[root@hostname ~]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1.Server version: 5.5.30-log MySQL Community Server (GPL)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 variables like ‘%char%’;

+————————–+—————————-+

| Variable_name | Value |

+————————–+—————————-+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/
|+————————–+—————————-+
8 rows in set (0.00 sec)

mysql> show variables like ‘%collat%’;

+———————-+—————–+
| Variable_name | Value |
+———————-+—————–+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+———————-+—————–+
3 rows in set (0.00 sec)
mysql> exit
Bye

[root@hostname ~]# cat /etc/my.cnf

# Example MySQL config file for medium systems.
#
# This is for a system with little memory (32M – 64M) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together with
# other programs (such as a web server)
#
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the “–help” option.
# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /var/lib/mysql/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
character_set_server = utf8
collation_server = utf8_general_ci
# Don’t listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the “enable-named-pipe” option) will render mysqld useless!
#
#skip-networking
# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin
# binary logging format – mixed recommended
binlog_format=mixed
# required unique id between 1 and 2^32 – 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id = 1
# Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose between
# two methods :
#
# 1) Use the CHANGE MASTER TO command (fully described in our manual) –
# the syntax is:
#
# CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
# MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
#
# where you replace <host>, <user>, <password> by quoted strings and
# <port> by the master’s port number (3306 by default).
#
# Example:
#
# CHANGE MASTER TO MASTER_HOST=’125.564.12.1′, MASTER_PORT=3306,
# MASTER_USER=’joe’, MASTER_PASSWORD=’secret’;
#
# OR
#
# 2) Set the variables below. However, in case you choose this method, then
# start replication for the first time (even unsuccessfully, for example
# if you mistyped the password in master-password and the slave fails to
# connect), the slave will create a master.info file, and any later
# change in this file to the variables’ values below will be ignored and
# overridden by the content of the master.info file, unless you shutdown
# the slave server, delete master.info and restart the slaver server.
# For that reason, you may want to leave the lines below untouched
# (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between 2 and 2^32 – 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id = 2
#
# The replication master for this slave – required
#master-host = <hostname>
#
# The username the slave will use for authentication when connecting
# to the master – required
#master-user = <username>
#
# The password the slave will authenticate with when connecting to
# the master – required
#master-password = <password>
#
# The port the master is listening on.
# optional – defaults to 3306
#master-port = <port>
#
# binary logging – not required for slaves, but recommended
#log-bin=mysql-bin
# Uncomment the following if you are using InnoDB tables
innodb_data_home_dir = /var/lib/mysql
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /var/lib/mysql
# You can set .._buffer_pool_size up to 50 – 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout

[root@hostname ~]# mysql -u root -p

Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2.Server version: 5.5.30-log MySQL Community Server (GPL)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> select version();
+————+
| version() |
+————+
| 5.5.30-log |
+————+
1 row in set (0.01 sec)

mysql> show databases;

+——————–+
| Database |
+——————–+
| information_schema |
| mysql |
| performance_schema |
| test |
+——————–+
4 rows in set (0.00 sec)

mysql> CREATE DATABASE ad_1;

Query OK, 1 row affected (0.00 sec)

mysql> CREATE DATABASE ma_1;

Query OK, 1 row affected (0.00 sec)

mysql> SHOW DATABASES;

+——————–+
| Database |
+——————–+
| information_schema |
| ad_1 |
| ma_1 |
| mysql |
| performance_schema |
| test |
+——————–

10 rows in set (0.00 sec)

mysql> create user ‘cloud’@’localhost’ identified by ‘cloud’;

Query OK, 0 rows affected (0.00 sec)

mysql> create user ‘cloud’@’%’ identified by ‘cloud’;

Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> use mysql;

Database changed

mysql> select user,host,password from user;

+——-+———–+————————————-

| user | host | password |

+——-+———–+————————————-

| root | localhost | *FAAFFE644E901CFAFAEC7562415E5FAEC243B8B2 |

| root | hostname | *FAAFFE644E901CFAFAEC7562415E5FAEC243B8B2 |

| root | 127.0.0.1 | |

| root | ::1 | |

| root | % | *FAAFFE644E901CFAFAEC7562415E5FAEC243B8B2 |

| cloud | localhost | *F42C6D37F7F070D029EDED0C444C833B66147779 |

| cloud | % | *F42C6D37F7F070D029EDED0C444C833B66147779 |

+——-+———–+————————————-

7 rows in set (0.00 sec)

mysql> exit

Bye

*******************************************************************************
End
*******************************************************************************


==================================================================
RHEL 5 – Database Version : 5.6.23
==================================================================


[root@hostname mysql]# ls -ltr
total 618920
-rw-r–r– 1 7155 wheel 23191064 Jan 20 12:49 MySQL-client-5.6.23-1.rhel5.x86_64.rpm
-rw-r–r– 1 7155 wheel 4589592 Jan 20 12:49 MySQL-devel-5.6.23-1.rhel5.x86_64.rpm
-rw-r–r– 1 7155 wheel 117399873 Jan 20 12:50 MySQL-embedded-5.6.23-1.rhel5.x86_64.rpm
-rw-r–r– 1 7155 wheel 88596822 Jan 20 12:51 MySQL-server-5.6.23-1.rhel5.x86_64.rpm
-rw-r–r– 1 7155 wheel 2413703 Jan 20 12:51 MySQL-shared-5.6.23-1.rhel5.x86_64.rpm
-rw-r–r– 1 7155 wheel 5199239 Jan 20 12:51 MySQL-shared-compat-5.6.23-1.rhel5.x86_64.rpm
-rw-r–r– 1 7155 wheel 75149346 Jan 20 12:51 MySQL-test-5.6.23-1.rhel5.x86_64.rpm
-rw-r–r– 1 mysql dba 316549120 May 14 10:25 MySQL-5.6.23-1.rhel5.x86_64.rpm-bundle.tar

[root@hostname mysql]# rpm -ivh MySQL-client-5.6.23-1.rhel5.x86_64.rpm
Preparing… ########################################### [100%]
1:MySQL-client ########################################### [100%]

[root@hostname mysql]# rpm -ivh MySQL-shared-5.6.23-1.rhel5.x86_64.rpm
Preparing… ########################################### [100%]
1:MySQL-shared ########################################### [100%]

[root@hostname mysql]# rpm -ivh MySQL-server-5.6.23-1.rhel5.x86_64.rpm
Preparing… ########################################### [100%]
1:MySQL-server ########################################### [100%]
warning: group mysql does not exist – using root
2015-05-14 10:28:51 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use –explicit_defaults_for_timestamp server option (see docu mentation for more details).
2015-05-14 10:28:51 15863 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-05-14 10:28:51 15863 [Note] InnoDB: The InnoDB memory heap is disabled
2015-05-14 10:28:51 15863 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-05-14 10:28:51 15863 [Note] InnoDB: Memory barrier is not used
2015-05-14 10:28:51 15863 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-05-14 10:28:51 15863 [Note] InnoDB: Using Linux native AIO
2015-05-14 10:28:51 15863 [Note] InnoDB: Not using CPU crc32 instructions
2015-05-14 10:28:51 15863 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-05-14 10:28:51 15863 [Note] InnoDB: Completed initialization of buffer pool
2015-05-14 10:28:51 15863 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2015-05-14 10:28:51 15863 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2015-05-14 10:28:51 15863 [Note] InnoDB: Database physically writes the file full: wait…
2015-05-14 10:28:52 15863 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2015-05-14 10:28:52 15863 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2015-05-14 10:28:53 15863 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2015-05-14 10:28:53 15863 [Warning] InnoDB: New log files created, LSN=45781
2015-05-14 10:28:53 15863 [Note] InnoDB: Doublewrite buffer not found: creating new
2015-05-14 10:28:53 15863 [Note] InnoDB: Doublewrite buffer created
2015-05-14 10:28:53 15863 [Note] InnoDB: 128 rollback segment(s) are active.
2015-05-14 10:28:53 15863 [Warning] InnoDB: Creating foreign key constraint system tables.
2015-05-14 10:28:53 15863 [Note] InnoDB: Foreign key constraint system tables created
2015-05-14 10:28:53 15863 [Note] InnoDB: Creating tablespace and datafile system tables.
2015-05-14 10:28:53 15863 [Note] InnoDB: Tablespace and datafile system tables created.
2015-05-14 10:28:53 15863 [Note] InnoDB: Waiting for purge to start
2015-05-14 10:28:53 15863 [Note] InnoDB: 5.6.23 started; log sequence number 0
A random root password has been set. You will find it in ‘/root/.mysql_secret’.
2015-05-14 10:28:54 15863 [Note] Binlog end
2015-05-14 10:28:54 15863 [Note] InnoDB: FTS optimize thread exiting.
2015-05-14 10:28:54 15863 [Note] InnoDB: Starting shutdown…
2015-05-14 10:28:55 15863 [Note] InnoDB: Shutdown completed; log sequence number 1625977
2015-05-14 10:28:55 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use –explicit_defaults_for_timestamp server option (see documentation for more details).
2015-05-14 10:28:55 15885 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-05-14 10:28:55 15885 [Note] InnoDB: The InnoDB memory heap is disabled
2015-05-14 10:28:55 15885 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-05-14 10:28:55 15885 [Note] InnoDB: Memory barrier is not used
2015-05-14 10:28:55 15885 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-05-14 10:28:55 15885 [Note] InnoDB: Using Linux native AIO
2015-05-14 10:28:55 15885 [Note] InnoDB: Not using CPU crc32 instructions
2015-05-14 10:28:55 15885 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-05-14 10:28:55 15885 [Note] InnoDB: Completed initialization of buffer pool
2015-05-14 10:28:55 15885 [Note] InnoDB: Highest supported file format is Barracuda.
2015-05-14 10:28:55 15885 [Note] InnoDB: 128 rollback segment(s) are active.
2015-05-14 10:28:55 15885 [Note] InnoDB: Waiting for purge to start
2015-05-14 10:28:55 15885 [Note] InnoDB: 5.6.23 started; log sequence number 1625977
2015-05-14 10:28:55 15885 [Note] Binlog end
2015-05-14 10:28:55 15885 [Note] InnoDB: FTS optimize thread exiting.
2015-05-14 10:28:55 15885 [Note] InnoDB: Starting shutdown…
2015-05-14 10:28:57 15885 [Note] InnoDB: Shutdown completed; log sequence number 1625987

A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in ‘/root/.mysql_secret’.

You must change that password on your first connect,
no other statement but ‘SET PASSWORD’ will be accepted.
See the manual for the semantics of the ‘password expired’ flag.
Also, the account for the anonymous user has been removed.
In addition, you can run:

/usr/bin/mysql_secure_installation

which will also give you the option of removing the test database.
This is strongly recommended for production servers.

See the manual for more instructions.
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
New default config file was created as /usr/my.cnf and will be used by default by the server when you start it.You may edit this file to change server settings
[root@hostname mysql]# service mysql status
MySQL is not running [FAILED]

[root@hostname mysql]# service mysql start
Starting MySQL.. [ OK ]

[root@hostname mysql]# service mysql status
MySQL running (16050) [ OK ]

[root@hostname ~]# cat /root/.mysql_secret
# The random password set for the root user at Thu May 14 10:28:53 2015 (local time): 7q7yzjWQis14U3w1

[root@hostname ~]# mysql -u root -p
Enter password:7q7yzjWQis14U3w1
Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1.Server version: 5.6.23.Copyright (c) 2000, 2015, 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> SET PASSWORD=PASSWORD(‘root’);
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

[root@hostname ~]# mysql -u root -p
Enter password: (with New password)
Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 4.Server version: 5.6.23 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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 |
| performance_schema |
| test |
+——————–+
4 rows in set (0.00 sec)

mysql>

[root@hostname ~]# mysql -u root -p -A
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 5.Server version: 5.6.23 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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 |
| performance_schema |
| test |
+——————–+
4 rows in set (0.00 sec)

mysql> use mysql;
Database changed

mysql> select user,host,password from user;
+——+—————-+———————————
| user | host | password |
+——+—————-+———————————
| root | localhost | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| root | hostname | *89D0263569FAAF25CE956F8A4E4CA0FDEBC622A9 |
| root | 127.0.0.1 | *89D0263569FAAF25CE956F8A4E4CA0FDEBC622A9 |
| root | ::1 | *89D0263569FAAF25CE956F8A4E4CA0FDEBC622A9 |
+——+—————-+———————————
4 rows in set (0.00 sec)

mysql> create user ‘root’@’%’ identified by ‘root’;
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT all on *.* to ‘root’@’%’ with grant option;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> use mysql;
Database changed
mysql> select user,host,password from user;
+——+—————-+———————————
| user | host | password |
+——+—————-+———————————
| root | localhost | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| root | hostname | *89D0263569FAAF25CE956F8A4E4CA0FDEBC622A9 |
| root | 127.0.0.1 | *89D0263569FAAF25CE956F8A4E4CA0FDEBC622A9 |
| root | ::1 | *89D0263569FAAF25CE956F8A4E4CA0FDEBC622A9 |
| root | % | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+——+—————-+———————————
5 rows in set (0.00 sec)

mysql>

[root@hostname ~]# cd /usr/share/mysql/

[root@hostname mysql]# cp my-default.cnf /etc/my.cnf

[root@hostname ~]# vi /etc/my.cnf
[root@hostname ~]# service mysql restart
Shutting down MySQL.. [ OK ]
Starting MySQL.. [ OK ]
[root@hostname ~]# cat /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It’s a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
basedir = /usr
datadir = /var/lib/mysql
port = 3306
server_id = 1
socket = /var/lib/mysql/mysql.sock

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[root@hostname ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2.Server version: 5.6.23 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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 |
| performance_schema |
| test |
+——————–+
4 rows in set (0.00 sec)

mysql> show variables like ‘%char%’;
+————————–+—————————-+
| Variable_name | Value |
+————————–+—————————-+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+————————–+—————————-+
8 rows in set (0.00 sec)

mysql> show variables like ‘%collat%’;
+———————-+——————-+
| Variable_name | Value |
+———————-+——————-+
| collation_connection | utf8_general_ci |
| collation_database | latin1_swedish_ci |
| collation_server | latin1_swedish_ci |
+———————-+——————-+
3 rows in set (0.00 sec)

mysql>

[root@hostname ~]# vi /etc/my.cnf


[root@hostname ~]# service mysql restart
Shutting down MySQL.. [ OK ]
Starting MySQL.. [ OK ]

[root@hostname ~]# cat /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It’s a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
basedir = /usr
datadir = /var/lib/mysql
port = 3306
server_id = 1
socket = /var/lib/mysql/mysql.sock
character_set_server = utf8
collation_server = utf8_general_ci

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[root@hostname ~]#
[root@hostname ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1.Server version: 5.6.23 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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 variables like ‘%collat%’;
+———————-+—————–+
| Variable_name | Value |
+———————-+—————–+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+———————-+—————–+
3 rows in set (0.00 sec)

mysql> show variables like ‘%char%’;
+————————–+—————————-+
| Variable_name | Value |
+————————–+—————————-+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+————————–+—————————-+
8 rows in set (0.00 sec)

mysql>

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

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

mysql> use mysql;
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> select user,host,password from user;
+——+—————-+———————————
| user | host | password |
+——+—————-+———————————
| root | localhost | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| root | hostname | *89D0263569FAAF25CE956F8A4E4CA0FDEBC622A9 |
| root | 127.0.0.1 | *89D0263569FAAF25CE956F8A4E4CA0FDEBC622A9 |
| root | ::1 | *89D0263569FAAF25CE956F8A4E4CA0FDEBC622A9 |
| root | % | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+——+—————-+———————————
5 rows in set (0.00 sec)

mysql> create user ‘qamercury’@’localhost’ identified by ‘qamercury’;
Query OK, 0 rows affected (0.00 sec)

mysql> create user ‘qamercury’@’%’ identified by ‘qamercury’;
Query OK, 0 rows affected (0.00 sec)


********************************************************************************
End
********************************************************************************

========================================================================
RHEL 5 – DB Version – 5.7.10
========================================================================

[root@hostname mysql]# rpm -ivh mysql-5.7.10-1.el5.x86_64.rpm mysql-community-client-5.7.10-1.el5.x86_64.rpm mysql-community-common-5.7.10-1.el5.x86_64.rpm mysql-community-devel-5.7.10-1.el5.x86_64.rpm mysql-community-embedded-5.7.10-1.el5.x86_64.rpm mysql-community-embedded-devel-5.7.10-1.el5.x86_64.rpm mysql-community-libs-5.7.10-1.el5.x86_64.rpm mysql-community-libs-compat-5.7.10-1.el5.x86_64.rpm mysql-community-server-5.7.10-1.el5.x86_64.rpm mysql-community-test-5.7.10-1.el5.x86_64.rpm
warning: mysql-5.7.10-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 5072e1f5
Preparing… ########################################### [100%]
1:mysql-community-libs ########################################### [ 10%]
2:mysql-community-common ########################################### [ 20%]
3:mysql-community-client ########################################### [ 30%]
4:mysql-community-server ########################################### [ 40%]
5:mysql-community-embedde########################################### [ 50%]
6:mysql-community-libs-co########################################### [ 60%]
7:mysql ########################################### [ 70%]
8:mysql-community-devel ########################################### [ 80%]
9:mysql-community-embedde########################################### [ 90%]
10:mysql-community-test ########################################### [100%]
[root@hostname mysql]#

[root@hostname mysql]# pwd
/var/lib/mysql

[root@hostname mysql]# ls -ltr
total 0

[root@hostname lib]# pwd
/var/lib
[root@hostname lib]# ls -ltr
drwxr-x–x 2 mysql mysql 4096 Nov 30 01:46 mysql
After installating rpm’s do the below step :

[mysql@hostname ~]$ /usr/sbin/mysqld –initialize –datadir=/var/lib/mysql

[root@hostname lib]# cd mysql

[root@hostname mysql]# ls -ltr
total 123048
-rwxr-xr-x 1 mysql mysql 50331648 Jan 13 11:51 ib_logfile1
-rwxr-xr-x 1 mysql mysql 56 Jan 13 11:51 auto.cnf
drwxr-xr-x 2 mysql mysql 4096 Jan 13 11:51 performance_schema
drwxr-xr-x 2 mysql mysql 4096 Jan 13 11:51 mysql
drwxr-xr-x 2 mysql mysql 12288 Jan 13 11:51 sys
-rwxr-xr-x 1 mysql mysql 408 Jan 13 11:51 ib_buffer_pool
-rw-r—– 1 mysql mysql 12582912 Jan 19 10:19 ibtmp1
-rwxr-xr-x 1 mysql mysql 12582912 Jan 19 10:19 ibdata1
-rwxr-xr-x 1 mysql mysql 50331648 Jan 19 10:19 ib_logfile0
-rw——- 1 mysql mysql 5 Jan 19 10:19 mysql.sock.lock
srwxrwxrwx 1 mysql mysql 0 Jan 19 10:19 mysql.sock

[root@hostname mysql]# service mysqld status
mysqld (pid 6988) is running…

[root@hostname mysql]# pwd
/var/lib/mysql

[root@hostname ~]# service mysqld status
mysqld (pid 6988) is running…

And run below comand :

[root@hostname ~]# /etc/init.d/mysqld start –skip-grant-tables

[root@hostname ~]# ps -ef | grep -i mysql
root 17627 1 0 13:49 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe –datadir=/var/lib/mysql –socket=/var/lib/mysql/mysql.sock –pid-file=/var/run/mysqld/mysqld.pid –basedir=/usr –user=mysql –skip-grant-tables
mysql 17850 17627 0 13:49 ? 00:00:00 /usr/sbin/mysqld –basedir=/usr –datadir=/var/lib/mysql –plugin-dir=/usr/lib64/mysql/plugin –user=mysql –skip-grant-tables –log-error=/var/log/mysqld.log –pid-file=/var/run/mysqld/mysqld.pid –socket=/var/lib/mysql/mysql.sock
root 19003 18943 0 14:12 pts/0 00:00:00 grep -i mysql

[root@hostname ~]# mysql -A
Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 10.Server version: 5.7.10 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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 |
| performance_schema |
| sys |
+——————–+
4 rows in set (0.00 sec)

mysql> use mysql;
Database changed
mysql> select user,host,authentication_string from user;
+———–+———–+———————————
| user | host | authentication_string |
+———–+———–+——————————————-+
| root | localhost | *361E98A027EF0CB2D55FFCBB00AEB9DF89BD4588 |
| mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
+———–+———–+———————————
2 rows in set (0.00 sec)

mysql> UPDATE user SET authentication_string = PASSWORD(‘root’),password_expired = ‘N’ WHERE user=’root’ and host=’localhost’;
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> select user,host,authentication_string from user;
+———–+———–+———————————
| user | host | authentication_string |
+———–+———–+———————————
| root | localhost | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
+———–+———–+———————————
2 rows in set (0.00 sec)
[root@hostname ~]# /etc/init.d/mysqld stop
Stopping mysqld: [ OK ]

[root@hostname ~]# /etc/init.d/mysqld status
mysqld is stopped

[root@hostname ~]# service mysqld start
Starting mysqld: [ OK ]

[root@hostname ~]# service mysqld status
mysqld (pid 19493) is running…

[root@hostname ~]# ps -ef | grep -i mysql
root 19285 1 0 14:17 pts/0 00:00:00 /bin/sh /usr/bin/mysqld_safe –datadir=/var/lib/mysql –socket=/var/lib/mysql/mysql.sock –pid-file=/var/run/mysqld/mysqld.pid –basedir=/usr –user=mysql
mysql 19493 19285 4 14:17 pts/0 00:00:00 /usr/sbin/mysqld –basedir=/usr –datadir=/var/lib/mysql –plugin-dir=/usr/lib64/mysql/plugin –user=mysql –log-error=/var/log/mysqld.log –pid-file=/var/run/mysqld/mysqld.pid –socket=/var/lib/mysql/mysql.sock
root 19551 18943 0 14:18 pts/0 00:00:00 grep -i mysql

[root@hostname ~]# mysql -u root -p
Enter password:(new password)
Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 3.Server version: 5.7.10 MySQL Community Server (GPL) Copyright (c) 2000, 2015, 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 |
| performance_schema |
| sys |
+——————–+
4 rows in set (0.00 sec)

mysql> use mysql;
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> select user,host,authentication_string from user;
+———–+———–+———————————
| user | host | authentication_string |
+———–+———–+———————————
| root | localhost | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
+———–+———–+———————————
2 rows in set (0.00 sec)

mysql> grant all on *.* to ‘root’@’localhost’ with grant option;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
[root@hostname ~]# cp /usr/share/mysql/my-default.cnf /etc/my.cnf

[root@hostname ~]# vi /etc/my.cnf

[root@hostname ~]# service mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]

[root@hostname ~]# service mysqld status
mysqld (pid 20315) is running…

[root@hostname ~]# cat /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It’s a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
log_bin

# These are commonly set, remove the # and set as required.
basedir = /usr
datadir = /var/lib/mysql
port = 3306
server_id = 1
socket = /var/lib/mysql/mysql.sock

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
join_buffer_size = 128M
sort_buffer_size = 2M
read_rnd_buffer_size = 2M

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[root@hostname ~]# cd /var/lib/
[root@hostname lib]# ls -ltr
drwxr-x–x 5 mysql mysql 4096 Jan 19 14:26 mysql

[root@hostname lib]# cd mysql

[root@hostname mysql]# ls -ltr
total 123064
-rw-r—– 1 mysql mysql 50331648 Jan 19 13:08 ib_logfile1
-rw-r—– 1 mysql mysql 56 Jan 19 13:08 auto.cnf
drwxr-x— 2 mysql mysql 4096 Jan 19 13:08 performance_schema
drwxr-x— 2 mysql mysql 4096 Jan 19 13:08 mysql
drwxr-x— 2 mysql mysql 12288 Jan 19 13:08 sys
-rw-r—– 1 mysql mysql 320 Jan 19 14:26 ib_buffer_pool
-rw——- 1 mysql mysql 6 Jan 19 14:26 mysql.sock.lock
srwxrwxrwx 1 mysql mysql 0 Jan 19 14:26 mysql.sock
-rw-rw—- 1 root root 6 Jan 19 14:26 mysqld_safe.pid
-rw-r—– 1 mysql root 3769 Jan 19 14:26 hostname.err
-rw-r—– 1 mysql mysql 25 Jan 19 14:26 hostname-bin.index
-rw-r—– 1 mysql mysql 154 Jan 19 14:26 hostname-bin.000001
-rw-r—– 1 mysql mysql 12582912 Jan 19 14:26 ibtmp1
-rw-r—– 1 mysql mysql 50331648 Jan 19 14:26 ib_logfile0
-rw-r—– 1 mysql mysql 12582912 Jan 19 14:26 ibdata1


*********************************************************************************
End
*********************************************************************************

Comments

Popular posts from this blog

PostgreSQL Database Version 13.4 To MySQL Database Version 8.0.20 Migration by using SQLines Tool

RDS MySQL / MariaDB SSL Connection by using Workbench and command line

Install Mydumper and Myloader Software for Backup of MySQL / MariaDB Databases and Usage of commands