目录
官网ODBC配置... 3
1、ODBC下载官网... 3
2、上传安装包并解压... 3
3、安装odbc. 3
4、安装依赖... 4
5、再次执行安装即可... 4
6、查看版本及配置文件... 4
Mysql-ODBC配置... 5
一、达梦服务器... 5
1、下载odbc包... 5
2、安装... 6
3、报错... 6
4、先配置好yum源再安装就没问题了... 7
5、查看unixodbc配置... 7
6、配置odbc.ini文件... 7
7、配置odbcinst.ini文件... 9
8、配置环境变量... 9
9、测试... 10
二、MySQL服务器安装mysql数据库... 10
1、先查看本机IP地址和主机名并添加进/etc/hosts文件中... 10
2、上传mysql的安装包... 11
3、检查服务器上是否之前安装过MYSQL. 11
4、删除之前版本... 11
5、解压MYSQL安装包改目录名称... 11
6、创建数据文件目录与日志文件目录等相关目录并创建mysql用户和组... 12
7、创建my.cnf文件... 12
8、配置系统服务... 14
9、执行如下命令 mysql开机启动... 14
10、初始化数据库... 14
11、启动数据库... 14
12、MYSQL安装完成以后的配置修改密码... 15
13、创建测试库及表... 15
三、DM服务器配置MySQL的dblink. 16
1、服务重启... 16
2、创建dblink. 17
3、查询报错... 17
https://www.unixodbc.org/
tar xvf unixODBC-2.3.11.tar
cd unixODBC-2.3.11
./configure --enable-gui=no
报错:
缺少依赖:gcc及glib
yum install gcc
./configure --enable-gui=no
make
make install
odbc_config --version
查看ODBC配置文件存放的位置
odbc_config --odbcini
odbc_config --odbcinstini
注意:服务器防火墙要关闭!
dm连接mysql必须在dm服务器上安装mysql的odbc驱动,直接使用dm的odbc驱动会报错
https://repo.mysql.com/yum/mysql-connectors-community/el/7/x86_64/
yum install -y mysql-connector-odbc-5.3.9-1.el7.x86_64.rpm
有这个警告:Warning: RPMDB altered outside of yum.
删除yum的历史记录 即可
rm -rf /var/lib/yum/history/*.sqlite
odbcinst -j
[dm]
Description = DM ODBC DSN
Driver = DM8 ODBC DRIVER
SERVER = 192.168.16.203
UID = SYSDBA
PWD = SYSDBA
TCP_PORT = 5236
[mysql3]
Driver = MySQL ODBC 5.3 Unicode Driver
SERVER = 192.168.16.200
TCP_PORT = 3306
UID = hr
PWD = hr
DATABASE= dm8
[mysql4]
Driver = MySQL ODBC 5.3 Unicode Driver
SERVER = 192.168.16.200
TCP_PORT = 3306
USER = hr
PASSWORD = hr
DATABASE= dm8
#[mysqlodbc]
#Driver = MySQL08
#SERVER = 192.168.16.200
#TCP_PORT = 3306
#USER = hr
#PASSWORD = hr
#DATABASE= dm8
[mysqlodbc8]
Driver = MySQL08
SERVER = 192.168.16.200
TCP_PORT = 3306
USER = hr
PASSWORD = hr
DATABASE= dm8
[mysqlodbc]
Driver = MySQL ODBC 5.3 Unicode Driver
SERVER = 192.168.16.200
PORT = 3306
USER = hr
PASSWORD = hr
CHARSET= gbk
DATABASE= dm8
OPTION = 3
TRACE = OFF
只需要安装一个odbc包即可。
若是只是连接mysq的odbc就安装mysql的odbc(自动安装mysql的odbc驱动)。
若是只需要连接达梦的ODBC则只安装达梦(官网下载的那个即可,驱动使用达梦自带的即可)。
检查依赖
ldd /usr/lib64/libmyodbc5w.so
添加mysql odbc驱动路径
source .bash_profile
官网下载安装包
https://dev.mysql.com/downloads/mysql/
下载通用版本
vim /etc/hostname
mysql
reboot
命令如下:
查看IP地址 : ifconfig -a
查看主机名 : hostname
然后修改/etc/hosts文件:
vi /etc/hosts
添加内容:ip 主机名
放到了/usr/local下
CENTOS6: rpm -qa |grep mysql --检查是否有mysql
CENTOS7: rpm -qa |grep mariadb
rpm -e mariadb-libs-5.5.64-1.el7.x86_64 --nodeps
cd /usr/local
tar xzvf mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz
改目录名称
mv mysql-5.7.23-linux-glibc2.12-x86_64 mysql
mkdir -p /data/mysql_data
mkdir -p /data/mysql_log
mkdir -p /data/log-bin
groupadd mysql
useradd -g mysql mysql
chown -R mysql.mysql /data/mysql_data /data/mysql_log /data/log-bin
chown -R mysql.mysql /usr/local/mysql
vi /etc/my.cnf
[mysqld]
# GENERAL #
user = mysql
default-storage-engine = InnoDB
socket = /data/mysql_data/mysql.sock
pid-file = /data/mysql_data/mysql.pid
port = 3306
# MyISAM #
key_buffer_size = 1000M
#myisam_recover = FORCE,BACKUP (如果你安装的是MYSQL5.7那么这行的内容必须注销掉)
# SAFETY #
max_allowed_packet = 16M
max_connect_errors = 1000000
skip_name_resolve
# DATA STORAGE #
datadir = /data/mysql_data/
long_query_time = 1
# BINARY LOGGING #
binlog-format = ROW #这个配置一定要注意,为了后期安装HIVE所以这个地方一定要是ROW
log-bin = /data/log-bin/mysql-bin-3306
expire-logs-days = 14
sync-binlog = 1
server-id = 1
max_binlog_size = 500M
# REPLICATION #
relay-log = /data/log-bin/relay-bin-3306
slave-net-timeout = 60
# CACHES AND LIMITS #
tmp_table_size = 32M
max_heap_table_size = 32M
max_connections = 500
thread_cache_size = 50
open_files_limit = 65535
table_definition_cache = 4096
table_open_cache = 4096
# INNODB #
innodb_data_file_path = ibdata1:128M;ibdata2:10M:autoextend
innodb_flush_method = O_DIRECT
innodb_log_files_in_group = 2
innodb_lock_wait_timeout = 50
innodb_log_file_size = 256M
innodb_flush_log_at_trx_commit = 1
innodb_file_per_table = 1
innodb_thread_concurrency = 8
innodb_buffer_pool_size = 8G
# LOGGING #
log-error = /data/mysql_log/mysql-error-3306.log
log-queries-not-using-indexes = 1
slow-query-log = 1
long_query_time = 1
slow-query-log-file = /data/mysql_log/mysql-slow-3306.log
# FOR SLAVE #
#log-slave-updates = true
#gtid-mode = on
#enforce-gtid-consistency = true
#master-info-repository = TABLE
#relay-log-info-repository = TABLE
#sync-master-info = 1
#slave-parallel-workers = 2
#binlog-checksum = CRC32
#master-verify-checksum = 1
#slave-sql-verify-checksum = 1
#binlog-rows-query-log_events = 1
#report-port = 3306
#report-host = 192.168.1.66
cp -af /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
vi /etc/init.d/mysqld
修改两处位置:
basedir=/usr/local/mysql
datadir=/data/mysql_data
chmod 755 /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 345 mysqld on
检查是否成功
chkconfig mysqld --list
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off <成功>
MYSQL 5.7:
cd /usr/local/mysql/bin
./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql_data
并添加环境变量
vim /etc/profile
export MYSQL_HOME="/usr/local/mysql"
export PATH="$PATH:$MYSQL_HOME/bin"
保存退出
. /etc/profile
service mysqld start
看到SUCCESS以后输入mysql -uroot -p
报错:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
执行:
ln -s /data/mysql_data/mysql.sock /tmp/mysql.sock
初始化密码查找
cat /data/mysql_log/mysql-error-3306.log|grep password
密码为最后一个A temporary password is generated for root@localhost: 冒号后的内容就是密码
mysql -uroot -p'xxxx' 这里面放冒号后的内容
MYSQL 5.7修改密码的方式:
set password=password("root");
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
刷新权限
FLUSH PRIVILEGES;
mysql自动提交。
create database dm8;
use dm8
创建用户并授权,必须加引号呢
create user 'hr' identified by 'hr';
grant all privileges on dm8.* to 'hr'@'%';
刷新权限表
flush privileges;
达梦服务器
DmServiceDMSERVER restart
disql
create or replace public LINK LINK_MYSQLODBC CONNECT 'ODBC' with "hr" identified by "hr" using 'mysqlodbc';
select * from dm8."dept"@LINK_MYSQLODBC;
最开始报错:
修改dmdba环境变量后
后来报错:
重新创建一个其他名字的dblink就行。只要是该名字LINK_MYSQLODBC重建多少次也会一直报同样错误。
删除该link后重建就可以了
后又测试使用dm自带驱动创建该link(不知道是不是这个原因)
现在怎样删除及重建都不能使用该link了
其他名字link无异常,且修改dm驱动创建link报错后重建依然可用。
达梦数据库社区地址:https://eco.dameng.com