Linux, MySQL Installation and Configuration

Recently the company to make a sort Mysql Linux installation documentation. So we order a bit, there will be a detailed document finishing their own notes.

1, download Mysql.

https://dev.mysql.com/downloads/mysql/5.6.html#downloads

I choose to install this version is 5.7.26

Selecting an installation package for download

https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz

Use the download command directly download or upload to your own server after downloading.

wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz

2, extract the installation package

tar –zxvf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz

3, copy the files to the installation directory

Copy the file to / usr / local / mysql (normal circumstances are of course also copy this directory can be customized)

cp -r mysql-5.7.26-linux-glibc2.12-x86_64 /usr/local/mysql

4, mysql add and modify users and user groups corresponding to the authority

groupadd mysql

useradd -g mysql mysql

Change the / usr / local / mysql folder owner attributes and the corresponding permissions

chown -R mysql:mysql  /usr/local/mysql/

chown -R mysql  /usr/local/mysql/

chmod -R 755 /usr/local/mysql/

5, the installation dependencies libaio if installed skip

6, the initial installation

Create a data directory in the current directory (/ usr / local / mysql /) used to store the database data file (this location can be customized)

mkdir data

Note that modify data directory permissions

chown -R mysql:mysql  /usr/local/mysql/data

chown -R mysql  /usr/local/mysql/data

chmod -R 755 /usr/local/mysql/data

Initial installation command

bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize

mysqld in the bin directory of the following database software; I am currently in / usr / local / mysql root directory so the front to add bin directory execute mysqld.

basedir : database software root directory, that is after decompression copy to the local

datadir : Database data storage directory, which is mkdir front of the front of the data established

Remember temporary database login password remember last few characters are generated after the colon is the password (see below)

If there is: . But the initialize at The data specified in IT Directory has the Aborting Files wrong, all files in the directory set data are deleted, and then initialize the install command.

7, modify the configuration file

Modify datadir, basedir like corresponding directory.

All the configuration file configuration file locations must be real, there is no need to manually create; and give the corresponding file permissions.

vim /etc/my.cnf

8, create a log file and give the corresponding permission

var / log / mariadb / mariadb.log mariadb.log file you want to create here must do well.

Create a file (I was already in var / log / mariadb the directory)

Create a file

touch mariadb.log

Set the log file and the corresponding rights owner to mysql

chown -R mysql:mysql /var/log/mariadb/

chown -R mysql /var/log/mariadb/

chmod -R 755 /var/log/mariadb/

 

9, mysql will join the service and set boot from the start

Added services

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

boot

chkconfig mysql on

10, start the service and Mysql database connection

service mysql start

 

See Starting MySQL. SUCCESS! Representatives started successfully. At this point the installation startup is complete.

Connect to the database using the temporary password

mysql -u root –p

If you enter any login mysql command prompt is: You must reset your password using ALTER USER statement before executing this statement.

As shown error

If this is the case you need to force the user to modify the password.

the User the User the ALTER () IDENTIFIED by "123456";  (this command is executed after logging in mysql)

11, modified to allow remote connection

Allow remote connections such as for example Navicat client login.

The following commands are executed after a successful login mysql

update user set host='%' where user = 'root';

The permission to modify with immediate effect.

flush privileges;

Note that in a real production environment, such a modification is not recommended, because of the security risk is too great. It recommended that the root host entry for the user to modify a specified ip address or localhost remains of the actual situation.

Then you can use the client connected.

Using Client Connection Note To open the firewall port 3306 for the job, if it is to buy cloud server you need to add the corresponding port in and out of the cloud server security settings page.

Guess you like

Origin www.linuxidc.com/Linux/2019-12/161832.htm