保姆级银河麒麟V10高级服务器离线安装mysql5.7数据库

avatar
作者
筋斗云
阅读量:0

离线在银河麒麟高级操作系统v10安装mysql5.7

  1. 下载mysql5.7

MySQL :: Download MySQL Community Server (Archived Versions)

2、把下载好的包上传到服务器

3、解压

[root@1-0001 ~]# cd /data/mysql  [root@1-0001 mysql]# tar -zxvf mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz

4、卸载系统的mariadb数据库

查询安装的mariadb数据库

rpm -qa | grep mariadb

[root@1-0001 ~]# rpm -qa | grep mariadb mariadb-common-10.3.9-12.p01.ky10.x86_64 mariadb-10.3.9-12.p01.ky10.x86_64 mariadb-errmessage-10.3.9-12.p01.ky10.x86_64 mariadb-connector-c-3.0.6-8.ky10.x86_64 mariadb-server-10.3.9-12.p01.ky10.x86_64

5、使用命令 rpm -e --nodeps卸载

[root@1-0001 ~]# rpm -e --nodeps mariadb-common-10.3.9-12.p01.ky10.x86_64 [root@1-0001 ~]# rpm -e --nodeps mariadb-10.3.9-12.p01.ky10.x86_64 [root@1-0001 ~]# rpm -e --nodeps mariadb-errmessage-10.3.9-12.p01.ky10.x86_64 [root@1-0001 ~]# rpm -e --nodeps mariadb-connector-c-3.0.6-8.ky10.x86_64 [root@1-0001 ~]# rpm -e --nodeps mariadb-server-10.3.9-12.p01.ky10.x86_64

6、继续查询是否存在玛丽数据库rpm -qa | grep mariadb

[root@1-0001 ~]# rpm -qa | grep mariadb

7、卸载mysql数据,查询mysql

[root@1-0001 ~]# rpm -qa | grep mysql qt5-qtbase-mysql-5.11.1-13.p01.ky10.x86_64 python2-mysqlclient-1.3.12-8.ky10.x86_64

8、使用rpm -e --nodeps 卸载mysql数据库

[root@1-0001 ~]# rpm -e --nodeps qt5-qtbase-mysql-5.11.1-13.p01.ky10.x86_64 [root@1-0001 ~]# rpm -e --nodeps python2-mysqlclient-1.3.12-8.ky10.x86_64

9、在解压的mysql包中,重新命名解压文件夹为mysql-5.7.44

10、在文件夹mysql新建data、tmp和logs文件夹

11、创建用户和用户组,分配权限

# 创建一个用户组:mysql  groupadd mysql  # 创建一个系统用户:mysql,指定用户组为mysql  useradd -r -g mysql mysql chown -R mysql:mysql /data/mysql/mysql-5.7.44/data chmod -R 750 /data/mysql/mysql-5.7.44/data chmod 777 /data/mysql/mysql-5.7.44/tmp

12、赋予mysql用户权限给mysql文件夹

chown -R mysql:mysql /data/mysql/mysql-5.7.44

13、设置配置文件mysql配置文件my.cnf(在文件夹/data/mysql/mysql-5.7.44/my.cnf)

# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL.     [mysqld] lower_case_table_names=1 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES    basedir = /data/mysql/mysql-5.7.44 datadir = /data/mysql/mysql-5.7.44/data port = 3306 socket = /data/mysql/mysql-5.7.44/tmp/mysql.sock character-set-server=utf8mb4  pid-file = /data/mysql/mysql-5.7.44/data/mysqld.pid  #log日志 log-error=/data/mysql/mysql-5.7.44/logs/mysql.err log_bin = /data/mysql/mysql-5.7.44/logs/mysql-bin relay_log = /data/mysql/mysql-5.7.44/logs/relay-bin slow_query_log_file = /data/mysql/mysql-5.7.44/logs/slow.log slow_query_log=on log_bin_trust_function_creators=1 #开启相关日志 general_log=OFF    #设置唯一id server-id=1 #指定bin-log为row类别,其他两种是statement、mixed binlog_format=row #对指定的数据库开启bin-log,这里是对wh数据库开启bin-log服务 binlog-do-db=wh    expire_logs_days = 30 #设置binlog清理时间 max_binlog_size = 1000m #binlog每个日志文件大小 binlog_cache_size = 40m #binlog缓存大小 max_binlog_cache_size = 5120m #最大binlog缓存大小  

14、初始化数据库

cd /data/mysql/mysql-5.7.44/bin ./mysqld --defaults-file=/data/mysql/mysql-5.7.44/my.cnf  --lower-case-table-names=1 --initialize-insecure

15、启动mysql

/data/mysql/mysql-5.7.44/bin/mysqld_safe --defaults-file=/data/mysql/mysql-5.7.44/my.cnf &

16、无密码登录mysql

/data/mysql/mysql-5.7.44/bin/mysql -S /data/mysql/mysql-5.7.44/tmp/mysql.sock -u root --skip-password

17、修改mysql密码同时允许远程访问,密码就是你设置的root登录密码

GRANT ALL ON *.* TO root@'%' IDENTIFIED BY '密码' WITH GRANT OPTION; #刷新使配置生效 flush privileges; #退出 quit

18、连接数据库

说明:

1、启动mysql

/data/mysql/mysql-5.7.44/bin/mysqld_safe --defaults-file=/data/mysql/mysql-5.7.44/my.cnf &

2、停止mysql

/data/mysql/mysql-5.7.44/bin/mysqladmin -S /data/mysql/mysql-5.7.44/tmp/mysql.sock -u root -p shutdown

3、在做11步骤的时候可能会无法启动,这里可能是你操作的时候使用root用户,创建的日志是root用户,但是执行是mysql用户,没有权限,所以可以重复执行给mysql配置一下权限命令:

chown -R mysql:mysql /data/mysql/mysql-5.7.44

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!