mysql数据库管理-文件系统分配管理

1 数据库软件迁移以及数据库挂载到不同的目录

1 在my.conf里面确定的datadir目录下创建数据库名称相同的文件夹,并进行mount挂载,分散数据库存储。

[root@postgresql ~]# /etc/init.d/mysqld status
 ERROR! MySQL is not running
[root@postgresql ~]# tar -cvf mysq.tar *

文件系统挂载,拷贝。

[root@postgresql ~]# chown mysql:mysql /mysql


[mysqld]
#skip-grant-tables
secure_file_priv="/mysql5.17"
port = 3306
skip-ssl
basedir = /mysql5.17
datadir = /mysql5.17/data

socket=/tmp/mysql.sock
pid-file=/mysql5.17/data/mysql.pid
log-error=/mysql5.17/log/error.log

character_set_server=utf8
user=mysql
max_connections=1500
symbolic-links=0
!includedir /etc/my.cnf.d

  • 停止mysql数据库。
  • 到原来的目录,tar -cvf mysqlbakup.tar *
  • 拷贝到新的目录data下。
  • 修改my.conf SELECT @@datadir, socket文件做ln -S
  • 启动mysql数据库

~[root@postgresql /]# /etc/init.d/mysqld  start
Starting MySQL.2019-10-28T08:01:20.738954Z mysqld_safe error: log-error set to '/mysql5.17/log/error.log', however file don't exists. Create writable for user 'mysql'.
 ERROR! The server quit without updating PID file (/mysql5.17/data/mysql.pid).
[root@postgresql /]# 

[root@postgresql log]# echo 123> error.log 
[root@postgresql log]# chown mysql:mysql error.log 
[root@postgresql log]# /etc/init.d/mysqld  start
Starting MySQL.... SUCCESS! 
[root@postgresql log]# ls
error.log  lost+found
[root@postgresql log]# tail -f error.log 
2019-10-28T08:04:11.232381Z 0 [Note] InnoDB: 5.7.27 started; log sequence number 2751359
2019-10-28T08:04:11.249474Z 0 [Note] Plugin 'FEDERATED' is disabled.
2019-10-28T08:04:11.294691Z 0 [Note] InnoDB: Loading buffer pool(s) from /mysql5.17/data/ib_buffer_pool
2019-10-28T08:04:11.408149Z 0 [Note] InnoDB: Buffer pool(s) load completed at 191028  1:04:11
2019-10-28T08:04:11.943131Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2019-10-28T08:04:11.944785Z 0 [Note] IPv6 is available.
2019-10-28T08:04:11.944820Z 0 [Note]   - '::' resolves to '::';
2019-10-28T08:04:11.944863Z 0 [Note] Server socket created on IP: '::'.
2019-10-28T08:04:12.010366Z 0 [Note] Event Scheduler: Loaded 0 events
2019-10-28T08:04:12.011057Z 0 [Note] 

[root@postgresql ~]# mount /dev/sdc3 /mysql5.17/data/radiodb/

-bash-4.2$ mysql -hlocalhost -uroot -p123
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.7.27 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

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> show databass;
ERROR 1064 (42000): 
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| monidb             |
| mysql              |
| performance_schema |
| radiodb            |
| sys                |
| tjnpm              |
+--------------------+
7 rows in set (0.01 sec)

mysql> use radiodb
Database changed
mysql> show create database radiodb\G
*************************** 1. row ***************************
       Database: radiodb
Create Database: CREATE DATABASE `radiodb` /*!40100 DEFAULT CHARACTER SET utf8 */
1 row in set (0.00 sec)

mysql> 


[root@postgresql ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        18G  4.4G   14G  25% /
devtmpfs        190M     0  190M   0% /dev
tmpfs           205M     0  205M   0% /dev/shm
tmpfs           205M  9.1M  196M   5% /run
tmpfs           205M     0  205M   0% /sys/fs/cgroup
/dev/sda1       297M  157M  141M  53% /boot
tmpfs            41M   12K   41M   1% /run/user/42
tmpfs            41M     0   41M   0% /run/user/1001
/dev/sdc1       9.8G  4.4G  4.9G  47% /mysql5.17
/dev/sdc2       3.9G   17M  3.6G   1% /mysql5.17/log
/dev/sdc3       3.9G   16M  3.6G   1% /mysql5.17/data/radiodb

[root@postgresql ~]# reboot


-bash-4.2$ mysql -uroot -p123
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.27 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

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> 
mysql> 
mysql> use tjnpm
Database changed
mysql> create table port (id int(10),name varchar(100);
ERROR 1064 (42000): 
mysql> create table port (id int(10),name varchar(100) ;
ERROR 1064 (42000): 
mysql> create table port (id int(10),name varchar(100) );
Query OK, 0 rows affected (0.04 sec)

mysql> 
mysql> 
mysql> show create table port\G
*************************** 1. row ***************************
       Table: port
Create Table: CREATE TABLE `port` (
  `id` int(10) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.06 sec)

mysql> 

 

2 新数据库挂载存储

mysql>  create database radiodb;

mount /dev/sdd1 /mysql5.7.21/data/radiodb

cp db.opt/  /mysql5.7.21/data/radiodb

 

3 如果数据库存储不足,如何扩容??

 

你可能感兴趣的:(MYSQL数据库部署,升级)