1, need Mysql-linux installation package
This time use mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz to install
2. Upload this installation package to a Linux server
The upload path is:/usr/local
3. Unzip MySQL
input command:tar zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
4, copy the MySQL into the/usr/local/mysql folder (Note mysql-5.7.17-linux-glibc2.5-x86_64 This folder name will not change, after copying the paste will be renamed to MySQL)
Input command: CP mysql-5.7.17-linux-glibc2.5-x86_64/usr/local/mysql-r
5. Add System MySQL group and MySQL user
Input command: Groupadd MySQL and useradd-r-g MySQL MySQL
6. Go to install MySQL software directory: Execute command
Input command: Cd/usr/local/mysql
7. Modify the current directory owner for MySQL User: Execute command
Input command: Chown-r mysql:mysql./
8. It is important to create a folder before installing the database
Input command: Mkdir/usr/local/mysql/data
9. Install Database: Execute command
mysql5.7 and previous versions, a lot of information is this command:. /scripts/mysql_install_db--user=mysql, while mysql5.7 's mysql_install_db command is in the bin directory and is recommended with the Mysqld--initialize command
mysql5.7 before version Initialization configuration Table command:
Input command:./bin/mysql_install_db--user=mysql--basedir=/usr/local/mysql/--datadir=/usr/local/mysql/data/
Later versions:
Input command:./bin/mysqld--initialize--user=mysql--basedir=/usr/local/mysql/--datadir=/usr/local/mysql/data/
If it appears ./mysqld:error while loading shared libraries:libnuma.so.1:cannot open Shared object file:no such file or dir Ectory's error;
is a lack of libnuma dependency. We can solve this problem by installing Yum install-y Libnuma
10. Copy the configuration file to/etc/my.cnf
Input command: cp-a./SUPPORT-FILES/MY-DEFAULT.CNF/ETC/MY.CNF (select y)
11. The MySQL service script is placed in the system service, then modifies the my.cnf file
Input command: cp-a./support-files/mysql.server/etc/init.d/mysqld
Edit File : vi/etc/my.cnf
Modify MY.CNF file (vi/etc/my.cnf) # These is commonly set, remove the # and set as required. Basedir =/usr/local/mysql datadir =/usr/local/mysql/data port = 3306 # server_id = ... .. Socket =/tmp/mysql.sock character-set-server = UTF8 # Remove leading # To set options mainly useful for Reporti ng servers. # The server defaults is faster for transactions and fast selects. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M
12. Start MySQL
input command: service mysqld start
13, check the MySQL initial password (remember and copy it, etc will log on to MySQL needs)
input command: Cat/root/.mysql_secret
14. Enter Mysql:bin/mysql-uroot-p (paste the password just copied up)
15. Reset Root Password after login
mysql> SET PASSWORD for ' root ' @localhost = PASSWORD (' 123456 ');
Query OK, 0 rows affected, 1 Warning (0.00 sec)
16, modify the Linux firewall port, development 3306 for external access, edit iptables
input command: vi/etc/sysconfig/iptables
Add a sentence:-a input-p tcp-m tcp--dport 3306-j ACCEPT
17. Modify the MySQL configuration to allow external access:
input Command : Cd/usr/local/mysql/bin
Log in to MySQL database command:./mysql-uroot-p123456
Mysql>use MySQL;
Mysql>update User Set host = '% ' where user = ' root ';
18. Restart the firewall and restart the MySQL database
input command: service iptables Restart Restart firewall
input command: service mysqld Restart re-mysql
19. Set up MySQL Boot
Check to see if MySQL is booting up
# chkconfig--list | grep mysqld
Set boot up
# Chkconfig Mysqld on
Linux (CentOS) installation MySQL database