Sample Header Ad - 728x90

Database Administrators

Q&A for database professionals who wish to improve their database skills

Latest Questions

0 votes
1 answers
151 views
mysql-shell: assign the return for dba.checkInstanceConfiguration() to a javascript variable
I am trying to create a javascript file that is invoked by mysql-shell that can automatically 1. test, using `dba.checkInstanceConfiguration("user@mysql-node:3306")`, if instance is ready for cluster devlopment 2. if not invoke dba.configureInstance("user@mysql-node:3306") 3. if instance is ready fo...
I am trying to create a javascript file that is invoked by mysql-shell that can automatically 1. test, using dba.checkInstanceConfiguration("user@mysql-node:3306"), if instance is ready for cluster devlopment 2. if not invoke dba.configureInstance("user@mysql-node:3306") 3. if instance is ready for cluster development, invoke: shell.connect("user@mysql-node:3306") cdCluster = dba.createCluster("cd-cluster"); cdCluster = dba.getCluster("cd-cluster"); cdCluster.addInstance("user@mysql-node:3306"); When we invoke: dba.checkInstanceConfiguration("user@mysql-node:3306") The resulting text contain either: { "status": "ok" } or something like { "config_errors": [ { "action": "server_update", "current": "COMMIT_ORDER", "option": "binlog_transaction_dependency_tracking", "required": "WRITESET" }, { "action": "server_update+restart", "current": "OFF", "option": "enforce_gtid_consistency", "required": "ON" }, { "action": "server_update+restart", "current": "OFF", "option": "gtid_mode", "required": "ON" }, { "action": "server_update+restart", "current": "1", "option": "server_id", "required": "" } ], "status": "error" } as part of the response. Is there a way one can get the json response for use in a javascript function that can be used to dynamically react by either invoking: dba.configureInstance("root@mysql-pri:3306"); or cdCluster = dba.createCluster("cd-cluster"); The documentation for dba.checkInstanceConfiguration("user@mysql-node:3306") suggest, the return is JSON. When I do: ret = dba.checkInstanceConfiguration("user@mysql-node:3306") console.log(ret) ..nothing is retured but I can see the text output. Can someone help please?
goremo (1 rep)
Aug 31, 2022, 06:23 PM • Last activity: Jul 19, 2025, 01:06 AM
4 votes
2 answers
158 views
MySQL: How to export the output for a non SQL query sentence?
In MySQL 8 server community to export a SQL query's output is possible execute in the `MySQL Shell` the following command (as most basic): ```mysql SELECT * FROM cientifico INTO OUTFILE '/var/lib/mysql-files/cientifico-data.txt'; ``` And it works as expected But for a non SQL query as follows: ```my...
In MySQL 8 server community to export a SQL query's output is possible execute in the MySQL Shell the following command (as most basic):
SELECT * FROM cientifico INTO OUTFILE '/var/lib/mysql-files/cientifico-data.txt';
And it works as expected But for a non SQL query as follows:
SHOW PROCESSLIST INTO OUTFILE '/var/lib/mysql-files/processlist.txt';
Throws the following error > ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO OUTFILE '/var/lib/mysql-files/processlist.txt'' at line 1 Same as:
SHOW DATABASES INTO OUTFILE '/var/lib/mysql-files/databases.txt';
Giving > ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO OUTFILE '/var/lib/mysql-files/databases.txt'' at line 1 Therefore if is possible **Question** * How to export the output for a non SQL query sentence? I am assuming that the INTO OUTFILE syntax is only for SQL sentences, but for non SQL sentences?
Manuel Jordan (229 rep)
Apr 18, 2025, 03:31 AM • Last activity: Apr 22, 2025, 08:27 PM
5 votes
3 answers
765 views
MySQL: Why doesn't the "use" command require ";" to be executed?
In MySQL 8 server community edition, here are examples of a _SQL query_ and _command_ in the `MySQL Shell`: ```mysql SELECT * FROM planet; DESC planet; SHOW DATABASES; SHOW tables; ``` As you can see is **mandatory** to declare the `;` character (or either `\g` or `\G` according the case) at the end...
In MySQL 8 server community edition, here are examples of a _SQL query_ and _command_ in the MySQL Shell:
SELECT * FROM planet;
DESC planet;
SHOW DATABASES;
SHOW tables;
As you can see is **mandatory** to declare the ; character (or either \g or \G according the case) at the end of the sentence. But I did realize by mistake that it is possible to execute the use command to change the database **without** ;. Therefore, the two following commands work in peace:
use 
use ;
Just being curious: **Question** * Why doesn't the use command require ; to be executed? To be honest I am not sure if it is the unique command with this situation but why it is different against others?
Manuel Jordan (229 rep)
Apr 18, 2025, 04:46 PM • Last activity: Apr 20, 2025, 01:17 AM
3 votes
1 answers
129 views
When use the SHOW PROCESSLIST vs SELECT * FROM information_schema.PROCESSLIST command?
In MySQL 8 server community the two following commands show the same structure: ```mysql SHOW PROCESSLIST; SELECT * FROM information_schema.PROCESSLIST; ``` **Question** * When use the `SHOW PROCESSLIST` vs `SELECT * FROM information_schema.PROCESSLIST` command? Each command exists for a specific re...
In MySQL 8 server community the two following commands show the same structure:
SHOW PROCESSLIST;
SELECT * FROM information_schema.PROCESSLIST;
**Question** * When use the SHOW PROCESSLIST vs SELECT * FROM information_schema.PROCESSLIST command? Each command exists for a specific reason, right? About their outputs I only found two differences for the State and Info columns for each command respectively:
State     | Info
----------------------------
init      | SHOW PROCESSLIST
executing | SELECT * FROM information_schema.PROCESSLIST
The difference of the Info column is clear because it represents the command itself that was executed **but**: * Why is different the State column? Is clear the executing value but: * What does the init value mean?
Manuel Jordan (229 rep)
Apr 17, 2025, 05:24 PM • Last activity: Apr 18, 2025, 04:35 PM
0 votes
1 answers
81 views
`--single-transaction` equivalent for mysqlsh util.dumpSchema
My database is using InnoDB, and when using `mysqldump` I have the option to set `--single-transaction` to avoid locking the tables while still having a consistent view of them. I'm trying to switch over to the recommended [MySQL Shell `util.dumpSchema`](https://dev.mysql.com/doc/mysql-shell/8.0/en/...
My database is using InnoDB, and when using mysqldump I have the option to set --single-transaction to avoid locking the tables while still having a consistent view of them. I'm trying to switch over to the recommended [MySQL Shell util.dumpSchema](https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-shell-utilities-dump-instance-schema.html) , and I only see two options: consistent: true and consistent: false. The documentation for consistent: true specifies that the tables will be locked for backup. Is it possible to use util.dumpSchema to dump in a single transaction via InnoDB in the same way? Or is this done automatically if the tables use InnoDB?
Nate Glenn (103 rep)
Dec 14, 2024, 07:39 AM • Last activity: Dec 15, 2024, 01:27 PM
0 votes
1 answers
676 views
Error during auto-completion cache update: Access denied
I'm trying the MySQL Shell for Windows. First time using this. I got as far as `\c` to connect, `\sql` to allow the familiar MySQL language, and a successful `show databases;` When I attempted to `use mydata;` it threw this: ``` Fetching global names, object names from `mydata` for auto-completion.....
I'm trying the MySQL Shell for Windows. First time using this. I got as far as \c to connect, \sql to allow the familiar MySQL language, and a successful show databases; When I attempted to use mydata; it threw this:
Fetching global names, object names from mydata for auto-completion... Press ^C to stop.
Error during auto-completion cache update: Access denied; you need (at least one of) the PROCESS privilege(s) for this operation
Robert Chapin (143 rep)
Jan 5, 2023, 10:02 PM • Last activity: Dec 10, 2023, 08:07 PM
2 votes
0 answers
106 views
Mysql shell seems not to dump deterministically. How can I minimise data transfer when rsyncing subsequent dumps?
What I'm trying to do is generate a full dump of my database using mysql shell, like so: util.dumpSchemas(["my_db"], "outdir", {threads:88, bytesPerChunk: "256M"}) And then rsync it to a remote nfs share that contains a previous version of the dump. I'd like to minimise the transferred data, so I wa...
What I'm trying to do is generate a full dump of my database using mysql shell, like so: util.dumpSchemas(["my_db"], "outdir", {threads:88, bytesPerChunk: "256M"}) And then rsync it to a remote nfs share that contains a previous version of the dump. I'd like to minimise the transferred data, so I was hoping mysql shell's dump utility would generate file chunks for old unchanged data in a repeatable manner (i.e. the files would checksum the same). However this has proved not to be the case, and in fact virtually all the files checksum differently after minor table updates. The [mysql docs](https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-shell-utilities-dump-instance-schema.html) say that the primary key is used to order & chunk the data, so I optimistically thought that any tables with autoincrementing primary keys should dump in a deterministic way. But that appears not to be the case as the produced files don't checksum the same. Maybe it's ordering rows in reverse? In any case I would love suggestions for how to do this.
Minsc (33 rep)
Aug 16, 2022, 12:12 AM
5 votes
2 answers
5011 views
Install mysql-shell from apt repository
I want to install and configure a high availability cluster for Mysql 8. To automate that, I want to use use apt repository (via ansible). My servers are debian jessy (8) distribution. I succesfully installed mysql server with commands : > sudo apt-key adv --keyserver pgp.mit.edu --recv-keys 5072E1F...
I want to install and configure a high availability cluster for Mysql 8. To automate that, I want to use use apt repository (via ansible). My servers are debian jessy (8) distribution. I succesfully installed mysql server with commands : > sudo apt-key adv --keyserver pgp.mit.edu --recv-keys 5072E1F5 > echo "deb http://repo.mysql.com/apt/debian jessie mysql-8.0" | \ sudo tee /etc/apt/sources.list.d/mysql80.list > sudo apt update > sudo apt install mysql-server It works fine. Now I want to install Mysql shell to manage a InnoDB cluster. It seems that it is available via apt repository as mentioned in this page : https://dev.mysql.com/downloads/repo/apt/ And installation is explained here : https://dev.mysql.com/doc/refman/8.0/en/installing-mysql-shell-linux-quick.html But when I execute a install via reposiory, I get an error : > sudo apt-get install mysql-shell with the message : > Reading package lists... Done Building dependency tree Reading state > information... Done E: Unable to locate package mysql-shell I have same error with server running on debian stretch (9).
gentiane (161 rep)
Oct 1, 2018, 09:26 AM • Last activity: Jul 15, 2022, 11:53 PM
1 votes
1 answers
393 views
Inndob Cluster - Automatically collect the output from mysqlsh?
Is there a way to take the output from mysqlshell and use it in a script or similar. I have set up a basic cluster for testing (3 x MySQL 8.0.27 databases, running on Debian 11). I am now trying to find a way to capture the output from mysqlshell's `cluster.status()` output. As an example, from insi...
Is there a way to take the output from mysqlshell and use it in a script or similar. I have set up a basic cluster for testing (3 x MySQL 8.0.27 databases, running on Debian 11). I am now trying to find a way to capture the output from mysqlshell's cluster.status() output. As an example, from inside mysqlshell I can run: cluster=dba.getCluster() cluster.status().defaultReplicaSet.topology['test-1:3306'].replicationLag to get the current replication lag. I would like to capture that so it can be monitored automatically. I assumed most of these statistics would also exist in the performance_schema or mysql_innodb_cluster_metadata databases somewhere, but I can't see them. Is there a way to do this?
IGGt (2276 rep)
Jan 21, 2022, 02:29 PM • Last activity: Jan 27, 2022, 03:48 PM
1 votes
1 answers
3123 views
How can the (JSON) formatted results from MySQL Shell be saved to a file?
Somewhat uniquely among official MySQL applications, MySQL Shell offers (easy) JSON output. From the MySQL shell prompt, typing the following will get you results as a JavaScript array of objects (one for each row): \option resultFormat json/array \use information_schema SELECT table_catalog, table_...
Somewhat uniquely among official MySQL applications, MySQL Shell offers (easy) JSON output. From the MySQL shell prompt, typing the following will get you results as a JavaScript array of objects (one for each row): \option resultFormat json/array \use information_schema SELECT table_catalog, table_schema, table_name, engine, create_time, table_collation FROM tables WHERE table_schema='INFORMATION_SCHEMA' AND table_name LIKE 'T%'; This is then passed to a pager for display on-screen. How can the output instead be redirected or otherwise saved to a file (named e.g. results.json)? (Note: the query could be anything. The above is provided as a simple, yet not trivial, test case that should be runnable against any MySQL installation.) As MySQL Shell is available on various platforms, platform agnostic solutions are preferred, but solutions for specific platforms are also of interest.
outis (375 rep)
Nov 6, 2021, 03:11 AM • Last activity: Nov 11, 2021, 10:23 AM
2 votes
1 answers
2192 views
How to start mysql-shell in mysql-js JavaScript mode?
How can I change the `mysqlsh` shell to `mysql-js` JavaScript mode? Somehow initially I'm in `mysql-py`, and I cannot switch to `\js`, only to `\sql`. Why? $ mysqlsh root@localhost:33060 Cannot set LC_ALL to locale en_US.UTF-8: No such file or directory Please provide the password for 'root@localhos...
How can I change the mysqlsh shell to mysql-js JavaScript mode? Somehow initially I'm in mysql-py, and I cannot switch to \js, only to \sql. Why? $ mysqlsh root@localhost:33060 Cannot set LC_ALL to locale en_US.UTF-8: No such file or directory Please provide the password for 'root@localhost:33060': ****** MySQL Shell 8.0.23 Copyright (c) 2016, 2021, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type '\help' or '\?' for help; '\quit' to exit. Creating a session to 'root@localhost:33060' Fetching schema names for autocompletion... Press ^C to stop. Your MySQL connection id is 240 (X protocol) Server version: 8.0.27-0ubuntu0.20.04.1 (Ubuntu) No default schema selected; type \use to set one. mysql-py []> \js Unknown command: '\js' mysql-py []> \sql Switching to SQL mode... Commands end with ; mysql-sql []> Installed from: apt snap install mysql-shell.
membersound (331 rep)
Nov 10, 2021, 10:42 AM • Last activity: Nov 10, 2021, 10:55 AM
0 votes
1 answers
142 views
MySQL Shell dump utility - maximum possible chunk size?
The documentation https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-shell-utilities-dump-instance-schema.html mentions that the min chunk size is 128kB. What is the maximum possible chunk size?
The documentation https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-shell-utilities-dump-instance-schema.html mentions that the min chunk size is 128kB. What is the maximum possible chunk size?
Mihir Rane (1 rep)
Oct 28, 2020, 04:22 PM • Last activity: Nov 5, 2021, 11:36 PM
Showing page 1 of 12 total questions