Skip to content

Commit 014fac9

Browse files
authored
Merge pull request #77571 from cynthn/mysql-prompt
Removing prompt from code blocks
2 parents def8128 + f1f8e7f commit 014fac9

File tree

1 file changed

+159
-103
lines changed

1 file changed

+159
-103
lines changed

articles/virtual-machines/linux/mysql-install.md

Lines changed: 159 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ ms.author: cynthn
2121
# How to install MySQL on Azure
2222
In this article, you will learn how to install and configure MySQL on an Azure virtual machine running Linux.
2323

24-
[!INCLUDE [learn-about-deployment-models](../../../includes/learn-about-deployment-models-both-include.md)]
2524

26-
## Install MySQL on your virtual machine
2725
> [!NOTE]
2826
> You must already have a Microsoft Azure virtual machine running Linux in order to complete this tutorial. Please see the
2927
> [Azure Linux VM tutorial](quick-create-cli.md?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json) to create and set up a Linux VM with `mysqlnode` as the VM name and `azureuser` as user before proceeding.
@@ -32,150 +30,208 @@ In this article, you will learn how to install and configure MySQL on an Azure v
3230
3331
In this case, use 3306 port as the MySQL port.
3432

35-
Connect to the Linux VM you created via putty. If this is the first time you use Azure Linux VM, see how to use putty connect to a Linux VM [here](mac-create-ssh-keys.md?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json).
36-
3733
We will use repository package to install MySQL5.6 as an example in this article. Actually, MySQL5.6 has more improvement in performance than MySQL5.5. More information [here](http://www.mysqlperformanceblog.com/2013/02/18/is-mysql-5-6-slower-than-mysql-5-5/).
3834

39-
### How to install MySQL5.6 on Ubuntu
40-
We will use Linux VM with Ubuntu from Azure here.
35+
## Install MySQL5.6 on Ubuntu
36+
We will use a Linux VM running Ubuntu.
4137

42-
* Step 1: Install MySQL Server 5.6
43-
Switch to `root` user:
44-
45-
#[azureuser@mysqlnode:~]sudo su -
46-
47-
Install mysql-server 5.6:
48-
49-
#[root@mysqlnode ~]# apt-get update
50-
#[root@mysqlnode ~]# apt-get -y install mysql-server-5.6
51-
52-
During installation, you will see a dialog window appear to ask you to set MySQL root password below, and you need set the password here.
53-
54-
![image](./media/mysql-install/virtual-machines-linux-install-mysql-p1.png)
5538

56-
Input the password again to confirm.
39+
### Install MySQL
5740

58-
![image](./media/mysql-install/virtual-machines-linux-install-mysql-p2.png)
41+
Install MySQL Server 5.6 by switching to the `root` user:
42+
43+
```bash
44+
sudo su -
45+
```
46+
47+
Install mysql-server 5.6:
48+
49+
```bash
50+
apt-get update
51+
apt-get -y install mysql-server-5.6
52+
```
5953

60-
* Step 2: Login MySQL Server
61-
62-
When MySQL server installation finished, MySQL service will be started automatically. You can login MySQL Server with `root` user.
63-
Use the below command to login and input password.
64-
65-
#[root@mysqlnode ~]# mysql -uroot -p
66-
* Step 3: Manage the running MySQL service
67-
68-
(a) Get status of MySQL service
69-
70-
#[root@mysqlnode ~]# service mysql status
7154

72-
(b) Start MySQL Service
55+
During installation, you will see a dialog window appear to ask you to set MySQL root password below, and you need set the password here.
7356

74-
#[root@mysqlnode ~]# service mysql start
57+
![image](./media/mysql-install/virtual-machines-linux-install-mysql-p1.png)
58+
59+
Input the password again to confirm.
60+
61+
![image](./media/mysql-install/virtual-machines-linux-install-mysql-p2.png)
62+
63+
### Sign in
7564

76-
(c) Stop MySQL service
65+
When MySQL server installation finished, MySQL service will be started automatically. You can sign in to MySQL Server with the `root` user, and enter your password.
66+
67+
```bash
68+
mysql -uroot -p
69+
```
70+
71+
72+
### Manage the MySQL service
73+
74+
Get status of MySQL service
75+
76+
```bash
77+
service mysql status
78+
```
7779

78-
#[root@mysqlnode ~]# service mysql stop
80+
Start MySQL Service
81+
82+
```bash
83+
service mysql start
84+
```
7985

80-
(d) Restart the MySQL service
86+
Stop MySQL service
87+
88+
```bash
89+
service mysql stop
90+
```
8191

82-
#[root@mysqlnode ~]# service mysql restart
92+
Restart the MySQL service
8393

84-
### How to install MySQL on Red Hat OS family like CentOS, Oracle Linux
94+
```bash
95+
service mysql restart
96+
```
97+
98+
## Install MySQL on Red Hat OS, CentOS, Oracle Linux
8599
We will use Linux VM with CentOS or Oracle Linux here.
86100

87-
* Step 1: Add the MySQL Yum repository
88-
Switch to `root` user:
89-
90-
#[azureuser@mysqlnode:~]sudo su -
91-
92-
Download and install the MySQL release package:
93-
94-
#[root@mysqlnode ~]# wget https://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
95-
#[root@mysqlnode ~]# yum localinstall -y mysql-community-release-el6-5.noarch.rpm
96-
* Step 2: Edit below file to enable the MySQL repository for downloading the MySQL5.6 package.
97-
98-
#[root@mysqlnode ~]# vim /etc/yum.repos.d/mysql-community.repo
99-
100-
Update each value of this file to below:
101-
102-
\# *Enable to use MySQL 5.6*
103-
104-
[mysql56-community]
105-
name=MySQL 5.6 Community Server
106-
107-
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/
101+
### Add the MySQL yum repository
102+
103+
Switch to `root` user:
104+
105+
```bash
106+
sudo su -
107+
```
108+
109+
Download and install the MySQL release package:
110+
111+
```bash
112+
wget https://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
113+
yum localinstall -y mysql-community-release-el6-5.noarch.rpm
114+
```
115+
116+
### Enable the MySQL repository
117+
Edit below file to enable the MySQL repository for downloading the MySQL5.6 package.
118+
119+
```bash
120+
vim /etc/yum.repos.d/mysql-community.repo
121+
```
122+
108123

109-
enabled=1
124+
Update each value of this file to below:
125+
126+
```
127+
\# *Enable to use MySQL 5.6*
110128
111-
gpgcheck=1
129+
[mysql56-community]
130+
name=MySQL 5.6 Community Server
112131
113-
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
114-
* Step 3: Install MySQL from MySQL repository
115-
Install MySQL:
132+
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/
116133
117-
#[root@mysqlnode ~]#yum install mysql-community-server
134+
enabled=1
118135
119-
MySQL RPM package and all related packages will be installed.
120-
* Step 4: Manage the running MySQL service
136+
gpgcheck=1
121137
122-
(a) Check the service status of the MySQL server:
138+
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
139+
```
140+
141+
### Install MySQL
142+
143+
Install MySQL from the repository.
144+
145+
```bash
146+
yum install mysql-community-server
147+
```
123148

124-
#[root@mysqlnode ~]#service mysqld status
149+
The MySQL RPM package and all related packages will be installed.
150+
151+
152+
## Manage the MySQL service
125153

126-
(b) Check whether the default port of MySQL server is running:
154+
Check the service status of the MySQL server:
155+
156+
```bash
157+
service mysqld status\
158+
```
127159

128-
#[root@mysqlnode ~]#netstat –tunlp|grep 3306
160+
Check whether the default port of MySQL server is running:
161+
162+
```bash
163+
netstat –tunlp|grep 3306
164+
```
129165

130-
(c) Start the MySQL server:
166+
Start the MySQL server:
131167

132-
#[root@mysqlnode ~]#service mysqld start
168+
```bash
169+
service mysqld start
170+
```
133171

134-
(d) Stop the MySQL server:
172+
Stop the MySQL server:
135173

136-
#[root@mysqlnode ~]#service mysqld stop
174+
```bash
175+
service mysqld stop
176+
```
137177

138-
(e) Set MySQL to start when the system boot-up:
178+
Set MySQL to start when the system boot-up:
139179

140-
#[root@mysqlnode ~]#chkconfig mysqld on
180+
```bash
181+
chkconfig mysqld on
182+
```
141183

184+
## Install MySQL on SUSE Linux
142185

143-
### How to install MySQL on SUSE Linux
144186
We will use Linux VM with OpenSUSE here.
145187

146-
* Step 1: Download and install MySQL Server
147-
148-
Switch to `root` user through below command:
149-
150-
#sudo su -
151-
152-
Download and install MySQL package:
188+
### Download and install MySQL Server
153189

154-
#[root@mysqlnode ~]# zypper update
155-
156-
#[root@mysqlnode ~]# zypper install mysql-server mysql-devel mysql
157-
* Step 2: Manage the running MySQL service
158-
159-
(a) Check the status of the MySQL server:
190+
Switch to `root` user through below command:
191+
192+
```bash
193+
sudo su -
194+
```
160195

161-
#[root@mysqlnode ~]# rcmysql status
196+
Download and install MySQL package:
197+
198+
```bash
199+
zypper update
200+
zypper install mysql-server mysql-devel mysql
201+
```
202+
203+
### Manage the MySQL service
162204

163-
(b) Check whether the default port of the MySQL server:
205+
Check the status of the MySQL server:
206+
207+
```bash
208+
rcmysql status
209+
```
164210

165-
#[root@mysqlnode ~]# netstat –tunlp|grep 3306
211+
Check whether the default port of the MySQL server:
212+
213+
```bash
214+
netstat –tunlp|grep 3306
215+
```
166216

167-
(c) Start the MySQL server:
217+
Start the MySQL server:
168218

169-
#[root@mysqlnode ~]# rcmysql start
219+
```bash
220+
rcmysql start
221+
```
170222

171-
(d) Stop the MySQL server:
223+
Stop the MySQL server:
172224

173-
#[root@mysqlnode ~]# rcmysql stop
225+
```bash
226+
rcmysql stop
227+
```
174228

175-
(e) Set MySQL to start when the system boot-up:
229+
Set MySQL to start when the system boot-up:
176230

177-
#[root@mysqlnode ~]# insserv mysql
231+
```bash
232+
insserv mysql
233+
```
178234

179-
### Next Step
180-
Find more usage and information regarding MySQL [Here](https://www.mysql.com/).
235+
## Next step
236+
For more information, see the [MySQL](https://www.mysql.com/) website.
181237

0 commit comments

Comments
 (0)