First, download the installation package
Download: https://dev.mysql.com/downloads/mysql/5.7.html#downloads;
Second, start the installation
1, the downloaded archive uploaded to any directory on a Linux server.
2, extract the installation package
tar -zxvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
或
tar zxvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
3, the decompressed file folder to the usr / local directory and renamed mysql-5.7
cp mysql-5.7.22-linux-glibc2.12-x86_64 /usr/local
mv /usr/local/mysql-5.7.22-linux-glibc2.12-x86_64 mysql-5.7
4, the configuration file my.cnf
From the beginning mysql5.7 does not automatically generate my.cnf file, you need to manually create a my.cnf file enter the following
command:
vim /etc/my.cnf
document content:
[mysql]
#设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
#跳过权限表校验
#skip-grant-tables
skip-name-resolve
#设置3306端口
port = 3306
#设置mysql的安装目录
basedir=/usr/local/mysql-5.7
#设置mysql数据库的数据的存放目录
datadir=/usr/local/mysql-5.7/data
#允许最大连接数
max_connections=200
#服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
#创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=16M
5, in the my.cnf configuration file, note that the datadir parameter specifies the data directory here in the mysql-5.7, data that we need to manually create the directory does not exist.
Enter in the mysql-5.7 directory
mkdir data
6, add user mysql, mysql group
groupadd mysql
useradd -r -g mysql mysql
chown -R mysql:mysql /usr/local/mysql-5.7/
7, initialize the database
Enter in mysql5.7 directory (note that most front a little)
./bin/mysqld --user=mysql --basedir=/usr/local/mysql-5.7 --datadir=/usr/local/mysql-5.7/data -initialize
Results as shown
in which the red frame is the initial password
8, MySQL start (after the activation, shown below)
mysqld --user=root
Third, modify the database password
1, enter mysql
mysql -uroot -p
Then write the initial password database initialization given.
We need to change the initial password after the first access to the database being given access to the database or not (as shown) in MySQL
it is necessary to modify the initial password database, the following command
alter user ‘root’@’localhost’ identified by ‘密码’
Fourth, the remote connection permissions granted
use mysql
update user set user.Host='%' where user.User='root'
View the modified values:
select user,host from user;
Refresh authority, the following command
flush privileges;