当前位置:网站首页>Ubuntu 20.04 installing mysql8.0 and modifying the MySQL password
Ubuntu 20.04 installing mysql8.0 and modifying the MySQL password
2022-06-25 14:53:00 【Mr . Solitary patient】
Preface
The blogs found on the Internet about this kind of blog are either mysql The version is out of date or completely useless , Wasted a lot of my time , So I shared my successful experience with you , I hope we can reduce the time for detours .
Mysql Installation
It's simple , In a word
sudo apt install mysql-server
Msql Password modification
To change the password, we have to go first mysql, With administrator privileges, no matter what password you enter, you can succeed .
sudo mysql -u root -p
The result is as shown in the figure , Indicates installation is complete 
Next, log out
quit;
And then to mysql Initialization of password settings
sudo mysql_secure_installation
The following configuration is shown in the figure
#1
VALIDATE PASSWORD PLUGIN can be used to test passwords...
Press y|Y for Yes, any other key for No: N ( choice N , No strong password verification )
#2
Please set the password for root here...
New password: ( Input password )
Re-enter new password: ( Repeat input )
( Here he will ask you if you want to change your password , First choice y)
#3
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...
Remove anonymous users? (Press y|Y for Yes, any other key for No) : N ( choice N, Don't delete anonymous users )
#4
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) : N ( choice N, allow root Remote connection )
#5
By default, MySQL comes with a database named 'test' that
anyone can access...
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N ( choice N, Don't delete test database )
#6
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) : Y ( choice Y, The modification will take effect immediately )
Log in after finishing
sudo mysql -uroot -p
choice mysql database
use mysql;
Try setting the password for the first time , This time, an error may be reported Your password does not satisfy the current policy requirements, This is because the length of your password does not meet the length requirements , If no error is reported, the following steps are not required .
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY ' password ';
If an error is reported, perform the following steps
SHOW VARIABLES LIKE 'validate_password%';
mysql The following parameters will be output
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password.check_user_name | ON |
| validate_password.dictionary_file | |
| validate_password.length | 8 |// This is the password length you want to set
| validate_password.mixed_case_count | 1 |
| validate_password.number_count | 1 |
| validate_password.policy | MEDIUM |
| validate_password.special_char_count | 1 |
+--------------------------------------+--------+
7 rows in set (0.01 sec)
Then we will compare the parameters of your computer with those here , Generally speaking, except that the password length is different, it is the same , If it does not always exist, modify it as follows .
1 mysql> set global validate_password.policy=0;
Query OK, 0 rows affected (0.00 sec)
2 mysql> set global validate_password.special_char_count=0;
Query OK, 0 rows affected (0.00 sec)
3 mysql> set global validate_password.length=6;
Query OK, 0 rows affected (0.00 sec)
4 mysql> set global validate_password.mixed_case_count=0;
Query OK, 0 rows affected (0.00 sec)
After that, let's see if the parameter modification is successful
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password.check_user_name | ON |
| validate_password.dictionary_file | |
| validate_password.length | 6 |
| validate_password.mixed_case_count | 0 |
| validate_password.number_count | 1 |
| validate_password.policy | LOW |
| validate_password.special_char_count | 0 |
+--------------------------------------+-------+
7 rows in set (0.01 sec)
Finally, re-enter the previous command to change the password .( Note that the password should be the same length as the one you modified above )
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY ' password ';
Save the settings and exit
flush privileges;
quit;
Finally, let's test whether the modification is successful
mysql -u root -p // Don't add... Here sudo
Input password , Can enter into mysql If no error is reported, the password is successfully modified .
边栏推荐
- 开餐馆
- Arithmetic operations and expressions
- [HBZ sharing] use of locksupport
- In 2022, the score line of Guangdong college entrance examination was released, and several families were happy and several worried
- SPARQL learning notes of query, an rrdf query language
- 重磅!国产 IDE 发布,由阿里研发,完全开源!(高性能+高定制性)
- Automatic correlation between QT signal and slot
- Jaspersoft studio adding MySQL database configuration
- p1408
- Thymeleaf Usage Summary
猜你喜欢

【Try to Hack】vulnhub DC1

关于win10 版本kicad 卡死的问题, 版本6.x

Using Sphinx to automatically generate API documents from py source files

Report on Hezhou air32f103cbt6 development board

Thymeleaf Usage Summary

How to crop GIF dynamic graph? Take this picture online clipping tool

How to view the Chrome browser plug-in location

分享自己平時使用的socket多客戶端通信的代碼技術點和軟件使用

Does stream even have application advanced learning? As a programmer, you know what

Clinical chemistry | zhangjianzhong / Xu Jian develop single cell precision diagnosis and treatment technology for Helicobacter pylori
随机推荐
H5 page graying source code, ie compatible (elegant downgrade provides download browser link)
JS component
弹性布局(display:flex;)属性详解
Application of TSDB in civil aircraft industry
Two common ways for orcale to clear table data
QT database connection deletion
[deep learning] multi label learning
For the first time in China, Chinatelecom 5g underground personnel positioning project is officially commercial: it can track the position in real time to ensure operation safety
QT opens the print dialog box in a text editor
Time stamp calculation and audio-visual synchronization of TS stream combined video by ffmpeg protocol concat
Kubernetes understands kubectl/ debugging
2020-03-20
C language LNK2019 unresolved external symbols_ Main error
Common formatting methods for amount numbers
[try to hack] vulhub shooting range construction
Biscuit distribution
Qmake uses toplevel or topbuilddir
Is it normal to dig for money? Is it safe to open a stock account?
If multiple signals point to the same slot function, you want to know which signal is triggered.
【HBZ分享】LockSupport的使用