First step: Download MySQL
Cd/usr/local/src
Download package: wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz (or upload directly from window)
Decompression: Tar zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
Move to/USR/LOCAL:MV mysql-5.7.17-linux-glibc2.5-x86_64/usr/local
Into the/usr/local/directory: cd/usr/local
Renamed to MYSQL:MV mysql-5.7.17-linux-glibc2.5-x86_64 MySQL
Then go to the Mysql/support-files directory: CD mysql/support-files
Step two: Modify the parameters
1. Copy my.cnf to/ETC/MY.CNF (automatically read at mysqld startup)
CP MY-DEFAULT.CNF/ETC/MY.CNF
Note: If you install the Linux virtual machine at the same time when the default MySQL, the above steps, the terminal will prompt you whether the file is overwritten, enter Yes overwrite.
2. Configure Database encoding
Vi/etc/my.cnf
In this file, you can add the following configuration information (if you have any modifications)
[MySQL]
Default-character-set=utf8
[Mysqld]
Default-storage-engine=innodb
Character_set_server=utf8
3, copy Mysql.server to/etc/init.d/directory "purpose to achieve power-on automatic execution effect"
Execute command: CP mysql.server/etc/init.d/mysql (MySQL is the service name)
4. Modify/etc/init.d/mysql Parameters
Vi/etc/init.d/mysql
Given with 2 directory locations
Basedir=/usr/local/mysql
Datadir=/usr/local/mysql/data
Step three: Create a MySQL user
Create a dedicated user of the operational database for security convenience
1), Groupadd MySQL #建立一个mysql的组
2), Useradd-r-G MySQL MySQL #建立mysql用户, and put the user into the MySQL group
3), passwd MySQL #给mysql用户设置一个密码
4), to the directory/usr/local/mysql change owner Chown-r mysql:mysql/usr/local/mysql/
Attached: Permanently delete user account
Userdel Peter
Groupdel Peter
Usermod–g Peter Peter (Force delete all files and subdirectories in the user's home directory and home directory)
Fourth step: Initializing the MySQL database
First go to the bin directory of MySQL
1. Initialization
./mysqld--initialize--user=mysql--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data
Generate a data directory that represents the successful initialization of the database
and the root user of MySQL generates a temporary password: sbbe=g.a*3g+ (it is better to record this temporary password first)
2. Encrypt the database
./mysql_ssl_rsa_setup--datadir=/usr/local/mysql/data
3. Start MySQL (in order to keep the process card master, you can add & for this process to run in the background after starting the MySQL command)
./mysqld_safe--user=mysql &
4. Check Ps-ef|grep MySQL
The discovery of the above process represents a successful start.
Fifth Step: Enter the client
1. Login./mysql-uroot-p Enter the temporary password before entering
2. Change the password
Set Password=password (' New password ');
Sixth step: Set up remote access
1, the firewall must be configured before remote access Systemctl stop Firewalld.service (not recommended, configurable open 3306 port)
2, Authorization
Mysql>grantall Privileges On * * To remote Access user name @ '% ' identified by ' user password ';
Mysql>select host,user from user; "1 more Telnet user records"
Mysql>flush privileges; (refresh)
Access at this time using a remote machine
Resolution: Remote access with MYSQL-H host Ip-u user name-p password
Seventh step: Set boot from start
1. Add service MySQL
Chkconfig--add MySQL or "Mysqld-install"
2. Set up MySQL service for automatic
Chkconfig MySQL on
3. Restart the viewing process
Init 6
Ps-ef|grep MySQL
Eighth Step: Configure environment variables
For ease of operation, it is necessary to configure environment variables.
Vi/etc/profile
Export path= $JAVA _home/bin:/usr/local/mysql/bin: $PATH
Exportpath= $PATH:/bin:/usr/local/mysql/bin
Summary: To this step basic configuration is complete.
Original: http://www.cnblogs.com/1016882435AIDA/p/6265759.html
Linux installation MySQL