Install mysql5.7 using centos 7 rpm
Step 1: Download mysql
Use the wget command on the Linux terminal to download network resources:
wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
1: Check whether MySQL is installed locally
rpm -qa | grep mysql
2: uninstall the previous mysql
Full name of an existing MySQL instance in rpm-e
Step 2: Decompress the file
Next, go to the moved directory.cd /usr/local
And decompress
tar zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar
To facilitate subsequent operations, you can change the decompressed file name to mysql:
mv mysql-5.7.17-linux-glibc2.5-x86_64 mysql
Step 3: configure the Startup File
Then gomysql
Ofsupport-files
Directory
1. Copy
my.cnf
To
/etc/my.cnf
(Mysqld is automatically read at startup)
cp my-default.cnf /etc/my.cnf
Note: If you have installed the default mysql at the same time on the Linux virtual machine during installation, the terminal will prompt you whether the file already exists and overwrite it by entering yes.
2. Configure database Encoding
vi /etc/my.cnf
Add the following configuration information to this file (if any)
[mysql]default-character-set=utf8[mysqld]default-storage-engine=INNODBcharacter_set_server=utf8
3. Copy
mysql.server
To
/etc/init.d/
Directory [Purpose: To achieve automatic execution upon startup]
Run the following command (mysql is the service name ):
cp mysql.server /etc/init.d/mysql
4. Modify
/etc/init.d/mysql
Parameters
vi /etc/init.d/mysql
Give two directory locations
basedir=/usr/local/mysqldatadir=/usr/local/mysql/data
5. Create a special user who operates the database for security and convenience
> 1 ),groupadd mysql
# Create a mysql group> 2 ),useradd -r -g mysql mysql
# Create a mysql user and put the user in the mysql group> 3 ),passwd mysql
# Set a password for the mysql user 4 )./usr/local/mysql
Change ownerchown -R mysql:mysql /usr/local/mysql/
Step 4: Initialize the mysql database
First gomysql
Ofbin
Directory
1. Initialization
./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
Generate a data Directory, which indicates that the database has been initialized successfully and the mysql root User has generated a temporary password:***(It is best to record this temporary password first)
2. encrypt the database./mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data
3. Start mysql (to prevent the process from getting stuck, you can add & indicates that the process runs in the background after the mysql Command is started)./mysqld_safe --user=mysql &
4. Checkps -ef|grep mysql
If a process is found, the startup is successful.
Step 5: Enter the client 1. log on:./Mysql-uroot-p # p and enter the previous temporary password
2. Change the passwordSet password = password ('new password ');
Step 6: Set Remote Access 1. Before remote access, open the centos7 port: 1): Enable the Port:firewall-cmd --zone=public --add-port=3306/tcp --permanent
2): restart the Firewall:firewall-cmd --reload
2. AuthorizationMysql>Grant all privileges on *. * to remote access username @ '%' identified by 'user password ';
Mysql>select host,user from user;
[One more remote logon user record] mysql>flush privileges;
(Refresh)
Now you can use a remote machine for access!
Resolution: Use the mysql-h Host ip address-u username-p password for remote access
Step 7: Set auto-start upon startup 1. Add the mysql Servicechkconfig --add mysql
[Mysqld-install]
2. Set mysql service to automaticchkconfig mysql on
3. Restart to view the processinit 6
ps -ef|grep mysql
Step 8: Configure Environment VariablesTo facilitate the operation, it is necessary to configure environment variables.
vi /etc/profileexport PATH=$JAVA_HOME/bin:/usr/local/mysql/bin:$PATH
Summary: The basic configuration in this step is complete.