This is the 24th day of my participation in the August More Text Challenge

Database is the most commonly used tool in daily projects, installation is a skill we must master, this article recorded the whole process of the building installation. Ensure that there is no exception, it is recommended to collect, when using directly copy.

1. Download

Had better not download again official website, thief slow, can look for Linux to install on CSDN, or Baidu network disk. The web disk address is attached below. Link: pan.baidu.com/s/1zkCN7Sc8… Extraction code: F8EI

2. Unzip

Create a new folder and then go inside and unzip it.

The tar XVF mysql - 5.7.26 - Linux - glibc2.12 - x86_64. Tar. GzCopy the code

3. Move and rename

Mysql - 5.7.26 - Linux - mv glibc2.12 x86_64 / usr/local/mysqlCopy the code

4. Create mysql user groups and users and modify their permissions

Go to the directory where the database is compressed. Perform operations

CD /user/local/mysql groupadd mysql useradd -r -g mysql mysql mkdir -p /data/mysql # create directory chown mysql:mysql -r /data/mysqlCopy the code

5. Configuration my. CNF

vim /etc/my.cnf
Copy the code

Configuration is as follows

[mysqld] bind-address=0.0.0.0 port=3306 user=mysql basedir=/usr/local/mysql datadir=/data/mysql socket=/ TMP /mysql.sock log-error=/data/mysql/mysql.err pid-file=/data/mysql/mysql.pid #character config character_set_server=utf8mb4 symbolic-links=0 explicit_defaults_for_timestamp=true lower_case_table_names=1Copy the code

6. Initialize the database

cd /usr/local/mysql/bin/
Copy the code
./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql --initialize
Copy the code

Mysqld: cannot execute binary file mysqld: cannot execute binary file mysqld: cannot execute binary file

7. View the password

cat /data/mysql/mysql.err
Copy the code

Be careful to include that.And mysql input password does not have a cursor, directly copy and paste can also be.

8. To start the mysql

1. The configuration

Mysql > insert mysql.server into /etc/init.d/mysql.

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
Copy the code

2. Start the service

service mysql start
ps -ef|grep mysql

Copy the code

3. Stop the service

service mysql stop
Copy the code

9. Login

Log in first with the initial password, the one viewed above. Just copy it.

./mysql -u root -p 
Copy the code

Log in successfully

10. Change your password

The first boot does not come with the account password, so we need to set the account password at the first boot.

SET PASSWORD = PASSWORD('123456');
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
FLUSH PRIVILEGES;                                 
Copy the code

11. Change the configuration

If you want to connect using Navicat, you also need to execute the following command.

Update user set host = '%' where user = 'root'; Enable root to access FLUSH PRIVILEGES from any host.Copy the code

If you don’t want to every time bin directory using mysql commands, execute the following command ln -s/usr/local/mysql/bin/mysql/usr/bin