版本信息

ubuntu版本:16.04.1

mysql-server版本:5.7.23

安装

先查看一下apt可获取的mysql版本

ubuntu@VM-0-4-ubuntu:~$ apt search mysql

看到结果里面有这两个package,我们安装mysql-server就可以了,可以看到提供的mysql-server是5.7.23的。

mysql-client/xenial-security,xenial-security,xenial-updates,xenial-updates 5.7.23-0ubuntu0.16.04.1 all
MySQL database client (metapackage depending on the latest version) mysql-server/xenial-security,xenial-security,xenial-updates,xenial-updates 5.7.23-0ubuntu0.16.04.1 all
MySQL database server (metapackage depending on the latest version)

安装apt提供的mysql

sudo apt install mysql-server

开始安装,直接选Y就可以

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libaio1 libcgi-fast-perl libcgi-pm-perl libencode-locale-perl
libevent-core-2.0-5 libfcgi-perl libhtml-parser-perl libhtml-tagset-perl
libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl
liblwp-mediatypes-perl libtimedate-perl liburi-perl mysql-client-5.7
mysql-client-core-5.7 mysql-common mysql-server-5.7 mysql-server-core-5.7
Suggested packages:
libdata-dump-perl libipc-sharedcache-perl libwww-perl mailx tinyca
The following NEW packages will be installed:
libaio1 libcgi-fast-perl libcgi-pm-perl libencode-locale-perl
libevent-core-2.0-5 libfcgi-perl libhtml-parser-perl libhtml-tagset-perl
libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl
liblwp-mediatypes-perl libtimedate-perl liburi-perl mysql-client-5.7
mysql-client-core-5.7 mysql-common mysql-server mysql-server-5.7
mysql-server-core-5.7
0 upgraded, 21 newly installed, 0 to remove and 195 not upgraded.
Need to get 19.4 MB of archives.
After this operation, 162 MB of additional disk space will be used.
Do you want to continue? [Y/n]

安装的过程中会让你设置root用户的密码,设置一下,一会登录mysql会用到





检测一下是否安装成功

sudo netstat -tap | grep mysql

出现以下内容就是安装成功了

tcp        0      0 localhost.localdo:mysql *:*                     LISTEN      26647/mysqld

修改字符集

使用root用户和刚设置的密码登录mysql

mysql -u root -p

先看下未修改前的字符集

mysql> show variables like '%char%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

我们通过修改mysql的配置文件my.cnf(是mysql.conf的链接文件,直接改mysql.conf也行,没区别)来修改字符集。

配置文件的位置在/etc/mysql/my.cnf,用vim修改的时候前面要加sudo,因为非root用户没有这个文件的写权限。

sudo vim /etc/mysql/my.cnf

未修改前的配置文件应该长这个样子。

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html #
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
# !includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

在后面添加以下信息,设置mysql的字符集。

#[client]
#default-character-set=utf8
#影响系统变量character_set_client和character_set_connectioncharacter_set_results,所以[client]那部分设置不用添加
[mysqld]
character-set-server=utf8
#影响系统变量character_set_server和character_set_database,因为这两个系统变量默认是latin1,所以要添加

修改保存后重启mysql,记得加sudo,因为非root用户没有重启的权限。

sudo service mysql restart

然后再看下数据库的字符集,全改成了utf8。

mysql> show variables like '%char%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

ubuntu16.04.1下安装mysql的更多相关文章

  1. ubuntu16.04 LTS Server 安装mysql phpmyadmin apache2 php5.6环境

    1.安装apache sudo apt-get install apache2 为了测试apache2是否正常,访问http://localhost/或http://127.0.0.1/,出现It W ...

  2. ubuntu16.04.1下的mysql修改默认编码

    在Ubuntu 下配置 Mysql 的字符编码.安装完 Mysql 后,系统默认的字符编码是 latin1 ,输入的是中文,可是输出却是一堆乱码.现在要做的就是把 Mysql的默认字符编码设置为支持中 ...

  3. Ubuntu16.04 server下配置MySQL,并开启远程连接

    背景 最近正在学nodejs,想到曾经有台云服务器,但是很久不用了,由于怕麻烦,一股脑的把云主机重装了个Ubuntu系统,于是配置MySQL成了配置服务中的一个环节(node用不用MySQL不管,主要 ...

  4. ubuntu16.04环境下安装配置openface人脸识别程序

    参考http://blog.csdn.net/weixinhum/article/details/77046873 最近项目需要用到人脸训练和检测的东西,选用了OpenFace进行,因而有此文. 本人 ...

  5. ubuntu16.04 卸载及安装MySQL

    以MySQL- 5.7.18为例: sudo apt-get autoremove --purge mysql-server-5.7 #sudo apt-get remove mysql-server ...

  6. 腾讯云服务器ubuntu16.04系统下安装Python版本管理工具pyenv

    一. 系统环境   腾讯云提供的系统是ubuntu 16.04 LTS,系统默认的Python版本是2.7.12,我想要安装3.6和其他的版本.   比较方便的是腾讯云已经默认安装好了git和curl ...

  7. Ubuntu16.04 LTS 下安装 Android Studio 2.2.2 步骤

    下载 Android SDK,官网:www.android.com 我相信很多人跟我一样,进不去.Android Studio 中文官网 www.android-studio.org 进去下载, 在终 ...

  8. linux(ubuntu16.04)下安装和破解pycharm专业版

    我用的linux 版本是ubuntu,查看版本命令是: lsb_release -a 因为学习Python爬虫,pycharm是Python很好用的IDE,但是专业版需要付费,所以开始安装: 首先在官 ...

  9. Ubuntu16.04 Linux 下安装、配置SSH

    本人在Win7+VMware下利用两个ubuntu虚拟机安装.配置.测试了SSH. 在Server端安装openssh-server. sudo apt-get install ssh # 安装ssh ...

随机推荐

  1. Win10 打开 ubuntu子系统

    1. 修改windows的设置, 增加开发人员模式 针对开人员模式 使用添加删除程序 添加 ubuntu子系统的角色 运行输入control.. 然后添加删除程序 安装完后重启 运行输入 bash 就 ...

  2. 关于supervisor 的使用以及配置

    首先我个人认为,用python实现的supervisor使用了守护进程这个概念去实现一个包裹进程的概念. 他可以帮助你的进程完成失效重启,日志记录,确保在线,关机自启动等一系列的功能. 当使用supe ...

  3. Ubuntu 16.04 root环境变量不生效问题解决方案

    在Ubuntu 16.04中配置JDK环境变量,但是在切换到root时不生效 . 在/etc/profile中添加如下: export JAVA_HOME=/opt/java/jdk1..0_151 ...

  4. c-lodop云打印实现手机打印 JS语句打印

    Lodop和c-lodop目前只能安装到windows操作系统上,但是其他操作系统可通过向C-Lodop安装的电脑发送打印任务,实现手机广域网或局域网打印,打印语句也是简单的JS语句,可以轻松实现云打 ...

  5. P2209 [USACO13OPEN]燃油经济性Fuel Economy

    题面 sol:(思想):开一个大根堆和一个小根堆,每次计算到下了一个加油站用掉的油时尽量用小根堆中的元素,且同时删去大根堆中的相应位置的元素,当前加油站如果足够便宜,就可以把大根堆中的元素替换掉: ( ...

  6. Socket网络编程--Libev库学习(1)

    这一节是安装篇. Socket网络编程不知不觉已经学了快两个月了.现在是时候找个网络库学学了.搜索了很多关于如何学网络编程的博客和问答.大致都是推荐学一个网络库,至于C++网络库有那么几个,各有各的好 ...

  7. php-扩展模块查找下载网址

    http://pecl.php.net/ 在该网页里面输入想要查找的扩展模块名 如: 搜索结果:

  8. ceph API之PHP的客户端连接

    下载v2的SDK开发包http://pear.amazonwebservices.com/get/sdk-latest.zip 解压到目录下: unzip sdk-latest.zip &&a ...

  9. python 操作系统模块 -- OS

    os,语义为操作系统,模块提供了访问多个操作系统服务的功能,可以处理文件和目录这些我们日常手动需要做的操作.os和它的子模块os.path还包括一些用于检查.构造.删除目录和文件的函数,以及一些处理路 ...

  10. codeforces 1B Spreadsheets

    In the popular spreadsheets systems (for example, in Excel) the following numeration of columns is u ...