#安装 unixODBC yum install unixODBC.x86_64 unixODBC-devel.x86_64 #查看odbcins.ini配置文件 cat /etc/odbcinst.ini #验证系统能否找到驱动 odbcinst -q -d
#下载,安装 unixODBC 驱动 wget https://mirrors.huaweicloud.com/centos/7/os/x86_64/Packages/mysql-connector-odbc-5.2.5-8.el7.x86_64.rpm rpm -ivh mysql-connector-odbc-5.2.5-8.el7.x86_64.rpm 查看安装路径 rpm -ql mysql-connector-odbc-5.2.5-8.el7.x86_64 ll /usr/lib64/libmyodbc5.so
#编辑odbc.ini vi /etc/odbc.ini [test] Description = MySQL test database Driver = mysql Server = 192.168.3.XX User = root Password =XXXX Port = 3306 Database = mysql
#验证 ODBC 是否可用 isql test
show databases; #显示所有数据库
use qgs_db; #使用qgs_db数据库 select database(); #查看当前数据库 show tables; #当前数据库的表 create table qgs1(name varchar(20),sex char(1), #创建表 create table 表名 (列属性); desc qgs1; #查看表结构
#关闭防火墙,创建监控用户, use mysql; update user set user.Host='%' where user.User='root'; #create user '用户名'@'%' identified by '密码'; create user 'qgs'@'%' identified by 'qgs111'; #grant select,process,super on *.* to '用户名'@'%' identified by '密码'; 允许所有ip连接(用通配符%表示),只允许指定IP地址链接将%去掉即可 grant select,process,super on *.* to 'qgs'@'%' identified by 'qgs111'; flush privileges;
与test对应得上即可