麒麟V10安装MySQL

麒麟V10安装MySQL

1、下载MySQL并上传到服务器上

MySQL下载地址
在这里插入图片描述

2、查看系统是否已安装Mariadb和MySQL,如果已存在那就卸载

# 查系统是否已经安装mariadb和mysql
[root@localhost mysql]# rpm -qa | grep mariadb
[root@localhost mysql]# rpm -qa | grep mysql
mysql-community-icu-data-files-8.0.28-1.el8.x86_64
mysql-community-client-plugins-8.0.28-1.el8.x86_64
mysql-community-libs-8.0.28-1.el8.x86_64
mysql-community-client-8.0.28-1.el8.x86_64
mysql-community-common-8.0.28-1.el8.x86_64
mysql-community-server-8.0.28-1.el8.x86_64
# 如果安装了就执行卸载操作
[root@localhost mysql]# rpm -e --nodeps mysql-community-icu-data-files-8.0.28-1.el8.x86_64
[root@localhost mysql]# rpm -e --nodeps  mysql-community-client-plugins-8.0.28-1.el8.x86_64
odeps  mysql-community-server-8.0.28-1.el8.x86_64[root@localhost mysql]# rpm -e --nodeps  mysql-community-libs-8.0.28-1.el8.x86_64
[root@localhost mysql]# rpm -e --nodeps  mysql-community-client-8.0.28-1.el8.x86_64
[root@localhost mysql]# rpm -e --nodeps  mysql-community-common-8.0.28-1.el8.x86_64
[root@localhost mysql]# rpm -e --nodeps  mysql-community-server-8.0.28-1.el8.x86_64
警告:/etc/my.cnf 已另存为 /etc/my.cnf.rpmsave
[root@localhost mysql]# rpm -qa | grep mysql

在这里插入图片描述

3、解压MySQL安装包并安装MySQL

# 进入存放mysql安装包的目录
[root@localhost mysql]# cd /usr/mysql8
# 解压MySQL压缩包
[root@localhost mysql8]# tar -xvf mysql-8.0.28-1.el8.x86_64.rpm-bundle.tar
mysql-community-client-8.0.28-1.el8.x86_64.rpm
mysql-community-client-debuginfo-8.0.28-1.el8.x86_64.rpm
mysql-community-client-plugins-8.0.28-1.el8.x86_64.rpm
mysql-community-client-plugins-debuginfo-8.0.28-1.el8.x86_64.rpm
mysql-community-common-8.0.28-1.el8.x86_64.rpm
mysql-community-debuginfo-8.0.28-1.el8.x86_64.rpm
mysql-community-debugsource-8.0.28-1.el8.x86_64.rpm
mysql-community-devel-8.0.28-1.el8.x86_64.rpm
mysql-community-icu-data-files-8.0.28-1.el8.x86_64.rpm
mysql-community-libs-8.0.28-1.el8.x86_64.rpm
mysql-community-libs-debuginfo-8.0.28-1.el8.x86_64.rpm
mysql-community-server-8.0.28-1.el8.x86_64.rpm
mysql-community-server-debug-8.0.28-1.el8.x86_64.rpm
mysql-community-server-debug-debuginfo-8.0.28-1.el8.x86_64.rpm
mysql-community-server-debuginfo-8.0.28-1.el8.x86_64.rpm
mysql-community-test-8.0.28-1.el8.x86_64.rpm
mysql-community-test-debuginfo-8.0.28-1.el8.x86_64.rpm
# 安装mysql
[root@localhost mysql8]# rpm -ivh mysql-community-common-8.0.28-1.el8.x86_64.rpm
警告:mysql-community-common-8.0.28-1.el8.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
Verifying...                          ################################# [100%]
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-common-8.0.28-1.e################################# [100%]
[root@localhost mysql8]# rpm -ivh mysql-community-client-plugins-8.0.28-1.el8.x86_64.rpm
警告:mysql-community-client-plugins-8.0.28-1.el8.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
Verifying...                          ################################# [100%]
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-client-plugins-8.################################# [100%]
[root@localhost mysql8]# rpm -ivh mysql-community-libs-8.0.28-1.el8.x86_64.rpm
警告:mysql-community-libs-8.0.28-1.el8.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
Verifying...                          ################################# [100%]
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-libs-8.0.28-1.el8################################# [100%]
[root@localhost mysql8]# rpm -ivh mysql-community-client-8.0.28-1.el8.x86_64.rpm
警告:mysql-community-client-8.0.28-1.el8.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
Verifying...                          ################################# [100%]
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-client-8.0.28-1.e################################# [100%]
[root@localhost mysql8]# rpm -ivh mysql-community-icu-data-files-8.0.28-1.el8.x86_64.rpm
警告:mysql-community-icu-data-files-8.0.28-1.el8.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
Verifying...                          ################################# [100%]
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-icu-data-files-8.################################# [100%]
[root@localhost mysql8]# rpm -ivh mysql-community-server-8.0.28-1.el8.x86_64.rpm
警告:mysql-community-server-8.0.28-1.el8.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
Verifying...                          ################################# [100%]
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-server-8.0.28-1.e################################# [100%]
/usr/lib/tmpfiles.d/firebird.conf:1: Line references path below legacy directory /var/run/, updating /var/run/firebird → /run/firebird; please update the tmpfiles.d/ drop-in file accordingly.
/usr/lib/tmpfiles.d/net-snmp.conf:1: Line references path below legacy directory /var/run/, updating /var/run/net-snmp → /run/net-snmp; please update the tmpfiles.d/ drop-in file accordingly.
/usr/lib/tmpfiles.d/slapd.conf:2: Line references path below legacy directory /var/run/, updating /var/run/openldap → /run/openldap; please update the tmpfiles.d/ drop-in file accordingly.
fchmod() of /run/wine failed: Read-only file system

在这里插入图片描述

4、编辑MySQL配置文件

在配置文件中加上lower_case_table_names=1,这句的意义是不让MySQL区分大小写

[root@localhost etc]# vi /etc/my.cnf

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
lower_case_table_names=1

5、启动MySQL服务

首先启动MySQL服务,然后修改MySQL的密码,并配置MySQL可远程访问

[root@localhost mysql8]# systemctl start mysqld
[root@localhost mysql8]# cat /var/log/mysqld.log | grep password
2023-06-13T05:55:58.156403Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Ax1#JAS_Q*LO
2023-06-13T07:08:22.500552Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: *oNXTNGhq7*P
[root@localhost mysql8]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.28

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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> use mysql;
No connection. Trying to reconnect...
Enter password: 
Connection id:    10
Current database: *** NONE ***

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set user.Host='%' where user.User='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select host from user where user = 'root';
+------+
| host |
+------+
| %    |
+------+
1 row in set (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> 

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
安装MySQL需要以下步骤: 1. 下载MySQL安装文件:在终端中使用wget命令下载MySQL安装文件。例如,使用以下命令下载MySQL 5.7.27版本的安装文件: ``` wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.27.tar.gz --no-check-certificate ``` 2. 解压安装文件:使用tar命令解压下载的安装文件。例如,使用以下命令解压下载的安装文件: ``` tar -zxvf mysql-boost-5.7.27.tar.gz ``` 3. 进入解压后的目录:使用cd命令进入解压后得到的MySQL目录。例如,使用以下命令进入解压后的目录: ``` cd mysql-5.7.27 ``` 4. 配置MySQL安装参数:使用cmake命令进行MySQL的配置。根据你的需求,设置合适的参数。例如,使用以下命令配置MySQL的参数: ``` cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DENABLE_DTRACE=0 -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DWITH_EMBEDDED_SERVER=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/soft/mysql-5.7.27/boost/boost_1_59_0 ``` 5. 编译和安装MySQL:使用make命令进行MySQL的编译和安装。例如,使用以下命令编译和安装MySQL: ``` make make install ``` 6. 配置MySQL环境变量:编辑你的环境变量文件,例如.bashrc或.bash_profile文件,将MySQL安装路径添加到PATH变量中。例如,在.bashrc文件中添加以下行: ``` export PATH=$PATH:/usr/local/mysql/bin ``` 然后运行以下命令使环境变量生效: ``` source ~/.bashrc ``` 7. 初始化MySQL:使用mysqld命令初始化MySQL。例如,使用以下命令初始化MySQL: ``` mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data ``` 8. 启动MySQL服务:使用mysqld_safe命令启动MySQL服务。例如,使用以下命令启动MySQL服务: ``` mysqld_safe --user=mysql & ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值