Ubuntu 怎么安装mysql5.7

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ubuntu 怎么安装mysql5.7相关的知识,希望对你有一定的参考价值。

先安装好操作系统   在mysql官网上下载最新版的Ubuntu Linux专用的Mysql。我这里下载的是:mysql-server_5.7.11-1ubuntu14.04_amd64.deb-bundle.tar。   解压文件 命令为:tar -xvf mysql-server_5.7.11-1ubuntu14.04_amd64.deb-bundle.tar.   解压开来后,一共有11个deb包,用sudo dpkg -i [包名]命令逐个安装,因为包与包中间存在依赖关系,这里安装有个先后顺序。   我的安装的顺序是:   1.mysql-common_5.7.11-1ubuntu14.04_amd64.deb   2.libmysqlclient20_5.7.11-1ubuntu14.04_amd64.deb   3.libmysqlclient-dev_5.7.11-1ubuntu14.04_amd64.deb   4.libmysqld-dev_5.7.11-1ubuntu14.04_amd64.deb   5而后需要安装一个依赖包叫libaio1,命令为sudo apt-get intall libaio1;   而后继续:   5.mysql-community-client_5.7.11-1ubuntu14.04_amd64.deb   6.mysql-client_5.7.11-1ubuntu14.04_amd64.deb   7.mysql-community-source_5.7.11-1ubuntu14.04_amd64.deb   6   这里需要再安装一个依赖包叫libmecab2,安装好后,继续安装最后一个:   8.mysql-community-server_5.7.11-1ubuntu14.04_amd64.deb   安装过程中需要设置数据库密码。   到这里,所有的已经安装完毕。输入Mysql -uroot-p可以登陆数据库了。 参考技术A   sudo apt-get update
sudo apt-get upgrade
apt-get install libaio1
(apt-get install mysql-server mysql-client自动安装会装上5.5)

sudo groupadd mysql
sudo useradd -r -g mysql mysql

cd /usr/local/src
sudo wget mysql-server_5.7.6-m16-1ubuntu12.04_amd64.deb-bundle.tar http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-server_5.7.6-m16-1ubuntu12.04_amd64.deb-bundle.tar

sudo tar -xvf mysql-server_5.7.6-m16-1ubuntu12.04_amd64.deb-bundle.tar
sudo dpkg -i mysql-common_5.7.6-m16-1ubuntu12.04_amd64.deb
sudo dpkg-preconfigure mysql-community-server_5.7.6-m16-1ubuntu12.04_amd64.deb
这一步骤会提示让你输入root密码,后期可改,随便输个。
sudo dpkg -i mysql-community-server_5.7.6-m16-1ubuntu12.04_amd64.deb
sudo dpkg -i mysql-community-client_5.7.6-m16-1ubuntu12.04_amd64.deb
sudo dpkg -i libmysqlclient20_5.7.6-m16-1ubuntu12.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 password

登录
sudo /usr/bin/mysql -u root -p [可选数据库名称]
远程连接

GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.10.40.54' IDENTIFIED BY '123456' WITH GRANT OPTION;

远程连接某表 : 创建username用户,可远程访问app数据库下user表,具有读、更新权限

grant select,update on app.user to username@‘%’ identified by '123456';

open_files_limit = 10240
back_log = 258
max_connections = 5000
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,说明配置已生效
参考技术B sudo apt-get update
sudo apt-get upgrade
apt-get install libaio1
(apt-get install mysql-server mysql-client自动安装会装上5.5)

sudo groupadd mysql
sudo useradd -r -g mysql mysql

cd /usr/local/src
sudo wget mysql-server_5.7.6-m16-1ubuntu12.04_amd64.deb-bundle.tar http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-server_5.7.6-m16-1ubuntu12.04_amd64.deb-bundle.tar

sudo tar -xvf mysql-server_5.7.6-m16-1ubuntu12.04_amd64.deb-bundle.tar
sudo dpkg -i mysql-common_5.7.6-m16-1ubuntu12.04_amd64.deb
sudo dpkg-preconfigure mysql-community-server_5.7.6-m16-1ubuntu12.04_amd64.deb
这一步骤会提示让你输入root密码,后期可改,随便输个。
sudo dpkg -i mysql-community-server_5.7.6-m16-1ubuntu12.04_amd64.deb
sudo dpkg -i mysql-community-client_5.7.6-m16-1ubuntu12.04_amd64.deb
sudo dpkg -i libmysqlclient20_5.7.6-m16-1ubuntu12.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 password

登录
sudo /usr/bin/mysql -u root -p [可选数据库名称]
远程连接

GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.10.40.54' IDENTIFIED BY '123456' WITH GRANT OPTION;

远程连接某表 : 创建username用户,可远程访问app数据库下user表,具有读、更新权限

grant select,update on app.user to username@‘%’ identified by '123456';

open_files_limit = 10240
back_log = 258
max_connections = 5000
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,说明配置已生效

Ubuntu 怎么安装mysql5.7

参考技术A sudo apt-get update
sudo apt-get upgrade
apt-get install libaio1
(apt-get install mysql-server mysql-client自动安装会装上5.5)

sudo groupadd mysql
sudo useradd -r -g mysql mysql

cd /usr/local/src
sudo wget mysql-server_5.7.6-m16-1ubuntu12.04_amd64.deb-bundle.tar http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-server_5.7.6-m16-1ubuntu12.04_amd64.deb-bundle.tar

sudo tar -xvf mysql-server_5.7.6-m16-1ubuntu12.04_amd64.deb-bundle.tar
sudo dpkg -i mysql-common_5.7.6-m16-1ubuntu12.04_amd64.deb
sudo dpkg-preconfigure mysql-community-server_5.7.6-m16-1ubuntu12.04_amd64.deb
这一步骤会提示让你输入root密码,后期可改,随便输个。
sudo dpkg -i mysql-community-server_5.7.6-m16-1ubuntu12.04_amd64.deb
sudo dpkg -i mysql-community-client_5.7.6-m16-1ubuntu12.04_amd64.deb
sudo dpkg -i libmysqlclient20_5.7.6-m16-1ubuntu12.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 password

登录
sudo /usr/bin/mysql -u root -p [可选数据库名称]
远程连接

GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.10.40.54' IDENTIFIED BY '123456' WITH GRANT OPTION;

远程连接某表 : 创建username用户,可远程访问app数据库下user表,具有读、更新权限

grant select,update on app.user to username@‘%’ identified by '123456';

open_files_limit = 10240
back_log = 258
max_connections = 5000
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,说明配置已生效

以上是关于Ubuntu 怎么安装mysql5.7的主要内容,如果未能解决你的问题,请参考以下文章

Ubuntu 怎么安装mysql5.7

ubuntu18.04 安装的mysql5.7怎么找不到库啊?

Unbuntu18.04通过apt源方式安装mysql5.7.22

centos7源码安装mysql5.7怎么卸载

Ubuntu18.04安装、卸载MySQL

ubuntu16全程安装mysql5.7.15!