当前位置:网站首页>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
边栏推荐
- [combinatorics] dislocation problem (recursive formula | general term formula | derivation process)*
- JS_ Array_ sort
- [Godot] add menu button
- Scrapy爬虫框架
- Torch learning notes (6) -- logistic regression model (self training)
- How to analyze the rising and falling rules of London gold trend chart
- 042. (2.11) do it when it's time to do it
- NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
- 编程中常见的 Foo 是什么意思?
- Torch learning notes (1) -- 19 common ways to create tensor
猜你喜欢
Compose LazyColumn 顶部添加控件
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
[Yu Yue education] theoretical mechanics reference materials of Shanghai Jiaotong University
Integrated easy to pay secondary domain name distribution system
2022-2028 global aircraft head up display (HUD) industry research and trend analysis report
Mysql45 lecture learning notes (II)
A green plug-in that allows you to stay focused, live and work hard
NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
Raft 日志复制
2022-2028 global copper foil (thickness 12 μ M) industry research and trend analysis report
随机推荐
Win 11 major updates, new features love love.
[Yu Yue education] world reference materials of Microbiology in Shanghai Jiaotong University
Typescript configuration
2022-2028 global solid phase extraction column industry research and trend analysis report
2022-2028 global marking ink industry research and trend analysis report
Have you learned the correct expression posture of programmers on Valentine's day?
NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
Boost.Asio Library
G1 garbage collector of garbage collector
042. (2.11) do it when it's time to do it
application
Read the paper glodyne global topology preserving dynamic network embedding
SQL custom collation
Help change the socket position of PCB part
2022-2028 global physiotherapy clinic industry research and trend analysis report
How many convolution methods does deep learning have? (including drawings)
CTO and programmer were both sentenced for losing control of the crawler
2022-2028 global sepsis treatment drug industry research and trend analysis report
Niuke monthly race 31 minus integer
Chisel tutorial - 06 Phased summary: implement an FIR filter (chisel implements 4-bit FIR filter and parameterized FIR filter)