首页 > 编程知识 正文

mysql设置数据库注意事项不包括

时间:2023-12-29 13:16:49 阅读:330176 作者:JJQQ

本文目录一览:

如何把sqlserver数据迁移到mysql数据库及需要注意事项

如何把sqlserver数据迁移到mysql数据库及需要注意事项

Server数据迁移到MySQL需要注意的一些问题

1、唯一索引的不同,sql

server的唯一索引的字段只能允许存在一个null值,而mysql,一直oracle中唯一索引对应的字段都允许存在多个null值。

2、存储过程的语法存在很大的不同,存储过程的迁移是最麻烦的,需要仔细修改。

3、程序中部分写的SQL语句由于语法的不同也要相应的修改。

怎么配置mysql数据库配置文件

一、mysql_install_db说明

当MySQL的系统库(mysql系统库)发生故障或需要新加一个mysql实例时,需要初始化mysql数据库。

需要使用的命令:/usr/local/mysql/bin/mysql_install_db

#/usr/local/mysql/bin/mysql_install_db --help 可以查看帮助信息如下

Usage: /usr/local/mysql/bin/mysql_install_db [OPTIONS]

--basedir=path       The path to the MySQL installation directory.

--cross-bootstrap    For internal use.  Used when building the MySQL system

tables on a different host than the target.

--datadir=path       The path to the MySQL data directory.

--force              Causes mysql_install_db to run even if DNS does not

work.  In that case, grant table entries that normally

use hostnames will use IP addresses.

--ldata=path         The path to the MySQL data directory.

--rpm                For internal use.  This option is used by RPM files

during the MySQL installation process.

--skip-name-resolve  Use IP addresses rather than hostnames when creating

grant table entries.  This option can be useful if

your DNS does not work.

--srcdir=path        For internal use.  The directory under which

mysql_install_db looks for support files such as the

error message file and the file for popoulating the

help tables.

--user=user_name     The login username to use for running mysqld.  Files

and directories created by mysqld will be owned by this

user.  You must be root to use this option.  By default

mysqld runs using your current login name and files and

directories that it creates will be owned by you.

All other options are passed to the mysqld program

除了支持以上的参数,还支持mysqld的参数。

二、举例:

本文以新加一个mysql实例为例。例如服务器上已经安装了3306端口的mysql服务,需要再启一个3308端口的mysql服务。

假设mysql安装在/usr/local/mysql路径下,找一个磁盘空间剩余比较大的盘,如/data1,把3308端口的mysql的数据保存在/data1下

#mkdir /data1/mysql_3308

#mkdir /data1/mysql_3308/data

#chown -R mysql:mysql /data1/mysql_3308

复制一个mysql配置文件my.cnf到/data1/mysql_3308目录下

#vi /data1/mysql_3308/my.cnf

修改配置文件,将端口和相关目录的都改为新的设置,如下:

[client]

character-set-server = utf8

port    = 3308

socket  = /tmp/mysql_3308.sock

[mysqld]

user    = mysql

port    = 3308

socket  = /tmp/mysql_3308.sock

basedir = /usr/local/mysql

datadir = /data1/mysql_3308/data

log-error = /data1/mysql_3308/mysql_error.log

pid-file = /data1/mysql_3308/mysql.pid

......其他略

确保配置文件无误。

运行下面命令进行数据库的初始化:

#/usr/local/mysql/bin/mysql_install_db --defaults-file=/data1/mysql_3308/my.cnf --datadir=/data1/mysql_3308/data

完成后新的3308数据库就初始化好了,如果有报错,则按照报错的提示查看报错日志,一般情况下都是my.cnf配置文件的问题,修正后即可。

三、启动新mysql

启动3308端口的mysql服务

#/usr/local/mysql/bin/mysqld_safe --defaults-file=/data1/mysql_3309/my.cnf

检查是否启动

#ps aux|grep mysql

如果有3308字样说明已经启动成功

可将启动命令加入/etc/rc.local随服务器启动

新加的mysql没有设置root密码,可以通过下面命令设置root密码:

#/usr/local/mysql/bin/mysqladmin -S /tmp/mysql_3308.sock -u root password 'new-password'

如何对MySQL数据库中的数据进行实时同步

具体操作:

1、在分析型数据库上创建目标表,数据更新类型为实时写入,字段名称和MySQL中的建议均相同;

2、在阿里云数据传输的控制台上创建数据订阅通道,并记录这个通道的ID;

3、 配置dts-ads-writer/app.conf文件,配置方式如下:所有配置均保存在app.conf中,运行前请保证配置正确;修改配置后,请重启writer,基本配置:

注意事项:

1、RDS

for

MySQL表和分析型数据库中表的主键定义必须完全一致;如果不一致会出现数据不一致问题。如果需要调整RDS/分析型数据库表的主键,建议先停止writer进程;

2、一个插件进程中分析型数据库db只能是一个,由adsJdbcUrl指定;

3、一个插件进程只能对应一个数据订阅通道;如果更新通道中的订阅对象时,需要重启进程。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。