Configuring MySQL's mysqlsh to accept SQL and connect by default - mysql

How do I configure the MySQL 8.0.15 shell. I just downloaded it and I am already having problems.
When I run the shell program I always have to switch from MySQL JS to MySQL SQL
I always have to reconnect using \connect root#localhost
I would like to open the MySQL shell and just get to work without having to do those two things.

If you start the shell with mysqlsh --sql --uri=myname#localhost it will accept SQL commands directly.
If you need only to use SQL you may wish to consider using the ancient and honorable mysql command line client program. mysql -h localhost -u myname

Related

MySQL CLI Client shows data as Hex

My MySQL CLI client when connecting to a database is automatically showing the data as hex
Connecting in CLI using mysql -u user -p'password' -h host -P port --ssl-mode=DISABLED
To turn this off I have to run it with the --skip-binary-as-hex option to see the data properly
Need help understanding what is causing this is getting enabled by default.
This issue does not exist for other users logging into the same database and is not an issue for me I connect through a DB tool, it occurs only on CLI
Prior to MySQL 8.0.19, the issue which you are facing did not exist. binary-as-hex client option is enabled by default from MySQL 8.0.19 Command Line Client.
Run status or \s in MySQL Command Line Client. You will notice a line about binary data like this:
Binary data as: Hexadecimal
You can refer these links for more information:
https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_char
https://dev.mysql.com/doc/refman/8.0/en/mysql-command-options.html#option_mysql_binary-as-hex

Where can I run a mysql command line under Azure to fix "The used command is not allowed with this MySQL version (1148)"

I have a MySQL database which is hosted in Azure, and I have MySQL Workbench installed on my laptop. I want to do some importing from a CSV file located in my laptop, but whenever I try to that, I get an error message saying:
The used command is not allowed with this MySQL version
I did some online searching, and I found out that I need to run the following command:
mysql -u myuser -p --local-infile somedatabase
But, I don't know where I have to run it, and how, while as I said my database is hosted in Azure.
mysql is just the commandline executable of the MySql client. And most probably it is even part of the MySql workbech - just check the MySQL Workbech working folder. But the result will not be different is my guess.
The best way you can manage Import/Export for MySQL is to use a Free Tier WebSite and Install the phpMyAdmin extension.

skip-secure-auth option not working with mysqldump

I am trying to export a mysql schema from remote server to local but geting the following error:
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysqldump --skip-secure-auth -h x.y.z.d -uatulya -p'root' t_tcadmin |mysql -u root -proot t_tcadmin
mysqldump: unknown option '--skip-secure-auth'
Warning: Using a password on the command line interface can be insecure.
Without the --skip-secure-auth it connects but I get error 2049.
So I want to use this option to skip secure auth but it is giving the above error. Could anyone suggest.
Thanks..
If you are in a pinch, dealing with an older server where updating the passwords to the newer method is not an option (say, MySQL Server v5.0.95) and attempting to migrate the data to a newer system - without modifying the fragile older system, you may need to temporarily downgrade your local mysql client to 5.5 for myasqldump to be able to talk to the older server. As of 5.6 it is possible to use the MySQL client to connect to it - using --skip-secure-auth in the command, but mysqldump will not accept that flag. And, in MySQL 5.7+ it is impossible to connect to a server that uses the older password storage method at all.

MySQL Syntax Error (Ubuntu LAMP Server)

Alright, so I've got a fairly fresh Ubuntu (server) installation. Just finished installing the LAMP server and when I go to create a database I'm getting the generic syntax error (1064 / 42000).
My query:
CREATE DATABASE phpbb;
Pretty simple and pretty standard, so I'm not sure what the issue is. Any ideas?
It looks from your error like you're trying to execute SQL on the command line, something like:
mysql -u mike -p CREATE DATABASE phpbb';
MySQL isn't going to like that, it separates the initiation of the tool from the SQL commands.
What I'd normally do for CREATE DATABASE, as it's a one off, I'd do it manually.
So start the tool with
mysql -u mike -p
This should prompt you for your password, and connect to the local database, giving you a shell prompt:
mysql>
You then issue your
CREATE DATABASE phpbb;
If you want to run scripts from the command line, put them in a file and redirect the input to mysql. Usually you'd redirect the output too - something like this:
mysql -u mike -p < mysqlscript.sql > outputofscript.log

mysql workbench ssh custo command

I'm trying to configure a new connection through SSH tunnel.
But on the server, the command mysql does not exists. I have my own compilation called custo-mysql.
I mean, when I'm on the server, I use the following command :
$ custo-mysql -u root -pmypassword
How can I tell workbench to use custo-mysql and not mysql ?
mysql (and your custo-mysql) is a client for the server. Workbench is a client as well, so it doesn't need to use that custo-mysql thing. It just connects to your server.
Basically, on your server you have a "mysqld" running: a mysql server. Your commans custo-mysql connects to that server as a sort of interface. Workbench has the exact same function, so it should work if your networking/tunneling etc is correct.
As #Nanne already mentioned, you don't need the mysql client to connect to your MySQL server using Workbench.
I would just like to point out that Workbench does use the mysql command line client for importing databases in the Admin / Data Import/Restore section. Having said that, you'll certainly be OK without it for everything else.
Cheers,