mysql 5.7. 16 Installation Configuration Tutorial (ubuntu 16.04)

  • 2021-07-01 08:21:21
  • OfStack

Ubuntu 16.04 How do I install MySQL 5.7?

Install the main program

As far as I know, there are two ways to install the main program:
-Fully automatic installation using apt-get


#  Installation command 
apt-get install mysql-server
#  You need to enter during installation mysql Adj. root Password 

Manual installation of dependency packages using dpkg


# 1.  Download the installation package 
#  What I downloaded during the test is: mysql-server_5.7.16-1ubuntu16.04_amd64.deb-bundle.tar
#  Domestic Mirror Station: http://mirrors.sohu.com/mysql/MySQL-5.7/

wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-server_5.7.16-1ubuntu16.04_amd64.deb-bundle.tar

# 2.  Unzip the installation package 
#  After decompression, the following will appear: 
# libmysqlclient20_5.7.16-1ubuntu16.04_amd64.deb
# mysql-common_5.7.16-1ubuntu16.04_amd64.deb  
# mysql-community-source_5.7.16-1ubuntu16.04_amd64.deb 
# mysql-testsuite_5.7.16-1ubuntu16.04_amd64.deb
# libmysqlclient-dev_5.7.16-1ubuntu16.04_amd64.deb 
# mysql-community_5.7.16-1ubuntu16.04_amd64.changes 
# mysql-community-test_5.7.16-1ubuntu16.04_amd64.deb 
# libmysqld-dev_5.7.16-1ubuntu16.04_amd64.deb 
# mysql-community-client_5.7.16-1ubuntu16.04_amd64.deb 
# mysql-server_5.7.16-1ubuntu16.04_amd64.deb
# mysql-client_5.7.16-1ubuntu16.04_amd64.deb 
# mysql-community-server_5.7.16-1ubuntu16.04_amd64.deb

tar -xvf ../mysql-server_5.7.16-1ubuntu16.04_amd64.deb-bundle.tar -C ./

# 3.  Use dpkg Install dependency packages 

dpkg -i mysql-common_5.7.16-1ubuntu16.04_amd64.deb
dpkg -i libmysqlclient20_5.7.17-1ubuntu16.04_amd64.deb 
dpkg -i libmysqlclient-dev_5.7.17-1ubuntu16.04_amd64.deb 
dpkg -i libmysqld-dev_5.7.17-1ubuntu16.04_amd64.deb

#  Above 4 There should be no problem with the installation of each package, and the next package installed will throw the error of missing dependent packages 
#  I forgot to write down the missing package name at that time, please read it carefully 1 Under the error message, and then use the apt-get Installation 1 Just go down 

dpkg -i mysql-community-client_5.7.17-1ubuntu16.04_amd64.deb 
dpkg -i mysql-client_5.7.17-1ubuntu16.04_amd64.deb 
dpkg -i mysql-community-source_5.7.17-1ubuntu16.04_amd64.deb

#  Next, we need to install mysql-community-server Package, before installation, you need to follow 1 Dependency packages: libmecab2

apt-get install libmecab2
dpkg -i mysql-community-server_5.7.17-1ubuntu16.04_amd64.deb 
##  You need to enter during installation mysql Adj. root Password 

At this point, we have completed the main program installation, and can use MySQL-u root-p to log in to the database on this machine.

Open remote access

Turn on the full name access rights of root users
1. Modify host of user in database


sh 
#  Use mysql -u root -p Log in to the database and execute the following statements in turn  
# xxxxxx Denote root User's password  
use mysql; 
update user set host = '%' where user ='root'; 
grant all privileges on *.* to 'root'@'%' identified by 'xxxxxx'; 
flush privileges; 

2. Modify the ip binding in my. conf


sh 
#  Enter Edit /etc/mysql/mysql.conf.d/mysqld.conf 
vi /etc/mysql/mysql.conf.d/mysqld.conf 
#  Modify ip Binding  
#  In the source file:  
bind-address 127.0.0.1 
#  Modify it to read:  
bind-address 0.0.0.0 
#  Overwrite save  
esc:wq 

3. Restart the database


sh 
#  Restart command  
service mysql restart 

Add users and allow remote access


#  Adding users and allowing remote access only needs to be done in the user Add to the table 1 Users, set the host Set to % You can 
#  The following example assigns all permissions to new users by default, for example: 
grant all privileges on *.* to 'lethew'@'%' identified by 'abcdef';
flush privileges;

References

Main program installation: https://www.ofstack.com/article/103353. htm

Open remote access: https://www.ofstack.com/article/103764. htm

Solve the 10061 problem: https://www.digitalocean.com/community/questions/can-t-connect-to-mysql-server-on-ipaddress-10061


Related articles: