1. 下载 mysql-5.7.20-linux-glibc2.12-x86_64.tar 地址 : https://dev.mysql.com/downloads/mysql/ 2. tar -xvf mysql-5.7.20-linux-glibc2.12-x86_64.tar 3. mv mysql-5.7.20-linux-glibc2.12-x86_64 mysql 4. groupadd mysql useradd -r -g mysql -s /bin/false mysql cd /usr/local/mysql 5. bin/mysqld --initialize --user=mysql //这个命令执行完之后会出现默认密码,请记录下来 6. 编辑 /etc/my.cnf [mysqld] port = 3306 socket = /tmp/mysql.sock datadir = /usr/local/mysql/data skip-external-locking key_buffer_size = 16M max_allowed_packet = 1M table_open_cache = 64 sort_buffer_size = 512K net_buffer_length = 8K read_buffer_size = 256K read_rnd