Apache Presto 简明教程
Apache Presto - MySQL Connector
The MySQL connector is used to query an external MySQL database.
Configuration Settings
Hopefully you have installed mysql server on your machine. To enable mysql properties on Presto server, you must create a file “mysql.properties” in “etc/catalog” directory. Issue the following command to create a mysql.properties file.
$ cd etc
$ cd catalog
$ vi mysql.properties
connector.name = mysql
connection-url = jdbc:mysql://localhost:3306
connection-user = root
connection-password = pwd
Save the file and quit the terminal. In the above file, you must enter your mysql password in connection-password field.
Create Database in MySQL Server
打开 MySQL 服务器并使用以下命令创建一个数据库。
create database tutorials
Now you have created “tutorials” database in the server. To enable database type, use the command “use tutorials” in the query window.
Create Table
我们来在“tutorials”数据库中创建一个简单的表。
create table author(auth_id int not null, auth_name varchar(50),topic varchar(100))
Insert Table
创建表后,使用以下查询插入三条记录。
insert into author values(1,'Doug Cutting','Hadoop')
insert into author values(2,’James Gosling','java')
insert into author values(3,'Dennis Ritchie’,'C')
Connect Presto CLI
键入以下命令以在 Presto CLI 上连接 MySql 插件。
./presto --server localhost:8080 --catalog mysql --schema tutorials
您将收到以下应答。
presto:tutorials>
此处 “tutorials” 指的是 mysql 服务器中的架构。