Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.
Virtualbox virtual machine
Vagrant creates a Linux VIRTUAL machine, yum installs dependencies, especially nginx pre, OpenSSL, Zlib, mysql Libaio, etcCopy the code
Environment configuration
- PSFTP transfer tool, between win system and Linux file transfer
- Log in to the Linux server using putty
- For Linux, the clean version of centos7. Box is known to vagrant
Mysql installation
- Download the mysql installation package, address: downloads.mysql.com/archives/co…
- Check whether the system comes with mysql or Mariadb first
RPM - qa | grep mysql if there is any data unload: RPM -e mysql - libs - * * * * check mariadb ditto operationCopy the code
- Installation package: local download and then upload Linux or Linux download is also available
CD/opt/wget HTTP: / / https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.25-linux-glibc2.12-x86_64.tar.gzCopy the code
- Decompress: tar ZXVF mysql-5.7.25-****
- Mysql -5.7.25-*** /usr/local/mysql
- Check whether the user and mysql group exist
Cat/etc/group | grep mysql cat/etc/passwd | grep mysql is deleted, or create a delete operation: groupdel/userdel create operation: Groupadd mysql useradd -r -g mysql mysql tips: The -r parameter indicates that mysql is a system user and cannot be used to log in to the systemCopy the code
- Create a database directory:
Run the CD /usr/local/mysql mkdir data command to change the owner and group of mysql to mysql chown -r mysql:mysql /usr/local/mysqlCopy the code
- Create a database configuration file
Create my_default. CNF in the support-files directory and edit the content as follows: # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html # * * * DO NOT EDIT THIS FILE. It 's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [mysqld] sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES basedir = /usr/local/mysql datadir = /data/myqsldb port = 3306 Socket = / TMP/mysql. The sock # don't change to other directories character - set - server = utf8 log - error = / usr/local/mysql/mysqld. Log pid - file = /usr/local/mysql/mysqld.pidCopy the code
- Copy the file to the /etc directory: cp supper-files /my_default. CNF /etc/my.cnf
- Initialize mysqld, that is, generate the database file
cd /usr/local/mysql
./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysqldb --pid-file=/usr/local/mysql/mysqld.pid
Copy the code
- Find the log path to view the log and get the temporary password: cat mysqld.log last line
- Put the startup script in the startup initialization directory cp supper-files /mysql.server /etc/init.d/mysql
- Start the service: service mysql start
- Log in to mysql with temporary password./bin/mysql -uroot -p
mysql> set password=password('vagrant');
mysql> grant all privileges on *.* to root@'%' identified by 'vagrant';
mysql> flush privileges;
Copy the code
- Add the remote access permission to mysql
mysql> use mysql;
mysql> update user set host='%' where user = 'root';
mysql> flush privileges;
Copy the code
- Restarting mysql takes Effect
Problems occurred during mysql installation on Linux
A libaio dependency was missing during initialization
Yum install -y libaioCopy the code
Failed to initialize the database. No data/ data files were generated. Fatal error: Can’t open and lock privilege tables: Table ‘mysql.user’ doesn’
Verify that the initialization parameters are missing or correct: --initializeCopy the code
“/ TMP /mysql.sock” is displayed when logging in to mysql.
Create a soft link to/TMP /. Create a soft link to/TMP /Copy the code
Error 1130-host’gateway
Update user set Host='%' where user ='root'; flush privileges;Copy the code