当前位置:网站首页>Record: install MySQL on ubuntu18.04
Record: install MySQL on ubuntu18.04
2022-07-03 18:48:00 【Randle】
step
1. explain : System is Ubuntu18.04.6 LTS
2. install MySQL, Directly using the command line ( You can also use other methods to install , See the first item in the reference catalogue )
First , Enter the command to ensure that your warehouse has been updated
sudo apt update
then , install MySQL5.7 Enter the following command
sudo apt install mysql-server -y
Then wait a few minutes and the installation will succeed .
problem
When I enter or even want to open MySQL But I can't open it , Show Access denied for user ‘root‘@‘localhost‘ (using password: YES), The authority is not enough , there yes That is to say, you entered the password when logging in , If you don't enter the password, it will show NO, Access is denied .
Summary questions :
A scenario : This problem usually occurs just after the installation mysql When
Reasons for appearance : Due to the use of commands sudo apt install mysql When installing , There is no prompt for password , Then the password is not initialized , Use root User login fails naturally .
resolvent
I found that the installation is the default installation , We didn't change our account password , So now let's change the account and password
1. Use cat Command to view the default user name and password
sudo cat /etc/mysql/debian.cnf
Show content :
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = HwPMmIAFg1GNU0OH
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = HwPMmIAFg1GNU0OH
socket = /var/run/mysqld/mysqld.sock
2. Log in with the account and password written above , For example, the account number above is debian-sys-maint, The password is HwPMmIAFg1GNU0OH
mysql -udebian-sys-maint -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
……
mysql>
In this way, the login is successful
3. Then we change the default account password , modify PLUGIN Set up ( The reason for this problem is this ), The account and password set here are root, You can change the account and password you want
UPDATE mysql.user SET authentication_string=PASSWORD('root'), PLUGIN='mysql_native_password' WHERE USER='root';
4. We need to restart our MySQL, I can see , The first is to close , The second is to open , We have to enter our boot password
/etc/init.d/mysql stop
/etc/init.d/mysql start
So we can log in
5. Sign in MySQL, Enter the following command , Then input root The password can enter , Exit can enter exit command
mysql -uroot -p
appendix : If the change is not successful , Then uninstall and reload directly , The unloading steps are given below , sometimes MySQL There will be many other problems , Then you can also choose to reinstall .
Unload command :
sudo rm /var/lib/mysql/ -R
sudo rm /etc/mysql/ -R
sudo apt-get autoremove mysql* --purge
sudo apt-get remove apparmor
Installation command :
sudo apt-get update
sudo apt-get install mysql-server
see MySQL edition
Directly enter the following command
mysql -V
perhaps
mysql --version
see MySQL The installation path
whereis mysql
Here's the picture :
Start off MySQL
There are several ways to start MySQL, I only remember the simplest , use service To start and shut down MySQL, And restart, of course ,( Other methods of startup, shutdown and restart will be given in the reference website ) Direct orders
Be careful : My version is 5.7.37, Different versions have different commands
1. Start command , To start, enter the login password
service mysql start
service mysqld start (5.0 The version is mysqld)
Nothing has changed since startup , But we can enter by command MySQL
mysql -uroot -p
Then enter the password to , Pictured :
2. Exit command ( Exit from the database is exit)
service mysql stop
service mysqld stop (5.0 The version is mysqld)
Pictured :
3. Restart command
service mysql restart
service mysqld restart (5.0 The version is mysqld)
Refer to the website
How the Ubuntu Linux Installation on MySQL
Mysql:ERROR 1698 (28000): Access denied for user ‘root’@‘localhost’
Linux see MySQL Version information for
Linux start-up / stop it / restart Mysql Database method
notes : Thank these authors for their articles , There may be some mistakes in the article , Please point it out in the comments , Common progress
边栏推荐
- Summary and Reflection on the third week of winter vacation
- Introduction to SSH Remote execution command
- Torch learning notes (4) -- torch's dynamic calculation diagram
- Torch learning notes (6) -- logistic regression model (self training)
- leetcode:11. Container with the most water [double pointer + greed + remove the shortest board]
- Sustainable service business models
- Niuke monthly race 31 minus integer
- The online customer service system developed by PHP is fully open source without encryption, and supports wechat customer service docking
- Torch learning notes (5) -- autograd
- Day-27 database
猜你喜欢

Raft 日志复制

Pytorch introduction to deep learning practice notes 13- advanced chapter of cyclic neural network - Classification

Unity webgl optimization

After the festival, a large number of people change careers. Is it still time to be 30? Listen to the experience of the past people

2022-2028 global sepsis treatment drug industry research and trend analysis report

Integrated easy to pay secondary domain name distribution system

There are several levels of personal income tax

12、 Service management

我眼中真正优秀的CTO长啥样

How does GCN use large convolution instead of small convolution? (the explanation of the paper includes super detailed notes + Chinese English comparison + pictures)
随机推荐
Web3 credential network project galaxy is better than nym?
Change is the eternal theme
leetcode:556. Next larger element III [simulation + change as little as possible]
leetcode:11. Container with the most water [double pointer + greed + remove the shortest board]
[leetcode weekly race] game 300 - 6110 Number of incremental paths in the grid graph - difficult
Administrative division code acquisition
Pan for in-depth understanding of the attention mechanism in CV
Getting started with JDBC
Add control at the top of compose lazycolumn
Opencv learning notes (continuously updated)
Read the paper glodyne global topology preserving dynamic network embedding
my. INI file not found
Ping problem between virtual machine and development board
What problems can cross-border e-commerce sellers solve with multi platform ERP management system
How to read the source code [debug and observe the source code]
[Yu Yue education] theoretical mechanics reference materials of Shanghai Jiaotong University
Torch learning notes (4) -- torch's dynamic calculation diagram
leetcode:11. 盛最多水的容器【雙指針 + 貪心 + 去除最短板】
cipher
Typescript configuration