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

服务器 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 mariadbmariadb-common-10.3.9-12.p01.ky10.x86_64mariadb-10.3.9-12.p01.ky10.x86_64mariadb-errmessage-10.3.9-12.p01.ky10.x86_64mariadb-connector-c-3.0.6-8.ky10.x86_64mariadb-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 mysqlqt5-qtbase-mysql-5.11.1-13.p01.ky10.x86_64python2-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、创建用户和用户组,分配权限

# 创建一个用户组:mysqlgroupadd mysql# 创建一个系统用户:mysql,指定用户组为mysqluseradd -r -g mysql mysqlchown -R mysql:mysql /data/mysql/mysql-5.7.44/datachmod -R 750 /data/mysql/mysql-5.7.44/datachmod 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=1sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES  basedir = /data/mysql/mysql-5.7.44datadir = /data/mysql/mysql-5.7.44/dataport = 3306socket = /data/mysql/mysql-5.7.44/tmp/mysql.sockcharacter-set-server=utf8mb4pid-file = /data/mysql/mysql-5.7.44/data/mysqld.pid#log日志log-error=/data/mysql/mysql-5.7.44/logs/mysql.errlog_bin = /data/mysql/mysql-5.7.44/logs/mysql-binrelay_log = /data/mysql/mysql-5.7.44/logs/relay-binslow_query_log_file = /data/mysql/mysql-5.7.44/logs/slow.logslow_query_log=onlog_bin_trust_function_creators=1#开启相关日志general_log=OFF#设置唯一idserver-id=1#指定bin-log为row类别,其他两种是statement、mixedbinlog_format=row#对指定的数据库开启bin-log,这里是对wh数据库开启bin-log服务binlog-do-db=whexpire_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

也许您对下面的内容还感兴趣: