您的当前位置:首页正文

银河麒麟系统V10(x86_64版)安装mysql8说明

2024-11-13 来源:个人技术集锦

#国产化操作系统mysql8安装#

随着国产化系统推广与发展,以及个人隐私和系统安全越来越重要。目前很多单位和企业开始尝试国产化上操作系统,国产化操作系统主要有深度Linux(Deepin)、统信UOS、优麒麟(UbuntuKylin)、红旗Linux、中标麒麟(NeoKylin)、银河麒麟V10(Kylin)华为欧拉(openEuler)和中科方德。

本文介绍如何在银河麒麟系统(x86_64版)上安装mysql8。本资源在x86_64版本上主要采用rpm安装包进行安装,采用mysql-8.0.30-1.el8.x86_64离线安装包,能够在x86_64版国产化银河麒麟系统上进行安装。

安装步骤如下

mkdir /usr/local/mysql

mkdir /usr/local/mysql/data

touch /usr/local/mysql/error.log

mkdir -p /usr/local/mysql/share/mysql-8.0/

mkdir -p /usr/local/mysql/share/mysql-8.0/

touch /usr/local/mysql/share/mysql-8.0/errmsg.sys

2、赋权

chmod -R 777 /usr/local/mysql/data

chmod -R 777 /usr/local/mysql/error.log

chmod -R 777 /usr/local/mysql/share/mysql-8.0/errmsg.sys

3、复制mysql-8.0.30-1.el8.x86_64.rpm-bundle.tar到/usr/local/mysql下

cp mysql-8.0.30-1.el8.x86_64.rpm-bundle.tar /usr/local/redis/mysql-8.0.30-1.el8.x86_64.rpm-bundle.tar
3、解压
tar -xvf mysql-8.0.30-1.el8.x86_64.rpm-bundle.tar

4、修改my.cnf配置

#一般由于系统自带mysql,也存在改配置文件,为了减少影响,在确认无误后可以将该文件备份后删除

mv /etc/my.cnf /etc/my.cnf.bak

#删除该文件

rm -rf /etc/my.cnf

#重新写入my.cnf内容

echo '[mysqld] ' > /etc/my.cnf

echo 'port=3306 ' >> /etc/my.cnf

echo 'basedir='/usr/local/mysql ' >> /etc/my.cnf

echo 'datadir='/usr/local/mysql/data ' >> /etc/my.cnf

echo 'max_connections=1200 ' >> /etc/my.cnf

echo 'max_connect_errors=5 ' >> /etc/my.cnf

echo 'skip-grant-tables ' >> /etc/my.cnf

echo '' >> /etc/my.cnf

echo 'bind-address=0.0.0.0 ' >> /etc/my.cnf

echo 'character-set-server=utf8 ' >> /etc/my.cnf

echo 'default-storage-engine=INNODB ' >> /etc/my.cnf

echo 'lower_case_table_names=1 ' >> /etc/my.cnf

echo 'socket=/var/lib/mysql/mysql.sock ' >> /etc/my.cnf

echo 'log-error='/usr/local/mysql/error.log ' >> /etc/my.cnf

echo '' >> /etc/my.cnf

echo '[mysql] '>> /etc/my.cnf

echo 'default-character-set=utf8 ' >> /etc/my.cnf

echo '' >> /etc/my.cnf

echo '[client] '>> /etc/my.cnf

echo 'port=3306' >> /etc/my.cnf

#注意,如果端口被占用,可以将端口改为其他未被占用的端口

4、执行安装程序

rpm -ivh mysql-community-client-8.0.30-1.el8.x86_64.rpm --nodeps --force

rpm -ivh mysql-community-client-debuginfo-8.0.30-1.el8.x86_64.rpm --nodeps --force

rpm -ivh mysql-community-client-plugins-8.0.30-1.el8.x86_64.rpm --nodeps --force

rpm -ivh mysql-community-client-plugins-debuginfo-8.0.30-1.el8.x86_64.rpm --nodeps --force

rpm -ivh mysql-community-common-8.0.30-1.el8.x86_64.rpm --nodeps --force

rpm -ivh mysql-community-debuginfo-8.0.30-1.el8.x86_64.rpm --nodeps --force

rpm -ivh mysql-community-debugsource-8.0.30-1.el8.x86_64.rpm --nodeps --force

rpm -ivh mysql-community-devel-8.0.30-1.el8.x86_64.rpm --nodeps --force

rpm -ivh mysql-community-icu-data-files-8.0.30-1.el8.x86_64.rpm --nodeps --force

rpm -ivh mysql-community-libs-8.0.30-1.el8.x86_64.rpm --nodeps --force

rpm -ivh mysql-community-libs-debuginfo-8.0.30-1.el8.x86_64.rpm --nodeps --force

rpm -ivh mysql-community-server-8.0.30-1.el8.x86_64.rpm --nodeps --force

rpm -ivh mysql-community-server-debug-8.0.30-1.el8.x86_64.rpm --nodeps --force  

rpm -ivh mysql-community-server-debug-debuginfo-8.0.30-1.el8.x86_64.rpm --nodeps --force

rpm -ivh mysql-community-server-debuginfo-8.0.30-1.el8.x86_64.rpm --nodeps --force

rpm -ivh mysql-community-test-8.0.30-1.el8.x86_64.rpm --nodeps --force  

rpm -ivh mysql-community-test-debuginfo-8.0.30-1.el8.x86_64.rpm --nodeps --force

5、初始化数据库

mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/

6、启动mysql

systemctl start mysqld

7、修改密码

因为配置了skip-grant-tables参数,所以可以不用密码进入mysql

mysql -u root -p

按enter健进入mysql命令行,输入以下修改密码指令

flush privileges;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '替换为自己设定的新密码';
flush privileges;
use mysql;
update user set host='%%' where user ='root' and host='localhost';
flush privileges;
grant all privileges on *.* to 'root'@'%%' with grant option;
flush privileges;
完成后停止服务

systemctl stop mysqld

8、从新改写my.cnf

vim /etc/my.cnf

将skip-grant-tables一行删除

9、重新启动mysql

systemctl start mysqld

完成mysql安装。

安装过程中有问题可以随时联系,感谢支持

显示全文