Since Linux and MySQL are installed differently due to different versions, please make sure that you have the same version as my Linux and MySQL versions before reading this guide.
If not, you can only refer to it.
My version:
Linux CentOS 6.5
MYSQL 5.7.18
Special reminder: MYSQ 5.7 and 5.6 in the way of installation is very different, so 5.6 of the students do not look at this strategy.
I. Preparation of the procedure
1. Enter https://dev.mysql.com/downloads/mysql/
Select Linux-generic, depending on whether the system is a 64-bit or 32-bit option to download the package. Both tar and tar.gz.
2. telnet to Linux using SECURECRT and get root privileges
Input:sudo su obtains the temporary root privileges of the current account.
3. Uploading a binary package from Windows to Linux
There are many ways to transfer Linux and Windows, and the 2 methods of FTP and RZSZ commands are mainstream. This article uses the RZ command upload (RZ command requires a remote connection to Linux using SECURECRT).
For detailed use of RZ please see: http://www.cnblogs.com/wangxiaoha/p/7059653.html
FTP Way Please yourself in the online search method, for focus theme, this article does not involve.
4. Package upload and move to:/usr/local/
Enter the following two commands
cd/usr/local
rz-be (large file must be added-be, otherwise it will be an error)
Pop-up dialog box, select MySQL binary package. Start uploading.
When the upload is complete, the path to the file should look like this:
/usr/local/mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
We need to unpack and compress the package.
The current directory is in/usr/local/
Enter the following command:
TAR-ZXVF mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
After the decompression, the following folder will be added, the folder is the MySQL running program
/usr/local/mysql-5.7.18-linux-glibc2.5-x86_64
For convenience, we changed the name of the folder to MySQL.
Current directory in/usr/local/
Input:
MV mysql-5.7.18-linux-glibc2.5-x86_64 MySQL
The modification is complete.
4. Create a new Folder
mkdir \usr\local\data\mysql
The basic work is ready for completion.
Ps:
1, why the majority of MySQL installation instructions will let us unpack the MySQL package, with the MV command to move to the/usr/local/, and then change the file name to MySQL, the individual superficial think there are two points. One is the conventional, if there is another account login or other programs need to find the path of MySQL program, with a conventional address is OK, no need to modify. Second, usr/local This folder belongs to the public folder of Linux, his permission is relatively open, basically has the root permission operation is open. However, if you put the program in other places, especially in personal folders, it is very likely that because of the various file permissions problems and abnormal constantly, greatly affecting learning efficiency. After the first scholar became the veteran, how do you play it?
2, why to create a \usr\local\data\mysql directory. This is required for MySQL because it requires you to specify a local data file to store the database. Our future data are stored in this folder, as well as table data.
Chapter II: Installation Configuration MySQL
1. Create a new user and user group in Linux
Sudu su
Root permission to create a MySQL user group
Groupadd MySQL
Create a MySQL user and belong to the MySQL user group
useradd-r-g MySQL MySQL
2. Assign an owner to a folder
cd/usr/local
chown-r MySQL mysql/ Assign the owner of the MySQL folder as a MySQL user
chgrp-r MySQL mysql/ assign all MySQL folder groups as MySQL user groups
3. New MySQL global configuration file
5.7.18 did not find the default configuration file. This finds a template on the Web:
# for advice The change settings see# http://dev.mysql.com/doc/refman/5.7/en/ server-configuration-defaults.html# * * * does not EDIT the this FILE. It's a template which'll be copied to the# * * * default location during install, and would be replaced if you# * * * Upgrade To a newer version of MySQL. [Mysqld]sql_mode=no_engine_substitution,strict_trans_tables # General configuration Options basedir =/usr/local/mysqldatadir =/usr/local/ Mysql/dataport = 3306socket =/var/run/mysqld/mysqld.sockcharacter-set-server=utf8
#下面是可选项, if there is a startup error, all commented out, retain the most basic configuration options, and then try to add some configuration items to start, detect the configuration item is wrong back_log = 300max_connections = 3000max_connect_ Errors = 50table_open_cache = 4096max_allowed_packet = 32m#binlog_cache_size = 4mmax_heap_table_size = 128Mread_rnd_ Buffer_size = 16msort_buffer_size = 16mjoin_buffer_size = 16mthread_cache_size = 16query_cache_size = 128Mquery_cache_ Limit = 4mft_min_word_len = 8thread_stack = 512ktransaction_isolation = Repeatable-readtmp_table_size = 128M#log-bin= Mysql-binlong_query_time = 6server_id=1innodb_buffer_pool_size = 1ginnodb_thread_concurrency = 16innodb_log_buffer_ Size = 16minnodb_log_file_size = 512minnodb_log_files_in_group = 3innodb_max_dirty_pages_pct = 90innodb_lock_wait_ Timeout = 120innodb_file_per_table = On[mysqldump]quickmax_allowed_packet = 32m[mysql] No-auto-rehashdefault-character-set=utf8safe-updates[myisamchk]key_buffer = 16msort_buffer_size = 16Mread_buffer = 8mwrite_buffer = 8m[mysqlhotcopy]interactive-timeout[mysqld_safe]open-files-limit = 8192[client]
paste the above text down, save as my.cnf, and through the RZ command or FTP upload to etc/my.cnf, you need to configure the following 4 lines.
Basedir =/usr/local/mysql MySQL program folder path datadir =/usr/local/data/mysql mysql Data folder path port = 3306 Database external access network port, general save Default 3306socket =/var/run/mysqld/mysqld.sock Socket connection execution file address
The above 3 lines are easy to understand and the 4th one is a little more troublesome. So far can be accounted for when ignoring it. Take a moment to deal with it
3. Initialize MySQL
Cd/usr/local/mysql/bin
./mysqld--initialize-insecure--user=mysql--basedir=/usr/local/mysql/--datadir=/usr/local/data/mysql
Initialize MySQL in an unsafe manner and specify that its owner user is MySQL. Insecure is not safe, in fact, there is no initial password (must be root permissions). For the general beginner, no password to many aspects.
If all goes well and the current account has/usr/local/data/mysql write access, the MySQL program will write to MySQL's own database in Data/mysql. Otherwise that would be an error.
4. Configuring the socket address and processing configuration file
Do you remember this line in the/etc/my.cnf file?
Socket =/var/run/mysqld/mysqld.sock
We now need to find Mysql.sock where this file was initialized by MySQL, enter the following command:
Find/-name ' Mysql.sock '
Find it in:
/var/lib/mysql/mysql.sock
So
socket =/var/run/mysql/mysql.sock
MY.CNF Configuration Complete
Before you start MySQL, you need a final step:
Mv/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld
Ps:
First, why copy the configuration file to the ETC folder. Because the ETC folder is the configuration file center of Linux, almost most of the configuration files are here. Like MySQL, which has a global service program, put here convenient for later use and operation.
second, why to give MySQL folder and files to specify a dedicated MySQL user, a word security. If MySQL is compromised, the hacker can only get access to the MySQL user and will not affect other systems.
Chapter III: Starting MySQL, completing the basic setup
1. Start MySQL
Cd/usr/local/mysql/bin
./mysqld_safe--user=mysql
/etc/init.d/mysqld Restart
2. Connect to MySQL
Cd/usr/local/mysql/bin
./mysql-uroot-p
Prompt for password, direct enter
Connection Successful!
3. Change the password
Get! Above.
Linux (CentOS 6.5) install MySQL 5.7.182 Binary Version Introduction