三月阳光 发表于 2018-9-19 09:20:52

Centos7下Gitlab迁移数据库mysql过程

yum -y install mysql-server mysql-devel  

  
#基本配置,新建密码等
  
mysql_secure_installation
  

  
#登录数据库
  
mysql -uroot -p$password
  

  
#查看用户情况
  
mysql> select user,host from mysql.user;
  
+------+-----------+
  
| user | host   |
  
+------+-----------+
  
| root | 127.0.0.1 |
  
| root | ::1      |
  
| root | localhost |
  
| root | test   |
  
+------+-----------+
  
4 rows in set (0.03 sec)
  

  
#创建一个gitlab管理用户
  
mysql> CREATE USER 'git'@'localhost' IDENTIFIED BY '123456';
  
Query OK, 0 rows affected (0.00 sec)
  

  
#创建gitlab数据库
  
mysql> CREATE DATABASE IF NOT EXISTS`gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_general_ci`;
  
Query OK, 1 row affected (0.00 sec)
  

  
#授予git用户对gitlabhq_production数据库所有表的权限
  
mysql> GRANT SELECT, INSERT, UPDATE, DELETE,CREATE, CREATE TEMPORARY TABLES, DROP, INDEX, ALTER, LOCK TABLES, REFERENCES ON`gitlabhq_production`.* TO 'git'@'localhost';
  
Query OK, 0 rows affected (0.00 sec)
  

  
#使修改用户生效
  
mysql> flush privileges;
  
Query OK, 0 rows affected (0.00 sec)
  
mysql> \q
  
Bye
  

  
#测试新用户是否能连接新的数据库
  
sudo -u git -H mysql -u git -p -Dgitlabhq_production
  
Enter password:
  
Reading table information for completion of tableand column names
  
You can turn off this feature to get a quickerstartup with -A
  

  
Welcome to the MySQL monitor.Commands end with ; or \g.
  
Your MySQL connection id is 32
  
Server version: 5.6.36 MySQL Community Server (GPL)
  

  
Copyright (c) 2000, 2017, Oracle and/or itsaffiliates. All rights reserved.
  

  
Oracle is a registered trademark of OracleCorporation and/or its
  
affiliates. Other names may be trademarks of theirrespective
  
owners.
  

  
Type 'help;' or '\h' for help. Type '\c' to clearthe current input statement.
  

  
mysql>


页: [1]
查看完整版本: Centos7下Gitlab迁移数据库mysql过程