树莓派3b+安装ubuntu server,安装mysql

本文档详细介绍了如何在树莓派上安装Ubuntu Server 18.04,创建并启用root用户,允许SSH远程登录,更换软件源为清华大学镜像,并安装及配置MySQL数据库,包括安全设置和远程访问权限的赋予。

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

1、[下载镜像]
http://cdimage.ubuntu.com/ubuntu/releases/18.04.5/release/ubuntu-18.04.5-preinstalled-server-arm64+raspi3.img.xz
2、解压
3、把镜像写入tf卡,插入树莓派
4、登录,初始账户及密码
用户名:ubuntu
密码:ubuntu
初次登陆修改密码
Ubuntu server安装成功
5、添加root用户
输入命令sudo passwd 给root用户设置密码
输入su命令,切换至root用户
6、root用户不允许远程登陆,修改一下令root 允许ssh远程登录

sudo vim /etc/ssh/sshd_config

找到PermitRootLogin without-password 修改为PermitRootLogin yes 或者直接添加PermitRootLogin yes
7、service ssh restart 重启ssh,用ssh工具登录
8、修改默认源

先备份/etc/apt/sources.list,

cd /etc/apt/
cp sources.list sources.list.d
vi /etc/apt/sources.list 

然后把sources.list里面的内容替换为:

## Note, this file is written by cloud-init on first boot of an instance
## modifications made here will not survive a re-bundle.
## if you wish to make changes you can:
## a.) add 'apt_preserve_sources_list: true' to /etc/cloud/cloud.cfg
##     or do the same in user-data
## b.) add sources in /etc/apt/sources.list.d
## c.) make changes to template file /etc/cloud/templates/sources.list.tmpl
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic main restricted
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-updates main restricted
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic universe
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic universe
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-updates universe
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-updates multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-backports main restricted universe multiverse
 
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-security main restricted
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-security main restricted
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-security universe
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-security universe
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-security multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-security multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu bionic partner
# deb-src http://archive.canonical.com/ubuntu bionic partner
 

更新

sudo apt-get update
sudo apt-get upgrate

9、安装mysql

sudo apt install mysql-server

10、配置mysql

mysql_secure_installation
root@ubuntu-virtual-machine:~# mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?    # 要安装验证密码插件吗?

Press y|Y for Yes, any other key for No: N    # 这里我选择N
Please set the password for root here.

New password:   # 输入要为root管理员设置的数据库密码

Re-enter new password:   # 再次输入密码


By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y     # 删除匿名账户
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : N    # 禁止root管理员从远程登录,这里我没有禁止

... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y   # 删除test数据库并取消对它的访问权限
- Dropping test database...
Success.

- Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y   # 刷新授权表,让初始化后的设定立即生效
Success.

All done!

用mysql -u root -p命令,Enter password:处输入刚设置的密码,回车,就能够进入mysql数据库。

使用 use mysql; 命令打开mysql命名的数据库,显示当前数据库的表:show tables; 查询user表里的数据:select * from user;(user表里是mysql数据库的所有账户信息)
11、配置mysql允许远程访问
编辑 /etc/mysql/mysql.conf.d/mysqld.cnf 配置文件:

vim /etc/mysql/mysql.conf.d/mysqld.cnf

用# 注释掉bind-address = 127.0.0.1
在这里插入图片描述
保存,进入mysql授权

mysql -u root -p
mysql> grant all on *.* to root@'%' identified by '你的密码' with grant option;

mysql> flush privileges;    # 刷新权限

mysql> exit

重启mysql服务

systemctl restart mysql
<think>好的,我现在需要在ARM架构的Ubuntu系统上安装MySQL。用户之前提到他们使用的是ARM架构,比如可能是在树莓派或者M1/M2芯片的Mac上运行Ubuntu。根据提供的引用,我需要综合不同的安装方法,并考虑版本兼容性。 首先,用户引用了几个不同的方法,包括使用.deb包安装、apt-get安装、以及Docker安装。不过引用中提到MySQL 5.7在ARM下可能存在问题,而Docker方面暂时没有找到5.x的ARM镜像。用户可能更倾向于安装5.7版本,但需要确认是否支持。 根据引用[1]和[2],使用apt-get安装可能是直接的方法,但需要确认软件源中是否有ARM兼容的MySQL包。引用[1]提到使用dpkg安装特定的.deb包,但可能这个包是针对特定Ubuntu版本的。引用[4]提到用户可能更愿意使用5.7版本,而8.x官方支持可能更好,但用户偏好5.7。 我需要检查MySQL官方是否提供ARM架构的5.7版本。如果通过Ubuntu的仓库安装,可能需要运行sudo apt update后,使用sudo apt install mysql-server-5.7,但不确定是否有该包。另外,引用[2]中的安装步骤是通用的,可能适用于ARM,但需要验证。 另外,用户可能遇到依赖问题,比如需要安装libaio1等库。安装完成后,配置安全选项,比如运行mysql_secure_installation,设置root密码,移除匿名用户等步骤是必要的。 如果通过Docker安装,引用[3]提到MySQL 5.x的ARM镜像可能不可用,但8.x有支持。如果用户坚持使用5.7,可能需要使用其他方法,而Docker可能不是最佳选择。 总结可能的步骤:更新软件源,安装mysql-servermysql-client,处理可能的依赖问题,安装完成后进行安全配置。同时,注意检查服务状态,确保MySQL正确运行。 此外,用户可能需要知道如何验证安装是否成功,比如通过mysql --version或登录数据库。如果安装过程中出现错误,可能需要查看日志或解决依赖问题。 最后,生成相关问题,帮助用户进一步解决可能遇到的问题,比如连接问题、性能优化、备份等。</think>### 分步指南:ARM架构Ubuntu安装配置MySQL #### 一、安装MySQL服务端和客户端 1. **更新软件源** 在终端执行以下命令确保软件包列表最新: ```bash sudo apt update ``` 2. **安装MySQL服务端和客户端** ARM架构下推荐使用Ubuntu官方仓库的MySQL版本(若需安装MySQL 5.7,需确认仓库支持): ```bash sudo apt install mysql-server mysql-client libmysqlclient-dev ``` *如果提示找不到MySQL 5.7,可尝试添加第三方仓库或使用MySQL官方APT仓库[^2][^4]。* #### 二、初始化配置 1. **启动MySQL服务** 安装完成后自动启动服务,手动检查状态: ```bash sudo systemctl status mysql ``` 2. **运行安全配置脚本** 设置root密码、移除匿名用户等: ```bash sudo mysql_secure_installation ``` 3. **验证安装** 登录MySQL并查看版本: ```bash sudo mysql -u root -p SELECT VERSION(); ``` #### 三、处理常见问题 - **ARM架构兼容性** - 若安装失败,检查依赖项是否完整(如`libaio1`): ```bash sudo apt install libaio1 ``` - 若需使用Docker,MySQL 8.x可直接支持ARM架构[^3][^4]。 - **修改配置文件** 配置文件路径为`/etc/mysql/mysql.conf.d/mysqld.cnf`,可按需调整端口、绑定地址等。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值