First, download
Here I created a directory software to store the MySQL package that we will download later, go to the directory first
Command: Cd/software
Command: wget Http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar
After the download is complete, you will see a file with the empty color box in the software directory.
Second, the establishment of users, as well as the MySQL directory
1, Groupadd MySQL #建立一个mysql的组
2, Useradd-r-g MySQL MySQL #建立mysql用户, and put the user into the MySQL group
3, passwd MySQL #给mysql用户设置一个密码
Third, decompression MySQL
1. Move the tar package to the/usr/local directory
Mv/software/mysql-5.7.17-linux-glibc2.5-x86_64.tar/usr/local
2. Decompression
Cd/usr/local
Tar xvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
Tar zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
"Multi-Out directory mysql-5.7.17-linux-glibc2.5-x86_64"
Note: There is no data directory, My.ini in the Support-files directory
3. Change the directory name to/usr/local/mysql (the default installation directory for MySQL under Linux)
MV Mysql-5.7.17-linux-glibc2.5-x86_64 MySQL
Iv. configuration-related boot configuration files
1. Copy my-default.cnf to/ETC/MY.CNF (automatically read at mysqld startup)
CP MY-DEFAULT.CNF/ETC/MY.CNF
2, copy Mysql.server to/etc/init.d/directory "purpose to achieve mysqld-install such boot automatic execution effect"
"/etc/init.d/directory, equivalent to registry hkey_local_machine\system\controlset001\services Records there are those services"
CP Mysql.server/etc/init.d/mysql (MySQL is the service name)
3. 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
4, to the directory/usr/local/mysql change owner
Chown-r mysql:mysql/usr/local/mysql/
5, solve the garbled problem
Vi/etc/my.cnf
[MySQL]
Default-character-set=utf8
[Mysqld]
Default-storage-engine=innodb
Character_set_server=utf8
V. Initialize the MySQL database
mysql_install_db (old version of the procedure)
New version:
1. Initialization
Bin/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: 5!UIPDK>QMG?
2. Encrypt the database
Bin/mysql_ssl_rsa_setup--datadir=/usr/local/mysql/data
3. Start MySQL
Bin/mysqld_safe--user=mysql &
"Check Ps-ef|grep MySQL"
Vi. entering the client
1. Login./mysql-uroot-p
If the error message is:
Workaround: Delete the/tmp/mysql.sock.lock file
Command: Rm-f/tmp/mysql.sock.lock
2. Change the password
Set Password=password (' 123456 ');
Vii. remote access (that is, you can use Windows system to access the Linux system MySQL)
Let's look at the data structure first:
Now our Windows system is unable to access MySQL under the virtual machine under the Linux system because there is no permission
1. Authorization
Grant all privileges on * * to [email protected] '% ' identified by ' 123456 ';
Select Host,user from user; "1 more Telnet user records"
Flush privileges;
Now with Windows system access to my Linux system MySQL, you will find still inaccessible, that is because the firewall is not related
Command: mysql-h (IP address of your Linux system)-uroot-p123456
2. Shut down the firewall or open the port to the firewall
Systemctl Stop Firewalld.service
After successful access, the following:
Eight, set the boot automatically start
1. Add service MySQL
Chkconfig--add MySQL "Mysqld-install"
2. Set up MySQL service for automatic
Chkconfig MySQL on
3. Restart Check
Init 6
Ps-ef|grep MySQL
Nine, set path
Vi/etc/profile
Export path= $JAVA _home/bin:/usr/local/mysql/bin: $PATH
Install MySQL under Linux system