Centos7上修改mysql数据目录
通过yum安装的mysql,启动和增加数据库,增加数据如下:
[root@wucl-4 lib]# systemctl start mariadb
[root@wucl-4 lib]# mysql -uroot
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.52-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 |
+--------------------+
| information_schema |
| abc |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.00 sec) MariaDB [(none)]> use abc;
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 [abc]> show tables;
+---------------+
| Tables_in_abc |
+---------------+
| abc |
+---------------+
1 row in set (0.00 sec) MariaDB [abc]> select * from abc;
+------+---------+
| id | name |
+------+---------+
| 1 | baoshan |
+------+---------+
1 row in set (0.00 sec) MariaDB [abc]> show variables like 'datadir%';
+---------------+-----------------+
| Variable_name | Value |
+---------------+-----------------+
| datadir | /var/lib/mysql/ |
+---------------+-----------------+
1 row in set (0.01 sec) 现在将mysql数据目录换成/var/lib/mysql8
操作步骤如下:
1. 停止数据库systemctl start mariadb
2. 修改配置文件/etc/my.conf
[mysqld]
datadir=/var/lib/mysql8
socket=/var/lib/mysql8/mysql.sock
3. 新建mysql8文件夹,将mysql原数据目录中的文件复制到mysql8目录中
[root@wucl-4 lib]# pwd
/var/lib
[root@wucl-4 lib]# mkdir mysql8
[root@wucl-4 lib]# cp -rf mysql/* mysql8/
4. 修改mysql8目录的所属用户和组
chown -R mysql:mysql mysql8/
5. 启动mysql数据库
systemctl start mariadb
6. 访问数据库,查看数据时候迁移成功,查看现在数据目录
[root@wucl-4 lib]# mysql -uroot -S /var/lib/mysql8/mysql.sock
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.52-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 |
+--------------------+
| information_schema |
| abc |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.00 sec) MariaDB [(none)]> use abc;
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 [abc]> show tables;
+---------------+
| Tables_in_abc |
+---------------+
| abc |
+---------------+
1 row in set (0.00 sec) MariaDB [abc]> select * from abc;
+------+---------+
| id | name |
+------+---------+
| 1 | baoshan |
+------+---------+
1 row in set (0.00 sec) MariaDB [abc]> show variables like 'datadir%';
+---------------+------------------+
| Variable_name | Value |
+---------------+------------------+
| datadir | /var/lib/mysql8/ |
+---------------+------------------+
1 row in set (0.00 sec) 前后折腾了好久,mark一下。
Centos7上修改mysql数据目录的更多相关文章
- 在 CentOS7 上部署 MySQL 主从
在 CentOS7 上部署 MySQL 主从 通过 SecureCRT 连接至 MySQL 主服务器: 找到 my.cnf 文件所在的目录: mysql --help | grep my.cnf 一般 ...
- centos7上修改主机名
centos7上修改主机名 2017-10-09 13:45:17 个人原创,转载请注明,否则追究法律责任 1,临时修改: 和centos5,centos6 一样,重启失效 2,永久修改: 命令: ...
- centos7上安装 mysql
centos7上的安装是和其他的版本不一样的 ,因为centos上的安装与centos的操作是不通了的 在CentOS中默认安装有MariaDB,这个是MySQL的分支,但为了需要,还是要在系统中安装 ...
- Centos7 上安装mysql遇上的问题:mysql无法正常启动
第一次在Centos上安装mysql遇到的一些问题. 第一步就遇到问题,安装mysql-server报错没有可用包. [解决方法] 先要安装mysql # wget http://repo.mysq ...
- 阿里云CentOs7上安装Mysql
前提:虽然yum源上有mysql,但是好像没有mysql-server,所以我们还是选择自己从官网上下载安装 一.新建文件夹,然后下载解压 cd /usr/ #新建mysql文件夹 mkdir mys ...
- linux上修改mysql登陆密码
1. 修改MySQL的登录设置: # vi /etc/my.cnf 2. 在[mysqld]的段中加上一句:skip-grant-tables 例如: [mysqld] port ...
- Mac上修改MySQL默认字符集为utf8
1.检查默认安装的mysql的字符集 mysql> show variables like '%char%'; +--------------------------+------------- ...
- 远程连接centos7 上的mysql报(ERROR 2003 (HY000): Can't connect to MySQL server on '168.x.x.x' (10060) )
1.MySQL端口 因为上一篇文章我就已经给MySQL新建了一新用户,且赋予了远程连接数据库的所有权限(GRANT ALL PRIVILEGES ON *.* TO 'newuser' @ '%' I ...
- CentOS7 上安装 MySQL 5.7
1.下载如下rpm文件: mysql-community-common-5.7.17-1.el7.x86_64.rpm mysql-community-libs-5.7.17-1.el7.x86_64 ...
随机推荐
- JDBC的批量插入操作
在今天之前,当我遇到需要使用JDBC对数据库进行批量插入操作的时候,我使用的方法如下: ①使用Connection建立数据库连接: ②使用PreparedStatement提交SQL语句,将数据插入: ...
- 设置pycharm为Eclipse快捷键
Ctrl + O 根据name模糊查找当前文件中类.方法Alt + (向左箭头或者向右箭头) ,回退or前进到到之前查看或者编辑处Alt + (向上箭头或者向下箭头) ,将当前方法整体往下或者往上移动 ...
- 介绍Visual Studio的Android模拟器
介绍Visual Studio的Android模拟器 http://blogs.msdn.com/b/visualstudioalm/archive/2014/11/12/introducing-vi ...
- UIWebView页面的控制(二)
1.UIWebView的内容控制的属性/方法列表 loading属性 确认当前页面是否在读入中 canGoForward属性 确认goForward 方法是否可运行, ...
- linux&shell
Linux经常使用命令 登录时显示信息放在/etc/motd和/etc/profile.d/xxx.sh motd放置字符串 profile.d下放置脚本文件 echo echo -e 处理特殊字符. ...
- Android studio中导入第三方类库
常常在github上看到一些好用的框架,但是对于一个新手怎样在android studio上导入去总会遇到各种麻烦,索性来研究下第三方类库怎样在android studio上导入. 以我在github ...
- 从0开始搭建symphony
目标:在本地服务器中运行symphonyX 困难:=.= 基本全是困难…服务器重装了win/ubuntu/centos均不识别网卡,也是醉了. 1.通过Eclipse进行配置. 一开始以为需要单独下载 ...
- SuperMap iServer 9D HBase使用
需提前将HBase进行部署,参考上篇部署文档 https://www.cnblogs.com/zhangyongli2011/p/9982143.html (转发请注明出处:http://www.cn ...
- MySQL中group_concat函数
本文通过实例介绍了MySQL中的group_concat函数的使用方法,比如select group_concat(name) .MySQL中group_concat函数完整的语法如下:group_c ...
- [翻译] C# 8.0 新特性 Redis基本使用及百亿数据量中的使用技巧分享(附视频地址及观看指南) 【由浅至深】redis 实现发布订阅的几种方式 .NET Core开发者的福音之玩转Redis的又一傻瓜式神器推荐
[翻译] C# 8.0 新特性 2018-11-13 17:04 by Rwing, 1179 阅读, 24 评论, 收藏, 编辑 原文: Building C# 8.0[译注:原文主标题如此,但内容 ...