Install mysql5.7.28 version on Ubuntu 18.04

Top priority after installing Ubuntu 18.04 system

1. Replace domestic sources

a. Back up the original source files.

sudo cp /etc/apt/sources.list /etc/apt/sources_init.list

b. Replace the source

After backing up the source file, delete the original file and create a new blank file.

sudo rm -rf /etc/apt/sources.list
sudo touch /etc/apt/sources.list
sudo vi /etc/apt/sources.list

c. Fill in the content of the document (Aliyuan)

deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main

deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main

deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe

deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe

2. Update

sudo apt-get update
sudo apt-get upgrade


The command sudo apt-get update will visit each URL in the source list, read the software list, and save it on the local computer. The software list we see in Synaptic Package Manager is updated through the update command.

After update, you may need to upgrade.
The sudo apt-get upgrade
command will compare the locally installed software with the corresponding software in the newly downloaded software list. If you find that the installed software version is too low, you will be prompted to update. If your software is the latest version, it will prompt:

3. Install MySQL5.7.28

1), install and view the version

 sudo apt-get install mysql-server
 sudo service mysql restart
 mysql --version
 sudo mysql

2), modify the default character set

Add the following under [mysql] in /etc/mysql/mysql.conf.d/mysqld.cnf: 

init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake

Restart to check the effect

sudo service mysql restart;
#登录mysql
mysql: show variables like '%character%';

3), modify remote login permissions

First edit the file /etc/mysql/mysql.conf.d/mysqld.cnf:

Save and exit, then enter the mysql service, execute the authorization command:

grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
flush privileges;​

At this point, the operation is complete and you can connect to this mysql database server from any host.

Guess you like

Origin blog.csdn.net/qq_30264689/article/details/103311693