Install mysql5.7 on Ubuntu (Tell people tirelessly, remember to dry goods)

In ubuntu, we often use the apt-get command plug-in. In fact, it has been updating the corresponding resource library. So far,

The latest version of mysql in the apt-get resource library is: mysql-5.7.29

Therefore, we can install mysql57 directly through the latest version of apt-get command, avoiding many troubles of manual installation;

This article will take you through the original installation process. If you are preparing to install mysql57 on the ubuntu system, congratulations, this article will definitely help you. If you encounter any trouble, leave a message below as soon as possible, and I will diagnose the problem in time.

installation##

1. Uninstall/clean up remnants###

  1. Check if mysql has installed dependencies
dpkg --list|grep mysql

Uninstall mysql-common first

sudo apt-get remove mysql-common

Then execute:

sudo apt-get autoremove --purge mysql-server-5.0

Then continue to check with dpkg --list|grep mysql, uninstall whatever is left;

Two, install mysql

# Update apt-get, the latest resource library will be used after the update
sudo apt-get update

# Install MySQL:
sudo apt-get install mysql-server

# View MySQL version: 
mysql -V

# Enter MySQL: 
mysql -u root -p
# start up: 
sudo service mysql start

# Reboot:
sudo  service mysql restart 

# shut down: 
sudo service mysql stop

Ubuntu16-Ubuntu18 installs mysql5.7 without prompt for password, mysql default password is empty; just log in directly;

If you use the mysql -uroot -p command to connect to mysql, an error is reported

ERROR 1045(28000): Access denied for user ‘root’@'localhost’

Now you can modify the default password of root:

  1. Go to the /etc/mysql/ directory and check the debian.cnf file

  1. Find the user name, password, use this account to log in to mysql
    Username: debian-sys-maint
    Password: UsIgysQBZbL6X4qW
    Login: mysql -udebian-sys-maint -pUsIgysQBZbL6X4qW

  1. Modify the password of the root user
    Here is the key point. Since mysql5.7 does not have a password field, the password is stored in the authentication_string field. The password() method can also be used in mysql to execute the following statement to modify the password:
show databases;
use mysql;
update user set authentication_string=PASSWORD("123456") where user='root';
update user set plugin="mysql_native_password";
flush privileges;
exit;
  1. After changing the password, you need to restart mysql; just log in again;

Finally, remember to modify the database encoding format

Enter the mysql command line and enter: show variables like'character%';

We need to adjust the database and server to utf8;

First we find the mysqld.cnf file: find / -name mysqld.cnf

Modify the content of mysqld.cnf: just add it under the corresponding label (as shown below), **if there is no [mysql] label, add **;

[ mysql]default-character-set=utf8

[ mysqld]

character_set_server=utf8

collation_server=utf8_general_ci

Restart mysql after saving; service mysql restart; log in to the mysql command line again after restart

Type show variables like'character%';

The following figure shows that the database configuration is complete;

Recommended Posts

Install mysql5.7 on Ubuntu (Tell people tirelessly, remember to dry goods)
How to install MySQL on Ubuntu 20.04
How to install MySQL on Ubuntu 20.04
How to install MySQL on Ubuntu 14.04
How to install MySQL on Ubuntu 18.04 (linux)
Install mysql on Ubuntu 14.04
How to install the latest MySQL on Ubuntu 18.04
How to install and use MySQL Workbench on Ubuntu 18.04
Install Mysql offline on Ubuntu
How to install JDK and Mysql on Ubuntu 18.04 linux system
How to install MySQL on CentOS 8
How to install Ruby on Ubuntu 20.04
How to install Memcached on Ubuntu 20.04
How to install Java on Ubuntu 20.04
How to install VirtualBox on Ubuntu 20.04
How to install Elasticsearch on Ubuntu 20.04
How to install Protobuf 3 on Ubuntu
How to install Nginx on Ubuntu 20.04
How to install Apache on Ubuntu 20.04
How to install Git on Ubuntu 20.04
How to install Node.js on Ubuntu 16.04
Install and configure MySQL on Ubuntu
How to install Vagrant on Ubuntu 20.04
How to install Bacula-Web on Ubuntu 14.04
How to install PostgreSQL on Ubuntu 16.04
How to install Git on Ubuntu 20.04
How to install Anaconda3 on Ubuntu 18.04
How to install mysql in Ubuntu 14.04
How to install Memcached on Ubuntu 18.04
How to install Jenkins on Ubuntu 16.04
How to install MemSQL on Ubuntu 14.04
How to install Go on Ubuntu 20.04
How to install MongoDB on Ubuntu 16.04
How to install Mailpile on Ubuntu 14.04
How to install PrestaShop on Ubuntu 16.04
How to install Skype on Ubuntu 20.04
How to install Jenkins on Ubuntu 20.04
How to install Python 3.8 on Ubuntu 18.04
How to install KVM on Ubuntu 18.04
How to install KVM on Ubuntu 20.04
How to install opencv3.0.0 on ubuntu14.04
How to install Anaconda on Ubuntu 20.04
How to install Prometheus on Ubuntu 16.04
How to install Jenkins on Ubuntu 18.04
How to install Apache on Ubuntu 20.04
How to install R on Ubuntu 20.04
How to install Moodle on Ubuntu 16.04
How to install Solr 5.2.1 on Ubuntu 14.04
How to install Teamviewer on Ubuntu 16.04
How to install MariaDB on Ubuntu 20.04
How to install Nginx on Ubuntu 20.04
How to install Mono on Ubuntu 20.04
How to install Go on Ubuntu 20.04
How to install Zoom on Ubuntu 20.04
How to install mysql in Ubuntu 14.04
How to install Nginx on Ubuntu 16.04
How to install OpenCV on Ubuntu 20.04
How to install Spotify on Ubuntu 20.04
How to install Postman on Ubuntu 18.04
How to install Go 1.6 on Ubuntu 16.04
How to install Go on Ubuntu 18.04