Installation, configuration and uninstallation of MySQL on Ubuntu

Server-side installation

  • Install the server side: enter the following command in the terminal, press Enter, and then follow the prompts to enter
sudo apt-get install mysql-server
  • Start service
sudo service mysql start
  • Check whether the mysql service exists in the process
ps ajx|grep mysql
  • Out of service
sudo service mysql stop
  • Restart service
sudo service mysql restart

set password

  • Enter the following command:
sudo cat /etc/mysql/debian.cnf

Insert picture description here

  • Enter the following command
mysql -u debian-sys-maint -p
//注意! 
//这条指令的密码输入是输入第一条指令获得的信息中的 password (红色箭头指向)得来。
//请根据自己的实际情况填写!

  • Change the password, this article will change the password to root, the user can define it by himself
use mysql;
// 下面这句命令有点长,请注意。
update mysql.user set authentication_string=password('root') where user='root' and Host ='localhost';
update user set plugin="mysql_native_password"; 
flush privileges;
quit;
  • Restart mysql.
sudo service mysql restart
mysql -u root -p // 启动后输入已经修改好的密码:root

Guess you like

Origin blog.csdn.net/weixin_44533129/article/details/103706195