当前位置:   article > 正文

linux(ARM)架构下的mysql安装使用(完整版)_mysql arm版本

mysql arm版本

目录

一、安装MYSQL之前要先换源

二、安装MYSQL

1、安装

2、安装完成

3、安装后无法登陆

3.1 原因

3.2 登陆后切换database

3.3 修改密码(注意这里账号和密码是双引号)

3.4查看一下用户

3.5 然后进行刷新使得配置生效

3.6 退出

3.7 重启

三、mysql使用测试


一、安装MYSQL之前要先换源

1.备份系统之前的源,也可以不备份,将之前的源注释掉

cp /etc/apt/sources.list /etc/apt/sources.list.bak

2.修改源文件/etc/apt/sources.list

vim /etc/apt/sources.list

将原来的内容删除,将下面的源内容粘贴上。

3.这里推荐比较好的两个国内源

3.1阿里源(arm64,速度快,推荐)

  1. deb http://mirrors.aliyun.com/ubuntu-ports/ xenial main
  2. deb-src http://mirrors.aliyun.com/ubuntu-ports/ xenial main
  3.  
  4. deb http://mirrors.aliyun.com/ubuntu-ports/ xenial-updates main
  5. deb-src http://mirrors.aliyun.com/ubuntu-ports/ xenial-updates main
  6.  
  7. deb http://mirrors.aliyun.com/ubuntu-ports/ xenial universe
  8. deb-src http://mirrors.aliyun.com/ubuntu-ports/ xenial universe
  9. deb http://mirrors.aliyun.com/ubuntu-ports/ xenial-updates universe
  10. deb-src http://mirrors.aliyun.com/ubuntu-ports/ xenial-updates universe
  11.  
  12. deb http://mirrors.aliyun.com/ubuntu-ports/ xenial-security main
  13. deb-src http://mirrors.aliyun.com/ubuntu-ports/ xenial-security main
  14. deb http://mirrors.aliyun.com/ubuntu-ports/ xenial-security universe
  15. deb-src http://mirrors.aliyun.com/ubuntu-ports/ xenial-security universe

3.2 华为源(arm64,速度快,二者选其一)

  1. deb https://repo.huaweicloud.com/ubuntu-ports/ bionic main restricted universe multiverse
  2. deb-src https://repo.huaweicloud.com/ubuntu-ports/ bionic main restricted universe multiverse
  3.  
  4. deb https://repo.huaweicloud.com/ubuntu-ports/ bionic-security main restricted universe multiverse
  5. deb-src https://repo.huaweicloud.com/ubuntu-ports/ bionic-security main restricted universe multiverse
  6.  
  7. deb https://repo.huaweicloud.com/ubuntu-ports/ bionic-updates main restricted universe multiverse
  8. deb-src https://repo.huaweicloud.com/ubuntu-ports/ bionic-updates main restricted universe multiverse
  9.  
  10. deb https://repo.huaweicloud.com/ubuntu-ports/ bionic-backports main restricted universe multiverse
  11. deb-src https://repo.huaweicloud.com/ubuntu-ports/ bionic-backports main restricted universe multiverse
  12.  
  13. ## Not recommended
  14. # deb https://repo.huaweicloud.com/ubuntu-ports/ bionic-proposed main restricted universe multiverse
  15. # deb-src https://repo.huaweicloud.com/ubuntu-ports/ bionic-proposed main restricted universe multiverse

4.更新仓库

apt-get update

4.1处理报错

可能出现报错

由于没有公钥,无法验证下列签名...

以下命令解决:

sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 40976EAF437D05B5 3B4FE6ACC0B21F32

5.清除软件仓库缓存

apt-get clean

6.更新软件仓库

apt-get update

完成,可以安装MYSQL了

二、安装MYSQL

1、安装

  1. sudo apt-get install mysql-server //服务端
  2. sudo apt-get install mysql-client //客户端
  3. sudo apt-get install libmysqlclient-dev //程序编译时链接的库

2、安装完成

安装完成之后dpkg命令查看状态

dpkg -l | grep mysql

输出以下信息则安装成功

  1. ii mysql-client-5.7 5.7.39-0ubuntu0.18.04.2 arm64 MySQL database client binaries
  2. ii mysql-client-core-5.7 5.7.39-0ubuntu0.18.04.2 arm64 MySQL database core client binaries
  3. ii mysql-common 5.8+1.0.5 all MySQL database common files, e.g. /etc/mysql/my.cnf
  4. ii mysql-server 5.7.39-0ubuntu0.18.04.2 all MySQL database server (metapackage depending on the latest version)
  5. ii mysql-server-5.7 5.7.39-0ubuntu0.18.04.2 arm64 MySQL database server binaries and system database setup
  6. ii 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

显示如下说明启动成功:

  1. tcp6 0 0 :::3306 :::* LISTEN 27608/mysqld
  2. unix 2 [ ACC ] STREAM LISTENING 648125 27608/mysqld /var/run/mysqld/mysqld.sock
  3. unix 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>

3、安装后无法登陆

3.1 原因

原因一(大部分):

你是root安装的: 在本机命令行下输入: mysql -uroot 就可以直接登录,然后修改用户名密码啥的

原因二:

使用mysql -u root -p命令但是不知道root密码是因为之前没有设置,这个时候进行环境配置,设置root密码。

1、首先,进行忽略密码登陆,打开配置文件

sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf

2、在最后加入skip-grant-tables

  1. #
  2. # Read the manual, too, if you want chroot!
  3. # chroot = /var/lib/mysql/
  4. #
  5. # For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
  6. #
  7. # ssl-ca=/etc/mysql/cacert.pem
  8. # ssl-cert=/etc/mysql/server-cert.pem
  9. # ssl-key=/etc/mysql/server-key.pem
  10. skip-grant-tables
  11. -- 插入 --

3、保存退出

4、重启以下mysql服务

sudo service mysql stop

sudo service mysql start

5、重新登陆

mysql -u mysql

进行3.2步骤,所有步骤执行完注释掉skip-grant-tables

原因三:没有把之前的mysql卸载干净

彻底删除MySQL

在删除mysql前 须要先删除一下 /var/lib/mysql 还有 /etc/mysqlubuntu

先停止mysql服务

systemctl stop mysql

须要输入如下几条命令

  1. sudo rm /var/lib/mysql/ -R
  2. sudo rm /etc/mysql/ -R
  3. sudo apt-get autoremove mysql* --purge
  4. sudo apt-get remove apparmor

确保没有mysql的文件夹可忽略此步骤

sudo find / -name mysql

再次安装

  1. sudo apt-get install mysql-server //服务端
  2. sudo apt-get install mysql-client //客户端
  3. sudo apt-get install libmysqlclient-dev //程序编译时链接的库

3.2 登陆后切换database

登录

  1. ~$ sudo mysql -u root -p
  2. Enter password:

直接回车

  1. Welcome to the MySQL monitor. Commands end with ; or \g.
  2. Your MySQL connection id is 3
  3. Server version: 5.7.39-0ubuntu0.18.04.2 (Ubuntu)
  4. Copyright (c) 2000, 2022, Oracle and/or its affiliates.
  5. Oracle is a registered trademark of Oracle Corporation and/or its
  6. affiliates. Other names may be trademarks of their respective
  7. owners.
  8. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  9. mysql>

换为database

  1. mysql> use mysql;
  2. Reading table information for completion of table and column names
  3. You can turn off this feature to get a quicker startup with -A
  4. Database changed
  5. mysql>

3.3 修改密码(注意这里账号和密码是双引号)

  1. mysql> update user set authentication_string=PASSWORD("123456") where user="root";
  2. Query OK, 1 row affected, 1 warning (0.00 sec)
  3. Rows matched: 1 Changed: 1 Warnings: 1

3.4查看一下用户

select user,host from mysql.user;

出现以下信息则配置完成

  1. mysql> select user,host from mysql.user;
  2. +------------------+-----------+
  3. | user | host |
  4. +------------------+-----------+
  5. | debian-sys-maint | localhost |
  6. | mysql.session | localhost |
  7. | mysql.sys | localhost |
  8. | root | localhost |
  9. +------------------+-----------+
  10. 4 rows in set (0.00 sec)

3.5 然后进行刷新使得配置生效

flush privileges;

3.6 退出

quit

3.7 重启

sudo service mysql restart

三、mysql使用测试

1、建立一个数据库

  1. mysql> create database joyrun;
  2. Query OK, 1 row affected (0.00 sec)

2、查看当前数据库

  1. mysql> show databases;
  2. +--------------------+
  3. | Database |
  4. +--------------------+
  5. | information_schema |
  6. | joyrun |
  7. | mysql |
  8. | performance_schema |
  9. | sys |
  10. +--------------------+
  11. 5 rows in set (0.00 sec)

3、建立一个表

  1. mysql> use joyrun
  2. Database changed
  3. mysql> create table tbl_run(id int,name varchar(5),primary key (id));
  4. Query OK, 0 rows affected (0.01 sec)

4、查看表的结构

  1. mysql> desc tbl_run;
  2. +-------+------------+------+-----+---------+-------+
  3. | Field | Type | Null | Key | Default | Extra |
  4. +-------+------------+------+-----+---------+-------+
  5. | id | int(11) | NO | PRI | NULL | |
  6. | name | varchar(5) | YES | | NULL | |
  7. +-------+------------+------+-----+---------+-------+
  8. 2 rows in set (0.00 sec)

5、修改字节长度

  1. mysql> alter table tbl_run modify column name varchar(20);
  2. Query OK, 0 rows affected (0.01 sec)
  3. Records: 0 Duplicates: 0 Warnings: 0
  4. mysql> desc tbl_run;
  5. +-------+-------------+------+-----+---------+-------+
  6. | Field | Type | Null | Key | Default | Extra |
  7. +-------+-------------+------+-----+---------+-------+
  8. | id | int(11) | NO | PRI | NULL | |
  9. | name | varchar(20) | YES | | NULL | |
  10. +-------+-------------+------+-----+---------+-------+
  11. 2 rows in set (0.00 sec)

6、现在表中不能添加中文字段,修改字符集后才可以

  1. 修改库字符集:alter database joyrun character set utf8;
  2. 修改表字符集:alter table tbl_run character set utf8;
  3. 修改字段字符集:alter table tbl_run change name name varchar(20) character set utf8;

7、增加一条数据

  1. mysql> insert into tbl_run (id,name) values (1,'xiaoming');
  2. Query OK, 1 row affected (0.01 sec)
  3. mysql> select * from tbl_run;
  4. +----+----------+
  5. | id | name |
  6. +----+----------+
  7. | 1 | xiaoming |
  8. +----+----------+
  9. 1 row in set (0.00 sec)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/266953
推荐阅读
相关标签
  

闽ICP备14008679号