0% found this document useful (0 votes)
30 views4 pages

Practice 02

The document provides a step-by-step guide for installing, connecting to, configuring, upgrading, and deploying MySQL, including commands for Linux terminal and Docker. It covers tasks such as initializing the MySQL database, setting user passwords, managing the MySQL service, and performing upgrades. Each practice section is clearly outlined with specific commands to execute for successful MySQL management.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views4 pages

Practice 02

The document provides a step-by-step guide for installing, connecting to, configuring, upgrading, and deploying MySQL, including commands for Linux terminal and Docker. It covers tasks such as initializing the MySQL database, setting user passwords, managing the MySQL service, and performing upgrades. Each practice section is clearly outlined with specific commands to execute for successful MySQL management.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

##=================================##

## Practice 2-1: Installing MySQL ##


##=================================##

#- Step 1
cd /opt
tar xf /stage/MySQL-Server/mysql-advanced-5.7*.tar.gz

#- Step 2
ln -s /opt/mysql* /usr/local/mysql

#- Step 3
ls /usr/local/mysql/bin

#- Step 4 : add to ~/.bashrc


export PATH=$PATH:/usr/local/mysql/bin

#- Step 5
source ~/.bashrc

#- Step 6
cp /labs/my.cnf /etc/my.cnf

#- Step 7
cat /etc/my.cnf

#- Step 8
adduser -r mysql

#- Step 9
mysqld --initialize

#- Step 10
mkdir /var/run/mysqld
chown mysql:mysql /var/run/mysqld/

#- Step 11
mysqld_safe &

##====================================##
## Practice 2-2: Connecting to MySQL ##
##====================================##

#- Step 1 : Use a text editor to add the following to /etc/my.cnf


[client]
socket=/var/lib/mysql/mysql.sock

#- Step 2 : Enter the temporary password on the Enter password prompt


mysql -uroot -p

#- Step 3 : At the mysql prompt


USE mysql

#- Step 4
ALTER USER USER() IDENTIFIED BY 'oracle';

#- Step 5
EXIT
#- Step 6
mysql -uroot -p

#- Step 7 : At the mysql prompt


USE mysql

#- Step 8
EXIT

##==============================================##
## Practice 2-3: Configuring the MySQL Service ##
##==============================================##

#- Step 1
mysqladmin -uroot -p shutdown

#- Step 2
cat /labs/service-5.7/mysqld.service

#- Step 3
cp /labs/service-5.7/mysqld.service /usr/lib/systemd/system

#- Step 4
systemctl enable mysqld.service

#- Step 5
systemctl start mysqld

#- Step 6
systemctl status mysqld

##===============================##
## Practice 2-4: Upgrading MySQL ##
##===============================##

#- Step 1 : In a Linux terminal


cd /stage/MySQL-Shell
rpm -i mysql-shell-commercial-8*.rpm

#- Step 2
mysqlsh root@localhost -- util checkForServerUpgrade

#- Step 3
systemctl stop mysqld

#- Step 4
systemctl status mysqld

#- Step 5
cd /opt
tar xf /stage/MySQL-Server/mysql-commercial-8*.tar.gz

#- Step 6
ls /opt

#- Step 7
rm /usr/local/mysql
y
#- Step 8
ln -s /opt/mysql-commercial-8* /usr/local/mysql

#- Step 9
cp /labs/service-8.0/mysqld.service /usr/lib/systemd/system
y

#- Step 10
systemctl daemon-reload

#- Step 11
systemctl start mysqld

#- Step 12
systemctl status mysqld

#- Step 13
mysql_upgrade -uroot -p

#- Step 14
systemctl status mysqld -l

#- Step 15
mysqld --version

##============================================##
## Practice 2-5: Deploying MySQL with Docker ##
##============================================##

#- Step 1 : In a Linux terminal


cd /stage/MySQL-Server/
docker load -i mysql-enterprise-server-8.0.18.tar
docker images

#- Step 2
docker run --name=mysql1 -d mysql/enterprise-server:8.0
docker ps

#- Step 3
docker logs mysql1 2>&1 | grep GENERATED

#- Step 4 : Enter the temporary password on the Enter password prompt


docker exec -it mysql1 mysql -uroot -p

#- Step 5 : At the mysql prompt


ALTER USER USER() IDENTIFIED BY 'MySQL8.0';
EXIT

#- Step 6 : At the Linux terminal prompt


docker exec -it mysql1 mysql -uroot -p
MySQL8.0
EXIT

#- Step 7
docker stop mysql1
docker ps -a
#- Step 8
docker start mysql1

#- Step 9
docker stop mysql1

#- Step 10
exit

You might also like