os: ubuntu 16.04
db: mysql 5.7.25
参考 os 设置blog
下载 mysql apt 源 https://dev.mysql.com/downloads/repo/apt/
# rz
# ls -l
-rw-r--r-- 1 root root 36306 Feb 25 08:46 mysql-apt-config_0.8.12-1_all.deb
# apt install ./mysql-apt-config_0.8.12-1_all.deb
Selecting previously unselected package mysql-apt-config.
(Reading database ... 63656 files and directories currently installed.)
Preparing to unpack .../mysql-apt-config_0.8.12-1_all.deb ...
Unpacking mysql-apt-config (0.8.12-1) ...
Setting up mysql-apt-config (0.8.12-1) ...
OK
中间会出现选择 mysql 版本的提示,选择 mysql 5.7 ,另外两个选择 enable 即可.
查看安装后的信息
# dpkg -l |grep -i mysql
ii mysql-apt-config 0.8.12-1 all Auto configuration for MySQL APT Repo.
# dpkg -L mysql-apt-config
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/mysql-apt-config
/usr/share/doc/mysql-apt-config/changelog.Debian.gz
/usr/share/doc/mysql-apt-config/copyright
/usr/share/doc/mysql-apt-config/README
/usr/share/doc/mysql-apt-config/COPYING.gz
# ls -l /etc/apt/sources.list.d/
total 4
-rw-r--r-- 1 root root 499 Feb 25 08:48 mysql.list
# cat /etc/apt/sources.list.d/mysql.list
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out entries below, but any other modifications may be lost.
# Use command 'dpkg-reconfigure mysql-apt-config' as root for modifications.
deb http://repo.mysql.com/apt/ubuntu/ xenial mysql-apt-config
deb http://repo.mysql.com/apt/ubuntu/ xenial mysql-5.7
deb http://repo.mysql.com/apt/ubuntu/ xenial mysql-tools
deb http://repo.mysql.com/apt/ubuntu/ xenial mysql-tools-preview
deb-src http://repo.mysql.com/apt/ubuntu/ xenial mysql-5.7
# apt update
# dpkg -l |grep -i mysql
ii mysql-apt-config 0.8.12-1 all Auto configuration for MySQL APT Repo.
# apt install mysql-client mysql-server libmysqlclient-dev libmysqlclient20 libmysqld-dev
安装中间需要输入 root 密码.
# dpkg -l |grep -i mysql
ii libmysqlclient-dev 5.7.25-1ubuntu16.04 amd64 MySQL development headers
ii libmysqlclient20:amd64 5.7.25-1ubuntu16.04 amd64 MySQL shared client libraries
ii libmysqld-dev 5.7.25-1ubuntu16.04 amd64 MySQL embedded server library
ii mysql-apt-config 0.8.12-1 all Auto configuration for MySQL APT Repo.
ii mysql-client 5.7.25-1ubuntu16.04 amd64 MySQL Client meta package depending on latest version
ii mysql-common 5.7.25-1ubuntu16.04 amd64 MySQL Common
ii mysql-community-client 5.7.25-1ubuntu16.04 amd64 MySQL Client
ii mysql-community-server 5.7.25-1ubuntu16.04 amd64 MySQL Server
ii mysql-server 5.7.25-1ubuntu16.04 amd64 MySQL Server meta package depending on latest version
# ps -ef|grep -i mysql |grep -v grep
mysql 3734 1 0 09:46 ? 00:00:00 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
# netstat -lntp |grep -i 3306
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 3734/mysqld
# systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2019-02-25 09:46:42 CST; 3min 56s ago
Main PID: 3734 (mysqld)
CGroup: /system.slice/mysql.service
└─3734 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
Feb 25 09:46:40 node1 systemd[1]: Starting MySQL Community Server...
Feb 25 09:46:42 node1 systemd[1]: Started MySQL Community Server.
# ls -l /etc/mysql/
total 16
drwxr-xr-x 2 root root 4096 Feb 25 09:46 conf.d
lrwxrwxrwx 1 root root 24 Feb 25 09:46 my.cnf -> /etc/alternatives/my.cnf
-rw-r--r-- 1 root root 1050 Dec 21 18:54 my.cnf.fallback
-rw-r--r-- 1 root root 796 Dec 21 18:54 mysql.cnf
drwxr-xr-x 2 root root 4096 Feb 25 09:46 mysql.conf.d
# ls -l /etc/mysql/my.cnf
lrwxrwxrwx 1 root root 24 Feb 25 09:46 /etc/mysql/my.cnf -> /etc/alternatives/my.cnf
# ls -l /etc/alternatives/my.cnf
lrwxrwxrwx 1 root root 20 Feb 25 09:46 /etc/alternatives/my.cnf -> /etc/mysql/mysql.cnf
/etc/mysql/my.cnf 和 /etc/mysql/mysql.cnf 这两个文件有点意思.
# mysql -h 127.0.0.1 -P 3306 -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.25 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, 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> select current_user,now();
+----------------+---------------------+
| current_user | now() |
+----------------+---------------------+
| root@localhost | 2019-02-25 10:28:32 |
+----------------+---------------------+
1 row in set (0.00 sec)
使用 apt 方式
参考:
https://dev.mysql.com/downloads/repo/apt/
mysql 5.7 的 .deb ,这些包的说明可以 参考 https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/
# apt list |grep -i mysql|grep -i 5.7
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
diaspora-installer-mysql/xenial,xenial 0.5.7.1+debian2 all
libmysqlclient-dev/unknown 5.7.25-1ubuntu16.04 amd64
libmysqlclient20/unknown 5.7.25-1ubuntu16.04 amd64
libmysqlclient20-dbgsym/unknown 5.7.25-1ubuntu16.04 amd64
libmysqld-dev/unknown 5.7.25-1ubuntu16.04 amd64
mysql-client/unknown,now 5.7.25-1ubuntu16.04 amd64 [installed]
mysql-client-5.7/xenial-updates,xenial-security 5.7.25-0ubuntu0.16.04.2 amd64
mysql-client-core-5.7/xenial-updates,xenial-security 5.7.25-0ubuntu0.16.04.2 amd64
mysql-common/unknown,now 5.7.25-1ubuntu16.04 amd64 [installed,automatic]
mysql-community-client/unknown,now 5.7.25-1ubuntu16.04 amd64 [installed,automatic]
mysql-community-client-dbgsym/unknown 5.7.25-1ubuntu16.04 amd64
mysql-community-server/unknown,now 5.7.25-1ubuntu16.04 amd64 [installed,automatic]
mysql-community-server-dbgsym/unknown 5.7.25-1ubuntu16.04 amd64
mysql-community-source/unknown 5.7.25-1ubuntu16.04 amd64
mysql-community-test/unknown 5.7.25-1ubuntu16.04 amd64
mysql-community-test-dbgsym/unknown 5.7.25-1ubuntu16.04 amd64
mysql-server/unknown,now 5.7.25-1ubuntu16.04 amd64 [installed]
mysql-server-5.7/xenial-updates,xenial-security 5.7.25-0ubuntu0.16.04.2 amd64
mysql-server-core-5.7/xenial-updates,xenial-security 5.7.25-0ubuntu0.16.04.2 amd64
mysql-source-5.7/xenial-updates,xenial-security 5.7.25-0ubuntu0.16.04.2 amd64
mysql-testsuite/unknown 5.7.25-1ubuntu16.04 amd64
mysql-testsuite-5.7/xenial-updates,xenial-security 5.7.25-0ubuntu0.16.04.2 amd64
pinba-engine-mysql-5.7/xenial-updates,xenial-security 1.1.0-1ubuntu1.11 amd64