info about MySQL Shell

202 views Asked by At

I'm using the MySQL shell for the first time. I ran the following commands:

    \connect --mysql root@localhost:3306
    \use myschema

But, when I try to follow this instruction:

    myColl = db.createCollection('my_coll')

I get the error:

    TypeError: Cannot read property 'createCollection' of null

The error obviously is due to the fact that db object is null, but I don't know the syntax to instantiate it.

1

There are 1 answers

0
ruiquelhas On

Commands like createCollection() are part of the X DevAPI which is a client-side interface for the MySQL X Protocol. You are using --mysql which creates a connection to the server using the MySQL Classic Protocol, which only supports SQL. To create an X Protocol connection, and assuming the X Plugin is enabled in the default server port, you should use --mysqlx instead:

\connect --mysqlx root@localhost:33060

Disclaimer: I'm the lead developer of the MySQL X DevAPI Connector for Node.js