More documentation. A blog article!
This commit is contained in:
parent
7868873744
commit
8bd574b39c
|
@ -0,0 +1,74 @@
|
|||
# Set/Reset MySQL Root Password on MySQL 14.14
|
||||
|
||||
I was trying to setup MySQL that I installed using `sudo apt install MySql` and couldn't remember how to set the root password. I found many different instructions on how to stop MySQL, boot into safe mode and reset the root password.
|
||||
|
||||
*None of them worked.*
|
||||
|
||||
This did:
|
||||
|
||||
Run: `sudo mysql_secure_installation`
|
||||
|
||||
You will see something like this:
|
||||
|
||||
```
|
||||
Securing the MySQL server deployment.
|
||||
|
||||
Enter password for user root:
|
||||
```
|
||||
|
||||
You can setup a password strength validation plugin if you wish in the next step:
|
||||
|
||||
```
|
||||
VALIDATE PASSWORD PLUGIN can be used to test passwords
|
||||
and improve security. It checks the strength of password
|
||||
and allows the users to set only those passwords which are
|
||||
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
|
||||
|
||||
Press y|Y for Yes, any other key for No:
|
||||
```
|
||||
|
||||
Next, it will give you an option to disable anonymous users. Do it. It is a security liability if you don't.
|
||||
|
||||
```
|
||||
By default, a MySQL installation has an anonymous user,
|
||||
allowing anyone to log into MySQL without having to have
|
||||
a user account created for them. This is intended only for
|
||||
testing, and to make the installation go a bit smoother.
|
||||
You should remove them before moving into a production
|
||||
environment.
|
||||
|
||||
Remove anonymous users? (Press y|Y for Yes, any other key for No) :
|
||||
```
|
||||
|
||||
Remote root login to MySQL is generally not a good thing. I recommend disabling it:
|
||||
|
||||
```
|
||||
Normally, root should only be allowed to connect from
|
||||
'localhost'. This ensures that someone cannot guess at
|
||||
the root password from the network.
|
||||
|
||||
Disallow root login remotely? (Press y|Y for Yes, any other key for No) :
|
||||
```
|
||||
|
||||
Delete the test database to reduce the attack surface for hackers:
|
||||
|
||||
```
|
||||
By default, MySQL comes with a database named 'test' that
|
||||
anyone can access. This is also intended only for testing,
|
||||
and should be removed before moving into a production
|
||||
environment.
|
||||
|
||||
|
||||
Remove test database and access to it? (Press y|Y for Yes, any other key for No) :
|
||||
```
|
||||
|
||||
Reload privilege tables now, unless you need MySQL working for this precise instant. It only takes a second.
|
||||
|
||||
```
|
||||
Reloading the privilege tables will ensure that all changes
|
||||
made so far will take effect immediately.
|
||||
|
||||
Reload privilege tables now? (Press y|Y for Yes, any other key for No) :
|
||||
```
|
||||
|
||||
And you're done!
|
|
@ -286,7 +286,7 @@ You can add lists like this: `['list1', 'stuff'] + ['list2', 'stuff']` but need
|
|||
|
||||
You can get a range of numbers using `range()`
|
||||
|
||||
It will give you all numbers under the number you input. For example, `range(8)` would give you 0-7, `range(1, 8)` would give you 1-7, and `range(1, 8, 2)` would give you 1,3,5,7 (2 is the interval) Use `print(list(var))` when printing.
|
||||
It will give you all numbers under the number you input. For example, `range(8)` would give you 0-7, `range(1, 8)` would give you 1-7, and `range(1, 8, 2)` would give you 1,3,5,7 (2 is the interval and needs no padding) Use `print(list(var))` when printing.
|
||||
|
||||
## length
|
||||
|
||||
|
@ -417,6 +417,65 @@ to produce a new list with sorted contents without changing the original variabl
|
|||
print("Nice little message to user.")
|
||||
```
|
||||
|
||||
# Loops
|
||||
The following assigns an arbitrary name to a temporary variable (tempvar) to the number of elements in `sport_games` For every element in `sport_games`, it will print `print(tempvar)`
|
||||
|
||||
```
|
||||
for tempvar in sport_games:
|
||||
print(tempvar)
|
||||
```
|
||||
|
||||
You can use `range()` to get lists of arbitrary lengths.
|
||||
|
||||
You can also add lists like this:
|
||||
|
||||
```
|
||||
students_period_A = ["Alex", "Briana", "Cheri", "Daniele"]
|
||||
students_period_B = ["Dora", "Minerva", "Alexa", "Obie"]
|
||||
|
||||
for student in students_period_A:
|
||||
students_period_B.append(student)
|
||||
```
|
||||
|
||||
## Iterating until we find something
|
||||
|
||||
```
|
||||
for thing in stuff:
|
||||
if thing == thing_I_want:
|
||||
print("Found it!")
|
||||
break # Stops the loop, executes code outside.
|
||||
```
|
||||
|
||||
## Skip a value in a list.
|
||||
|
||||
Ex.5
|
||||
|
||||
```
|
||||
for age in ages:
|
||||
if age < 21:
|
||||
continue
|
||||
else:
|
||||
print(age)
|
||||
```
|
||||
|
||||
## Move from list to list
|
||||
Ex.7
|
||||
```
|
||||
while len(students_in_poetry) < 6:
|
||||
student = all_students.pop(-1) # Remove last element
|
||||
students_in_poetry.append(student) # Add it to students_in_poetry
|
||||
|
||||
print(students_in_poetry)
|
||||
```
|
||||
|
||||
# Nested Loops
|
||||
|
||||
```
|
||||
for location in sales_data:
|
||||
print(location)
|
||||
for sub in location:
|
||||
scoops_sold += sub
|
||||
```
|
||||
|
||||
# Fun Projects
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
last_semester_gradebook = [("politics", 80), ("latin", 96), ("dance", 97), ("architecture", 65)]
|
||||
subjects = ['physics', 'calculus', 'poetry', 'history']
|
||||
grades = ['98', '97', '85', '88']
|
||||
subjects.append('computer science')
|
||||
grades.append('100')
|
||||
gradebook = list(zip(subjects, grades))
|
||||
gradebook.append(['visual arts', 93])
|
||||
full_gradebook = gradebook + last_semester_gradebook
|
||||
print(full_gradebook)
|
|
@ -0,0 +1,11 @@
|
|||
#Write your function here
|
||||
|
||||
def every_three_nums(start):
|
||||
if start > 100:
|
||||
return []
|
||||
|
||||
everythree = range(start, 101, 3)
|
||||
return list(everythree)
|
||||
|
||||
#Uncomment the line below when your function is done
|
||||
print(every_three_nums(91))
|
|
@ -0,0 +1,4 @@
|
|||
a = 1
|
||||
|
||||
while a == a:
|
||||
print("hi")
|
Loading…
Reference in New Issue