当前位置:网站首页>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
边栏推荐
- Torch learning notes (3) -- univariate linear regression model (self training)
- Sepconv (separable revolution) code recurrence
- Integrated easy to pay secondary domain name distribution system
- Web3 credential network project galaxy is better than nym?
- 12、 Service management
- Administrative division code acquisition
- Zhengda futures news: soaring oil prices may continue to push up global inflation
- JS_ Array_ sort
- Know what it is, and know why, JS object creation and inheritance [summary and sorting]
- Typescript configuration
猜你喜欢

CV in transformer learning notes (continuously updated)

12、 Service management

Multifunctional web file manager filestash

Raft log replication

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

Nodejs (01) - introductory tutorial

Does SQL always report foreign key errors when creating tables?

2022-2028 global marking ink industry research and trend analysis report

Xception for deeplab v3+ (including super detailed code comments and original drawing of the paper)

How to quickly view the inheritance methods of existing models in torchvision?
随机推荐
Have you learned the correct expression posture of programmers on Valentine's day?
Read the paper glodyne global topology preserving dynamic network embedding
webcodecs
Naoqi robot summary 27
Typescript configuration
235. The nearest common ancestor of the binary search tree [LCA template + same search path]
Unity2018 to wechat games without pictures
Summary and Reflection on the third week of winter vacation
leetcode:556. 下一个更大元素 III【模拟 + 尽可能少变更】
[Yu Yue education] theoretical mechanics reference materials of Shanghai Jiaotong University
Transformer T5 model read slowly
SQL custom collation
平淡的生活里除了有扎破皮肤的刺,还有那些原本让你魂牵梦绕的诗与远方
leetcode:11. 盛最多水的容器【双指针 + 贪心 + 去除最短板】
硬盘监控和分析工具:Smartctl
leetcode:11. Container with the most water [double pointer + greed + remove the shortest board]
Caddy server agent
Su embedded training - Day10
After nohup NPM start &, close the shell window directly, and the process closes accordingly
[combinatorics] exponential generating function (concept of exponential generating function | permutation number exponential generating function = combinatorial number ordinary generating function | e