System environment: ubuntu kylin 14.10, 64-bit system
mysql version: 5.7.14 community version
mysql download address: http://dev.mysql.com/downloads/mysql/, choose Linux - Generic, download 612.9M mysql-5.7. 14-linux-glibc2.5-x86_64.tar.gz
mysql official installation documentation: http://dev.mysql.com/doc/refman/5.7/en/binary-installation.html
1. Follow the official installation documentation , just some shell commands have been modified. For ubuntu, most commands need to add sudo in front
shell> sudo groupadd mysql shell> sudo useradd -r -g mysql -s /bin/false mysql shell> cd /usr/local shell> sudo tar -zxvf /path/to/mysql-VERSION-OS.tar.gz shell> sudo mv mysql-5.7.14-linux-glibc2.5-x86_64 mysql-5.7.14-linux-glibc2.5-x86_64-3306 #Rename the mysql directory shell> sudo ln -s mysql-5.7.14-linux-glibc2.5-x86_64-3306 mysql-3306 shell> cd mysql-3306 shell> sudo mkdir mysql-files shell> sudo chmod 750 mysql-files shell> sudo chown -R mysql:mysql . shell> sudo cp support-files/my-default.cnf ./my.cnf #copy一份my.cnf Then edit my.cnf, open basedir, datadir, port and other items, and configure as follows: basedir = /usr/local/mysql-3306 datadir = /usr/local/mysql-3306/data port = 3306 server_id = 11 Then start to initialize mysql on port 3306: shell> sudo bin/mysqld --defaults-file=/usr/local/mysql-3306/my.cnf --initialize --user=mysql 2016-07-29T15:38:48.896585Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2016-07-29T15:38:48.896672Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. 2016-07-29T15:38:48.896682Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set. 2016-07-29T15:38:50.498675Z 0 [Warning] InnoDB: New log files created, LSN=45790 2016-07-29T15:38:50.890849Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2016-07-29T15:38:51.062752Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 8c708a13-55a2-11e6-835e-a0481ced538c. 2016-07-29T15:38:51.088854Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2016-07-29T15:38:51.090179Z 1 [Note] A temporary password is generated for root@localhost: pJLwjf%q;1t) shell> sudo bin/mysql_ssl_rsa_setup --defaults-file=/usr/local/mysql-3306/my.cnf Generating a 2048 bit RSA private key .........+++ .......................+++ writing new private key to 'ca-key.pem' ----- Generating a 2048 bit RSA private key ..........+++ ..............................................................+++ writing new private key to 'server-key.pem' ----- Generating a 2048 bit RSA private key ................................................+++ ........................................+++ writing new private key to 'client-key.pem' ----- shell> sudo chown -R root . shell> sudo chown -R mysql data mysql-files shell> sudo bin/mysqld_safe --user=mysql & #Start mysql, run in the background # Next command is optional shell> cp support-files/mysql.server /etc/init.d/mysql.server
2. Start logging in to mysql for related operations
/usr/local/mysql-3306> bin/mysql -uroot -p
Note that when bin/mysqld is initialized, a temporary password is given in the last prompt of the command line, and you can log in after entering it.
After logging in to mysql, you are required to change the password immediately, otherwise you cannot perform any operations. Execute the following command to change the password of 'root'@'localhost':
mysql> SET PASSWORD = PASSWORD('your new password'); mysql> ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER; mysql> flush privileges;
In order to be able to log in remotely, add a 'root'@'%' account:
mysql> grant all privileges on *.* to 'root'@'%' identified by 'your new password' with grant option;
3. According to the above method, continue to decompress and install mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz, and configure it as 3307, 3308, 3309 ports, you can install multiple mysql.