linux 的mysql数据库 数据库的路径的软连接

centos7以下

[root@localhost mysql]# service mysqld restart
Redirecting to /bin/systemctl restart  mysqld.service
[root@localhost mysql]# mysql -uroot -p123456
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 2
Server version: 10.1.21-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MariaDB [(none)]> use daochudata
Database changed
MariaDB [daochudata]> create table t(id int);
ERROR 1005 (HY000): Can't create table `daochudata`.`t` (errno: 13 "Permission denied")
MariaDB [daochudata]> user cardid
    -> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'user cardid' at line 1
MariaDB [daochudata]> use sedata1
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [sedata1]> create table t1(id int);
Query OK, 0 rows affected (0.38 sec)

MariaDB [sedata1]> drop table t1;
Query OK, 0 rows affected (0.08 sec)

MariaDB [sedata1]> create database daochudata;
Query OK, 1 row affected (0.00 sec)

MariaDB [sedata1]> use daochudata
Database changed
MariaDB [daochudata]> create table a(id int);
Query OK, 0 rows affected (0.33 sec)

MariaDB [daochudata]>
-rw-rw----. 1 mysql mysql    33243136 2月  10 16:45 zhilianzhaopin.MAI
-rw-rw----. 1 mysql mysql        6581 2月   7 11:17 zhuoyue.frm
-rw-rw----. 1 mysql mysql     7847936 2月  10 13:38 zhuoyue.MAD
-rw-rw----. 1 mysql mysql     2465792 2月  10 16:45 zhuoyue.MAI
[root@localhost sedata1]# cd ..
[root@localhost Data1]# ll
总用量 76
drwxrwxrwx. 2 mysql mysql  4096 5月  12 15:58 daochudata
drwxrwxrwx. 5 root  root   4096 2月  28 11:40 dataprocess
drwxrwxrwx. 2 mysql mysql 32768 5月  12 16:06 sedata1
drwxrwxrwx. 2 mysql mysql 16384 3月  11 08:48 sedata2
drwxrwxrwx. 2 mysql mysql 12288 4月   7 09:07 sedata3
drwxrwxrwx. 2 mysql mysql  4096 2月   4 14:28 sedata4
drwxrwxrwx. 2 mysql mysql  4096 2月   4 14:28 sedata5
[root@localhost Data1]# rm daochudata
rm: 无法删除"daochudata": 是一个目录
[root@localhost Data1]# rm -rf daochudata
[root@localhost Data1]# mv /var/lib/mysql/daochudata .
[root@localhost Data1]# ll
总用量 76
drwx------. 2 mysql mysql  4096 5月  12 16:08 daochudata
drwxrwxrwx. 5 root  root   4096 2月  28 11:40 dataprocess
drwxrwxrwx. 2 mysql mysql 32768 5月  12 16:06 sedata1
drwxrwxrwx. 2 mysql mysql 16384 3月  11 08:48 sedata2
drwxrwxrwx. 2 mysql mysql 12288 4月   7 09:07 sedata3
drwxrwxrwx. 2 mysql mysql  4096 2月   4 14:28 sedata4
drwxrwxrwx. 2 mysql mysql  4096 2月   4 14:28 sedata5
[root@localhost Data1]# cd /var/lib/mysql
[root@localhost mysql]# ln -s /media/Data1/daochudata/ daochudata
[root@localhost mysql]# cd daochudata
[root@localhost daochudata]# ll
总用量 104
-rw-rw----. 1 mysql mysql   433 5月  12 16:11 a.frm
-rw-rw----. 1 mysql mysql 98304 5月  12 16:11 a.ibd
-rw-rw----. 1 mysql mysql    65 5月  12 16:08 db.opt


Centos7的软连接
[root@HBase mysql]# mysql -uroot -p123456
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 54
Server version: 10.0.28-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| aa                 |
| datapart10         |
| dumpdata           |
| icplatform         |
| information_schema |
| jiudian            |
| mass               |
| mysql              |
| performance_schema |
| test               |
| txtdata            |
| webauth            |
| webpass            |
+--------------------+
13 rows in set (0.00 sec)

MariaDB [(none)]> create database daochudata;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> show tables;
ERROR 1046 (3D000): No database selected
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| aa                 |
| daochudata         |
| datapart10         |
| dumpdata           |
| icplatform         |
| information_schema |
| jiudian            |
| mass               |
| mysql              |
| performance_schema |
| test               |
| txtdata            |
| webauth            |
| webpass            |
+--------------------+
14 rows in set (0.00 sec)

MariaDB [(none)]> use daochudata;
Database changed
MariaDB [daochudata]> create table t(id int);
Query OK, 0 rows affected (0.56 sec)

MariaDB [daochudata]>






原文地址:https://www.cnblogs.com/miaoer/p/6846252.html