sudo apt-get update
sudo apt-get upgrade
apt-get install libaio1
(apt-get install mysql-server mysql-client自动安装会装上5.7)
sudo groupadd mysql
sudo useradd -r -g mysql mysql
cd /usr/local/src
sudo wget mysql-server_5.7.15-1ubuntu16.04_amd64.deb-bundle.tar
http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-server_5.7.15-1ubuntu16.04_amd64.deb-bundle.tar
sudo tar -xvf mysql-server_5.7.15-1ubuntu16.04_amd64.deb-bundle.tar
sudo dpkg -i mysql-common_5.7.15-1ubuntu16.04_amd64.deb
sudo dpkg-preconfigure mysql-community-server_5.7.15-1ubuntu16.04_amd64.deb
这一步骤会弹出一个界面,提示让你输入root密码
sudo dpkg -i mysql-client_5.7.15-1ubuntu16.04_amd64.deb (这个必须先安装,否则下面的安装会报错依赖缺失)
sudo dpkg -i mysql-community-client_5.7.15-1ubuntu16.04_amd64.deb
<这里需要注意:安装一个 libmecab2 这个是安装 mysql-community-server的依赖>
sudo apt-get install libmecab2
sudo dpkg -i mysql-community-server_5.7.15-1ubuntu16.04_amd64.deb
sudo dpkg -i libmysqlclient20_5.7.15-1ubuntu16.04_amd64.deb
cd /usr/local/
sudo ln -s /var/lib/mysql /usr/local/mysql
sudo mkdir /usr/local/mysql/data
sudo chown -R mysql. /usr/local/mysql/data
修改密码
sudo /usr/bin/mysqladmin -u root -p password [可选新密码(‘123456‘)]
(密码修改的两种方式,可参考 http://www.2cto.com/os/201412/358399.html)
登录
sudo /usr/bin/mysql -u root -p [可选数据库名称]
远程连接
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘192.168.186.128‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION; --这里的ip写你通过ssh访问linux的ip即可
设置所有mysql变量:如
set global max_connections=14000;
open_files_limit = 10240
back_log = 258
max_connections = 14000
max_connect_errors = 716
external-locking = FALSE
max_allowed_packet = 32M
sort_buffer_size = 8M
join_buffer_size = 1M
thread_cache_size = 300
query_cache_type=1
query_cache_size = 512M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
thread_stack = 192K
tmp_table_size = 258M
max_heap_table_size = 258M
key_buffer_size = 512M
read_buffer_size = 4M
read_rnd_buffer_size = 16M
wait_timeout=1814400
bulk_insert_buffer_size = 64M
innodb_buffer_pool_size = 8000M
innodb_buffer_pool_instances=32
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 16M
innodb_log_file_size = 2048M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_read_io_threads = 16
innodb_write_io_threads = 16
innodb_io_capacity = 20000
innodb_io_capacity_max = 40000
查看连接数
show variables like ‘%max_connections%‘
这时应该为5000,说明配置已生效