Skip to content

Commit d4f6ba5

Browse files
authored
Update how-to-use-mysql-on-hypernode.md
1 parent aaca8c7 commit d4f6ba5

File tree

1 file changed

+27
-39
lines changed

1 file changed

+27
-39
lines changed

docs/hypernode-platform/mysql/how-to-use-mysql-on-hypernode.md

Lines changed: 27 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ Your MySQL credentials are stored in the homedir of application user.
2121

2222
You find them in the file `.my.cnf` located in `/data/web`.
2323

24-
```nginx
24+
```bash
2525
cat ~/.my.cnf
2626
```
2727

28-
```nginx
28+
```ini
2929
[client]
3030
user = app
3131
password = JlogA1Sws6XMHmAj7QlP9vpfjlprtpE5
@@ -49,23 +49,23 @@ Port 3306 is fire-walled on all Hypernodes to prevent hackers and bruteforces fr
4949

5050
First check which IP addresses have been whitelisted already, if any.
5151

52-
```bash
52+
```console
5353
hypernode-systemctl whitelist get
5454
```
5555

5656
### Adding to Whitelist
5757

5858
To add more values to your whitelists you can run the following. Please note that descriptions are optional:
5959

60-
```bash
60+
```console
6161
hypernode-systemctl whitelist add database 1.2.3.4 --description "my description"
6262
```
6363

6464
### Removing From Whitelist
6565

6666
To remove values from your whitelists you can run the following:
6767

68-
```bash
68+
```console
6969
hypernode-systemctl whitelist remove database 1.2.3.4
7070
```
7171

@@ -86,15 +86,15 @@ Because we’ve provided a `~/.my.cnf`, you’re all set to go.
8686

8787
Just type `mysql` and you’re in.
8888

89-
```nginx
89+
```console
9090
mysql
9191
```
9292

9393
### Use the Command Line Shell From a Remote Host
9494

9595
Use your credentials to connect like so:
9696

97-
```nginx
97+
```console
9898
mysql --host=mysqlmaster.example.hypernode.io --user=app --password=mypassword
9999
```
100100

@@ -111,7 +111,7 @@ If you are blocked by a firewall, you can tunnel the remote MySQL service to you
111111

112112
Use this command:
113113

114-
```nginx
114+
```console
115115
ssh -NL 3306:mysqlmaster:3306 app@example.hypernode.io
116116
```
117117

@@ -123,7 +123,7 @@ Voila, now your Hypernode database is reachable through localhost port 3306!
123123

124124
Use the following command using SSH:
125125

126-
```nginx
126+
```console
127127
magerun db:dump -n -c gz -s @stripped
128128
```
129129

@@ -156,16 +156,16 @@ Hypernode offers several version of MySQL to be able to meet te requirements of
156156

157157
To upgrade your MySQL version you can use[the hypernode-systemctl tool](../tools/how-to-use-the-hypernode-systemctl-cli-tool.md#mysql) through the command line.
158158

159-
```nginx
159+
```console
160160
hypernode-systemctl settings mysql_version --value 5.7
161161
```
162162

163163
### How to Create a New Database
164164

165165
To create a new database, we’ll login using the MySQL client and drop the database using the command line.
166166

167-
```nginx
168-
>DATABASE="new_database"
167+
```bash
168+
DATABASE="new_database"
169169
mysql -e "CREATE DATABASE IF NOT EXISTS $DATABASE"
170170
```
171171

@@ -184,7 +184,7 @@ To prevent incorrect deletion of database that are still in use, ensure yourself
184184

185185
When you are 100% sure it is safe to delete the database, issue the following command:
186186

187-
```nginx
187+
```bash
188188
DATABASE="old_database"
189189
mysql -e "DROP DATABASE $DATABASE"
190190
```
@@ -198,7 +198,7 @@ If you truncate a database table, all records are removed but the table structur
198198

199199
After you ensured yourself it is safe to delete all records of the table, use the following command:
200200

201-
```nginx
201+
```bash
202202
DATABASE="magento"
203203
TABLE="core_url_rewrite"
204204
mysql "$DATABASE" -e "TRUNCATE TABLE $TABLE"
@@ -208,37 +208,31 @@ mysql "$DATABASE" -e "TRUNCATE TABLE $TABLE"
208208

209209
Login to your MySQL server via the following command:
210210

211-
```nginx
211+
```console
212212
mysql
213213
```
214214

215-
This will get you into the MySQL prompt. Select the database which holds user accounts, here it’s called mysql;
215+
This will get you into the MySQL prompt. Now change the password for a given user account using this command:
216216

217-
```nginx
218-
use mysql;
219-
```
220-
221-
Now change the password for a given user account using this command:
222-
223-
```nginx
217+
```mysql
224218
update user set password=PASSWORD('newpassword') where user='username';
225219
```
226220

227221
Let’s assume here that your username is ‘trial’ and your new password is ‘hypernode’. Your actual command would look like this:
228222

229-
```nginx
223+
```mysql
230224
update user set password=PASSWORD('hypernode') where user='trial';
231225
```
232226

233227
Now your password is changed in the database, but they haven’t filtered into memory yet. Change that by typing:
234228

235-
```nginx
229+
```mysql
236230
flush privileges;
237231
```
238232

239233
Your password has been updated. There’s no need to restart the MySQL demon. Exit the MySQL with
240234

241-
```nginx
235+
```mysql
242236
exit;
243237
```
244238

@@ -250,7 +244,7 @@ exit;
250244

251245
You can upgrade the MySQL version on your Hypernode from 5.6 to 5.7 with the following command:
252246

253-
```nginx
247+
```bash
254248
hypernode-systemctl settings mysql_version 5.7
255249
```
256250

@@ -260,31 +254,25 @@ You can then check with `livelog` when the process has finished and your MySQL v
260254

261255
Login to your MySQL server via the following command
262256

263-
```nginx
257+
```console
264258
mysql
265259
```
266260

267-
This will get you into the MySQL prompt. Select the database which holds user accounts, here it’s called mysql;
268-
269-
```nginx
270-
use mysql;
271-
```
272-
273-
Now change the password for a given user account using this command, in this case the `app` user:
261+
This will get you into the MySQL prompt. Now change the password for a given user account using this command, in this case the `app` user:
274262

275-
```nginx
263+
```mysql
276264
update user set authentication_string=password('newpassword') where user='app';
277265
```
278266

279267
Now your password is changed in the database, but they haven’t filtered into memory yet. Change that by typing:
280268

281-
```nginx
269+
```mysql
282270
flush privileges;
283271
```
284272

285273
Your password has been updated. There’s no need to restart the MySQL demon. Exit the MySQL with
286274

287-
```nginx
275+
```mysql
288276
exit;
289277
```
290278

@@ -296,7 +284,7 @@ Remember to update your `~/.my.cnf` with your new password so you could easily l
296284

297285
Before you can upgrade to MySQL 8.0 you first need to upgrade the MySQL version to 5.7 and wait for this process to finish. Once You can upgrade the MySQL version on your Hypernode from 5.7 to 8.0 with the following command:
298286

299-
```nginx
287+
```console
300288
hypernode-systemctl settings mysql_version 8.0
301289
```
302290

0 commit comments

Comments
 (0)