MySQL command line not doing anything - mysql

I'm completely new to SQL and am following the MySQL tutorial for set up. In the command line client, none of the commands seem to do anything except give me an arrow -> which just sits there. I've tried the SHOW DATABASES and CREATE DATABASE test commands and nothing. The only thing that seems to do anything is the \c command which removes the arrow and takes me back to the mysql> prompt. This is an example of what it looks like:

You need to terminate the command with a semicolon (;).

Related

MySQL Change Password command run in MySQL on Ubuntu Server results in strange Character Changes in terminal

I'm running an Ubuntu Server with MySQL in VirtualBox and trying to change the password for a user.
I run:
sudo mysql -u root -p
to access MySQL. At this point, and with any other commands not trying to see a user's password, everything is working.
In MySQL ( ) I run:
SELECT * FROM mysql.user;
After I run this, the entire display and terminal change. The output and command line are both displaying strange characters. I run this command which works just fine. What gives?
SELECT user FROM mysql.user;
Here are the before and after screen shots:
Screen Shot Before,
Screen Shot After
Any help would be greatly appreciated. I have no clue why this is happening. Is this an Ubuntu thing, a MySQL thing or a VirtualBox thing? I'm a noob so this is just an uninformed theory but could it have something to do with MySQL authenticated_string and something to do with hashing?
It actually creates a change that persists even upon typing exit and hitting Enter, exiting MySQL and back to the Ubuntu command line where the weird characters are still showing.
EDIT:
I was following a blog tutorial and inserted <db-password> as the password when creating the MySQL user. I was supposed to insert an actual new password instead but figured I'd just use that. Are the <, - or > characters that I used when setting the user's MySQL password maybe causing this?
I believe this was a character encoding issue in MySQL because SELECT * FROM mysql.user WHERE user = 'root'; doesn't have the same issue. Because of that, I believe the issue only occurs at that one user's password data point where the <, - and > characters were used. Maybe someone else can provide a better answer explaining more thoroughly why this occurs. Specifically, I'm curious as to how this issue in MySQL is then able to affect the appearance of the Ubuntu Command Line once the MySQL shell is exited.

MySQL ERROR: Not Connected

I am learning MySQL and stumbled upon a problem after installation of MySQL. I switched to sql mode and from there I tried to connect to root#localhost but after I inputted the password, it says there is no such Host. I tried other host names, but the same results show where it says
ERROR: 2005: No such host is known 'hostname'
I even tried to make a simple table, but when I enter it, I get the error that says ERROR: Not Connected, which was expected. How exactly do I get through this, I am a bit lost despite having everything installed.
I use commands such as:
mysql-sql> \connect 127.0.01;
From there enter a password and no success.
Check the list of hosts names inside this file
C:\Windows\System32\drivers\etc\hosts
If you can't see this 127.0.0.1 localhost add it on new line on bottom.
If it's there but the line start with # remove this symbol.
You can try "127.0.01" instead localhost.
I think, Felipe meant \connect root#127.0.0.1 instead of 127.0.01

Delphi + MySQL command line

I'm building a tool using Delphi and MySQL to restore a script generated with MySQLDump.
It was supposed to load and execute a SQL file and log any possible errors into a given output file.
I thought about execute the mysql command line and send command lines but i don't know if its possible ou how to do it since I just know how to call mysql using windows cmd and execute a single command line using ShellExecute or CreateProcess
I tried to do it with a single command line but it did'nt logged the errors properly
I tried this:
cmd /c mysql.exe --user root < "C:\restore.sql" > "C:\restore_log.txt"
the content of restore.sql was:
drop database test;
It does execute my script, but on the second attempt it should log "database doesn't exist" but restore_log.txt was empty
It would help if anyone could point the way to call mysql and send multiple lines OR a help with my cmd line to log properly
Anyone can help me?
I don't know what components you've got available to connect to the MySQL db, but using TADOQuery to access SQL Server, I simply load up the queries into a TADOQuery's .SQL property and then call Open or ExecSQL. As long as it's just vanilla SQL that was generated by SQLDump, I'd guess that should work. It's worth a try anyway.
digging more at stackoverflow I found previous answers that helped, the difference is that the output goes to a Memo that I can save to a file.
Thank you all for the help and the insights.
The answers can be found on the following links:
Getting output from a shell/dos app into a Delphi app
How do I run a command-line program in Delphi?
Getting output from a shell/dos app into a Delphi app

No system command when using mysql from cli

Attempting to change directories, view directory contents, etc., but for some reason I don't have the system command to use the command line once I run mysql. These are the options I get:
List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
? (\?) Synonym for `help'.
clear (\c) Clear the current input statement.
connect (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter.
ego (\G) Send command to mysql server, display result vertically.
exit (\q) Exit mysql. Same as quit.
go (\g) Send command to mysql server.
help (\h) Display this help.
notee (\t) Don't write into outfile.
print (\p) Print current command.
prompt (\R) Change your mysql prompt.
quit (\q) Quit mysql.
rehash (\#) Rebuild completion hash.
source (\.) Execute an SQL script file. Takes a file name as an argument.
status (\s) Get status information from the server.
tee (\T) Set outfile [to_outfile]. Append everything into given outfile.
use (\u) Use another database. Takes database name as argument.
charset (\C) Switch to another charset. Might be needed for processing binlog
with multi-byte charsets.
warnings (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.
Any ideas what could cause this? It seems to be possible using windows (using \!).
As stated in the MySQL documentation, the MySQL system command works only in Unix and therefore not in Windows:
http://dev.mysql.com/doc/refman/5.6/en/mysql-commands.html

MySQL shell displaying results into something like "less"

Running the following command in a remote login attempt in a MySQL shell.
show variables;
The query only shows the last 50 or so variables out of 233. I would like the result to be scrollable so that I can review all of the variables. Something like a redirect to 'less.'
As it is, I am stumped.
You could try using the following command to set a "less"-type of behavior in the MySQL command line:
pager less
Also, this behavior can be turned off by using this command:
pager
(Note: This might not work on every flavor of MySQL... for more information, check the docs.)