Ubuntu 使用tar包 安装及配置 mysql 5.7

本文详细介绍如何使用命令行工具安装MySQL数据库,并配置字符集为UTF-8。安装过程涉及使用sudo apt-get install 和 dpkg命令安装libaio1及MySQL相关组件,通过dpkg预配置MySQL服务器,设置root密码,以及安装必要的deb包。最后通过编辑my.cnf文件来更改MySQL的默认字符集。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

安装


  • 装更新软件

    sudo apt-get install libaio1

  • 配置

    sudo dpkg-preconfigure mysql-community-server_*.deb

在这一步会出现一个UI页面,让你输入数据库root账号的密码,你可以设置一个,也可以参考下边官方文档给的介绍

Important
Make sure you remember the root password you set. Users who want to set a password later can leave the password field blank in the dialogue box and just press OK; in that case, root access to the server is authenticated using the MySQL Socket Peer-Credential Authentication Plugin for connections using a Unix socket file. You can set the root password later using mysql_secure_installation.


  • 安装

sudo dpkg -i mysql-{common,community-client,client,community-server,server}_*.deb
sudo apt-get -f install

-

Here are where the files are installed on the system:
All configuration files (like my.cnf) are under /etc/mysql
All binaries, libraries, headers, etc., are under /usr/bin and /usr/sbin
The data directory is /var/lib/mysql

-

自己猜测,这里自动配置了很多,包括创建用户,设置目录,分配权限等等,这一步估计会自动生成一个mysql的用户,但是不知道这个mysql的用户的密码是多少,例如自动安装完成后,存放数据的目录是/var/lib/mysql,进入到/var/lib后,你使用ll 命令查看如下图,存放数据的目录mysql,所属的组是mysql用户的,但你还不知道密码,这个问题以后再去解决吧。
这里写图片描述

配置字符集


vi /etc/my.cnf【编辑配置文件,支持语言设置】

#

[client]
default-character-set=utf8

[mysqld]
character-set-server=utf8

[mysql]
default-character-set=utf8

#

service mysql stop【重新启动mysql服务】
service mysql start

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值