Ubuntu 怎么安装mysql5.7

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 怎么安装mysql

在Linux Ubuntu中安装MySQL数据库

#安装MySQL服务器端
~ sudo apt-get install mysql-server

安装过程会弹出提示框,输入root用户的密码,我在这里设置密码为mysql。
安装完成后,MySQL服务器会自动启动,我们检查MySQL服务器程序

# 检查MySQL服务器系统进程
~ ps -aux|grep mysql
mysql 3205 2.0 0.5 549896 44092 ? Ssl 20:10 0:00 /usr/sbin/mysqld
conan 3360 0.0 0.0 11064 928 pts/0 S+ 20:10 0:00 grep --color=auto mysql

# 检查MySQL服务器占用端口
~ netstat -nlt|grep 3306
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN

# 通过启动命令检查MySQL服务器状态
~ sudo /etc/init.d/mysql status
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql status

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the status(8) utility, e.g. status mysql
mysql start/running, process 3205

# 通过系统服务命令检查MySQL服务器状态
~ service mysql status
mysql start/running, process 3205

3. 通过命令行客户端访问MySQL
安装MySQL服务器,会自动地一起安装MySQL命令行客户端程序。
在本机输入mysql命令就可以启动,客户端程序访问MySQL服务器。

~ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 42
Server version: 5.5.35-0ubuntu0.12.04.2 (Ubuntu)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

使用户名和密码,登陆服务器

~ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 37
Server version: 5.5.35-0ubuntu0.12.04.2 (Ubuntu)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
参考技术A 您好,请问您是想知道ubuntu 怎么安装mysql吗?

以上是关于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!