目录 一、安装MYSQL之前要先换源 二、安装MYSQL 1、安装 2、安装完成 3、安装后无法登陆 3.1 原因 3.2 登陆后切换database 3.3 修改密码(注意这里账号和密码是双引号) 3.4查看一下用户 3.5 然后进行刷新
目录
备份系统之前的源,也可以不备份,将之前的源注释掉
cp /etc/apt/sources.list /etc/apt/sources.list.bak
修改源文件/etc/apt/sources.list
vim /etc/apt/sources.list
将原来的内容删除,将下面的源内容粘贴上。
这里推荐比较好的两个国内源
1阿里源(arm64,速度快,推荐)
deb Http://mirrors.aliyun.com/ubuntu-ports/ xenial maindeb-src http://mirrors.aliyun.com/ubuntu-ports/ xenial main deb http://mirrors.aliyun.com/ubuntu-ports/ xenial-updates maindeb-src http://mirrors.aliyun.com/ubuntu-ports/ xenial-updates main deb http://mirrors.aliyun.com/ubuntu-ports/ xenial universedeb-src http://mirrors.aliyun.com/ubuntu-ports/ xenial universedeb http://mirrors.aliyun.com/ubuntu-ports/ xenial-updates universedeb-src http://mirrors.aliyun.com/ubuntu-ports/ xenial-updates universe deb http://mirrors.aliyun.com/ubuntu-ports/ xenial-security maindeb-src http://mirrors.aliyun.com/ubuntu-ports/ xenial-security maindeb http://mirrors.aliyun.com/ubuntu-ports/ xenial-security universedeb-src http://mirrors.aliyun.com/ubuntu-ports/ xenial-security universe
2 华为源(arm64,速度快,二者选其一)
deb https://repo.huaweicloud.com/ubuntu-ports/ bionic main restricted universe multiversedeb-src https://repo.huaweicloud.com/ubuntu-ports/ bionic main restricted universe multiverse deb https://repo.huaweicloud.com/ubuntu-ports/ bionic-security main restricted universe multiversedeb-src https://repo.huaweicloud.com/ubuntu-ports/ bionic-security main restricted universe multiverse deb https://repo.huaweicloud.com/ubuntu-ports/ bionic-updates main restricted universe multiversedeb-src https://repo.huaweicloud.com/ubuntu-ports/ bionic-updates main restricted universe multiverse deb https://repo.huaweicloud.com/ubuntu-ports/ bionic-backports main restricted universe multiversedeb-src https://repo.huaweicloud.com/ubuntu-ports/ bionic-backports main restricted universe multiverse ## Not recommended# deb https://repo.huaweicloud.com/ubuntu-ports/ bionic-proposed main restricted universe multiverse# deb-src https://repo.huaweicloud.com/ubuntu-ports/ bionic-proposed main restricted universe multiverse
更新仓库
apt-get update
1处理报错
可能出现报错
由于没有公钥,无法验证下列签名...
以下命令解决:
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 40976EAF437D05B5 3B4FE6ACC0B21F32
清除软件仓库缓存
apt-get clean
更新软件仓库
apt-get update
完成,可以安装mysql了
sudo apt-get install mysql-server //服务端sudo apt-get install mysql-client //客户端sudo apt-get install libmysqlclient-dev //程序编译时链接的库
安装完成之后dpkg命令查看状态
dpkg -l | grep mysql
输出以下信息则安装成功
ii mysql-client-5.7 5.7.39-0ubuntu0.18.04.2 arm64 MySQL database client binariesii mysql-client-core-5.7 5.7.39-0ubuntu0.18.04.2 arm64 MySQL database core client binariesii mysql-common 5.8+1.0.5 all MySQL database common files, e.g. /etc/mysql/my.cnfii mysql-server 5.7.39-0ubuntu0.18.04.2 all MySQL database server (metapackage depending on the latest version)ii mysql-server-5.7 5.7.39-0ubuntu0.18.04.2 arm64 MySQL database server binaries and system database setupii mysql-server-core-5.7 5.7.39-0ubuntu0.18.04.2 arm64 MySQL database server binaries
使用如下命令启动mysql
service mysql start
启动后使用如下命令查看状态
sudo netstat -anp | grep mysql
显示如下说明启动成功:
tcp6 0 0 :::3306 :::* LISTEN 27608/mysqld unix 2 [ ACC ] STREAM LISTENING 648125 27608/mysqld /var/run/mysqld/mysqld.sockunix 3 [ ] STREAM CONNECTED 648111 27608/mysqld
使用命令进行登陆
mysql -u root -p
输入密码,进行登陆,如果之前没有设置密码请看第3步
aaron@aaron-Raytine-PC:~$ mysql -u root -p
Enter passWord:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.7.30-0ubuntu0.18.04.1 (Ubuntu)
Copyright © 2000, 2020, 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>
原因一(大部分):
你是root安装的: 在本机命令行下输入: mysql -uroot 就可以直接登录,然后修改用户名密码啥的
原因二:
使用mysql -u root -p命令但是不知道root密码是因为之前没有设置,这个时候进行环境配置,设置root密码。
首先,进行忽略密码登陆,打开配置文件
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
在最后加入skip-grant-tables
## Read the manual, too, if you want chroot!# chroot = /var/lib/mysql/## For generating SSL certificates I recommend the OpenSSL GUI "tinyca".## ssl-ca=/etc/mysql/cacert.pem# ssl-cert=/etc/mysql/server-cert.pem# ssl-key=/etc/mysql/server-key.pemskip-grant-tables-- 插入 --
保存退出
重启以下mysql服务
sudo service mysql stop
sudo service mysql start
重新登陆
mysql -u mysql
进行3.2步骤,所有步骤执行完注释掉skip-grant-tables
原因三:没有把之前的mysql卸载干净
彻底删除MySQL
在删除mysql前 须要先删除一下 /var/lib/mysql 还有 /etc/mysqlubuntu
先停止mysql服务
systemctl stop mysql
须要输入如下几条命令
sudo rm /var/lib/mysql/ -R sudo rm /etc/mysql/ -Rsudo apt-get autoremove mysql* --purgesudo apt-get remove apparmor
确保没有mysql的文件夹可忽略此步骤
sudo find / -name mysql
再次安装
sudo apt-get install mysql-server //服务端sudo apt-get install mysql-client //客户端sudo apt-get install libmysqlclient-dev //程序编译时链接的库
登录
~$ sudo mysql -u root -pEnter password:
直接回车
Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.7.39-0ubuntu0.18.04.2 (Ubuntu)Copyright (c) 2000, 2022, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>
换为database
mysql> use mysql;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql>
mysql> update user set authentication_string=PASSWORD("123456") where user="root";Query OK, 1 row affected, 1 warning (0.00 sec)Rows matched: 1 Changed: 1 Warnings: 1
select user,host from mysql.user;
出现以下信息则配置完成
mysql> select user,host from mysql.user;+------------------+-----------+| user | host |+------------------+-----------+| debian-sys-maint | localhost || mysql.session | localhost || mysql.sys | localhost || root | localhost |+------------------+-----------+4 rows in set (0.00 sec)
flush privileges;
quit
sudo service mysql restart
建立一个数据库
mysql> create database joyrun;Query OK, 1 row affected (0.00 sec)
查看当前数据库
mysql> show databases;+--------------------+| Database |+--------------------+| infORMation_schema || joyrun || mysql || performance_schema || sys |+--------------------+5 rows in set (0.00 sec)
建立一个表
mysql> use joyrunDatabase changedmysql> create table tbl_run(id int,name varchar(5),primary key (id));Query OK, 0 rows affected (0.01 sec)
查看表的结构
mysql> desc tbl_run;+-------+------------+------+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |+-------+------------+------+-----+---------+-------+| id | int(11) | NO | PRI | NULL | || name | varchar(5) | YES | | NULL | |+-------+------------+------+-----+---------+-------+2 rows in set (0.00 sec)
修改字节长度
mysql> alter table tbl_run modify column name varchar(20);Query OK, 0 rows affected (0.01 sec)Records: 0 Duplicates: 0 Warnings: 0mysql> desc tbl_run;+-------+-------------+------+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |+-------+-------------+------+-----+---------+-------+| id | int(11) | NO | PRI | NULL | || name | varchar(20) | YES | | NULL | |+-------+-------------+------+-----+---------+-------+2 rows in set (0.00 sec)
现在表中不能添加中文字段,修改字符集后才可以
修改库字符集:alter database joyrun character set utf8;修改表字符集:alter table tbl_run character set utf8;修改字段字符集:alter table tbl_run change name name varchar(20) character set utf8;
增加一条数据
mysql> insert into tbl_run (id,name) values (1,'xiaoming');Query OK, 1 row affected (0.01 sec)mysql> select * from tbl_run;+----+----------+| id | name |+----+----------+| 1 | xiaoming |+----+----------+1 row in set (0.00 sec)
来源地址:https://blog.csdn.net/qq_43445867/article/details/126718980
--结束END--
本文标题: linux(ARM)架构下的mysql安装使用(完整版)
本文链接: https://www.lsjlt.com/news/384331.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0