Mysql Cmd Xampp

  1. Get code examples like 'how to run xampp mysql in command prompt' instantly right from your google search results with the Grepper Chrome Extension.
  2. Hello @kartik, Your MySQL binaries should be somewhere under your XAMPP folder. Look for a /bin folder, and you'll find the mysql.exe client around. Let's assume it is in c: xampp mysql bin, then you should fireup a command prompt in this folder.

C: xampp mysql binmysql -V mysql Ver 15.1 Distrib 5.4.1, for Win32 (AMD64) Alternatively, you will find a readmeen.txt file in your xampp installation folder. It will contain MySQL version number used for xampp installation, and looks something like the following.

Contents

  1. Using mysql
    1. Option Files
  2. How to Specify Which Protocol to Use When Connecting to the mysqld Server
  3. mysql Tips

About the mysql Command-Line Client

mysql (from MariaDB 10.4.6, also called mariadb) is a simple SQL shell (with GNU readlinecapabilities). It supports interactive and non-interactive use. When usedinteractively, query results are presented in an ASCII-table format. When usednon-interactively (for example, as a filter), the result is presented intab-separated format. The output format can be changed using command options.

If you have problems due to insufficient memory for large result sets, use the--quick option. This forces mysql to retrieve results fromthe server a row at a time rather than retrieving the entire result set andbuffering it in memory before displaying it. This is done by returning theresult set using the mysql_use_result() C API function in theclient/server library rather than mysql_store_result().

Using mysql is very easy. Invoke it from the prompt of your command interpreteras follows:

Or:

Then type an SQL statement, end it with “;”, g, or G and press Enter.

Typing Control-C causes mysql to attempt to kill thecurrent statement. If this cannot be done, or Control-C is typed again beforethe statement is killed, mysql exits.

You can execute SQL statements in a script file (batch file) like this:

From MariaDB 10.4.6, mariadb is available as a symlink to mysql.

From MariaDB 10.5.2, mysql is the symlink, and mariadb the binary name.

Using mysql

The command to use mysql and the general syntax is:

Options

mysql supports the following options:

OptionDescription
-?, --helpDisplay this help and exit.
-I, --helpSynonym for -?
--abort-source-on-errorAbort 'source filename' operations in case of errors.
--auto-rehashEnable automatic rehashing. This option is on by default, which enables database, table, and column name completion. Use --disable-auto-rehash, --no-auto-rehash or skip-auto-rehash to disable rehashing. That causes mysql to start faster, but you must issue the rehash command if you want to use name completion. To complete a name, enter the first part and press Tab. If the name is unambiguous, mysql completes it. Otherwise, you can press Tab again to see the possible names that begin with what you have typed so far. Completion does not occur if there is no default database.
-A, --no-auto-rehashNo automatic rehashing. One has to use 'rehash' to get table and field completion. This gives a quicker start of mysql and disables rehashing on reconnect.
--auto-vertical-outputAutomatically switch to vertical output mode if the result is wider than the terminal width.
-B, --batchPrint results using tab as the column separator, with each row on a new line. With this option, mysql does not use the history file. Batch mode results in nontabular output format and escaping of special characters. Escaping may be disabled by using raw mode; see the description for the --raw option. (Enables --silent.)
--binary-modeBy default, ASCII '0' is disallowed and 'rn' is translated to 'n'. This switch turns off both features, and also turns off parsing of all client commands except C and DELIMITER, in non-interactive mode (for input piped to mysql or loaded using the 'source' command). This is necessary when processing output from mysqlbinlog that may contain blobs.
--character-sets-dir=nameDirectory for character set files.
--column-namesWrite column names in results. (Defaults to on; use --skip-column-names to disable.)
--column-type-infoDisplay column type information.
-c, --commentsPreserve comments. Send comments to the server. The default is --skip-comments (discard comments), enable with --comments.
-C, --compressCompress all information sent between the client and the server if both support compression.
--connect-expired-passwordNotify the server that this client is prepared to handle expired password sandbox mode even if --batch was specified. From MariaDB 10.4.3.
--connect-timeout=numNumber of seconds before connection timeout. Defaults to zero.
-D, --database=nameDatabase to use.
-# [options], --debug[=options]On debugging builds, write a debugging log. A typical debug_options string is d:t:o,file_name. The default is d:t:o,/tmp/mysql.trace.
--debug-checkCheck memory and open file usage at exit.
-T, --debug-infoPrint some debug info at exit.
--default-auth=pluginDefault authentication client-side plugin to use.
--default-character-set=nameSet the default character set. A common issue that can occur when the operating system uses utf8 or another multibyte character set is that output from the mysql client is formatted incorrectly, due to the fact that the MariaDB client uses the latin1 character set by default. You can usually fix such issues by using this option to force the client to use the system character set instead. If set to auto the character set is taken from the client environment (LC_CTYPE on Unix).
--defaults-extra-file=fileRead this file after the global files are read. Must be given as the first option.
--defaults-file=fileOnly read default options from the given file. Must be given as the first option.
--defaults-group-suffix=suffixIn addition to the given groups, also read groups with this suffix.
--delimiter=nameDelimiter to be used. The default is the semicolon character (“;”).
-e, --execute=nameExecute statement and quit. Disables --force and history file. The default output format is like that produced with --batch.
-f, --forceContinue even if we get an SQL error. Sets --abort-source-on-error to 0.
-h, --host=nameConnect to host.
-H, --htmlProduce HTML output.
-U, --i-am-a-dummySynonym for option --safe-updates, -U.
-i, --ignore-spacesIgnore space after function names. Allows one to have spaces (including tab characters and new line characters) between function name and '('. The drawback is that this causes built in functions to become reserved words.
--init-command=strSQL Command to execute when connecting to the MariaDB server. Will automatically be re-executed when reconnecting.
--line-numbersWrite line numbers for errors. (Defaults to on; use --skip-line-numbers to disable.)
--local-infileEnable or disable LOCAL capability for LOAD DATA INFILE. With no value, the option enables LOCAL. The option may be given as--local-infile=0 or --local-infile=1 to explicitly disable or enable LOCAL. Enabling LOCAL has no effect if the server does not also support it.
--max-allowed-packet=numThe maximum packet length to send to or receive from server. The default is 16MB, the maximum 1GB.
--max-join-size=numAutomatic limit for rows in a join when using --safe-updates. Default is 1000000.
-G, --named-commandsEnable named commands. Named commands mean mysql's internal commands (see below) . When enabled, the named commands can be used from any line of the query, otherwise only from the first line, before an enter. Long-format commands are allowed, not just short-format commands. For example, quit and q are both recognized. Disable with --disable-named-commands. This option is disabled by default.
--net-buffer-length=numThe buffer size for TCP/IP and socket communication. Default is 16KB.
-b, --no-beepTurn off beep on error.
--no-defaultsDon't read default options from any option file. Must be given as the first option.
-o, --one-databaseIgnore statements except those those that occur while the default database is the one named on the command line. This filtering is limited, and based only on USE statements. This is useful for skipping updates to other databases in the binary log.
--pager[=name]Pager to use to display results (Unix only). If you don't supply an option, the default pager is taken from your ENV variable PAGER. Valid pagers are less, more, cat [> filename], etc. See interactive help (h) also. This option does not work in batch mode. Disable with --disable-pager. This option is disabled by default.
-p, --password[=name]Password to use when connecting to server. If you use the short option form (-p), you cannot have a space between the option and the password. If you omit the password value following the --password or -p option on the command line, mysql prompts for one. Specifying a password on the command line should be considered insecure. You can use an option file to avoid giving the password on the command line.
--plugin-dir=nameDirectory for client-side plugins.
-P, --port=numPort number to use for connection or 0 for default to, in order of preference, my.cnf, $MYSQL_TCP_PORT, /etc/services, built-in default (3306).
--print-defaultsPrint the program argument list and exit. Must be given as the first option.
--progress-reportsGet progress reports for long running commands (such as ALTER TABLE). (Defaults to on; use --skip-progress-reports to disable.)
--prompt=nameSet the mysql prompt to this value. See prompt command for options.
--protocol=nameThe protocol to use for connection (tcp, socket, pipe, memory).
-q, --quickDon't cache result, print it row by row. This may slow down the server if the output is suspended. Doesn't use history file.
-r, --rawFor tabular output, the “boxing” around columns enables one column value to be distinguished from another. For nontabular output (such as is produced in batch mode or when the --batch or --silent option is given), special characters are escaped in the output so they can be identified easily. Newline, tab, NUL, and backslash are written as n, t, 0, and
. The --raw option disables this character escaping.
--reconnectReconnect if the connection is lost. This option is enabled by default. Disable with --disable-reconnect or skip-reconnect.
-U, --safe-updatesAllow only those UPDATE and DELETE statements that specify which rows to modify by using key values. If you have set this option in an option file, you can override it by using --safe-updates on the command line. See using the --safe-updates option for more.
--secure-authRefuse client connecting to server if it uses old (pre-MySQL4.1.1) protocol. Defaults to false (unlike MySQL since 5,6, which defaults to true).
--select-limit=numAutomatic limit for SELECT when using --safe-updates. Default 1000.
--server-arg=nameSend embedded server this as a parameter.
--shared-memory-base-name=nameShared-memory name to use for Windows connections using shared memory to a local server (started with the --shared-memory option). Case-sensitive.
--show-warningsShow warnings after every statement. Applies to interactive and batch mode.
--sigint-ignoreIgnore SIGINT signals (usually CTRL-C).
-s, --silentBe more silent. This option can be given multiple times to produce less and less output. This option results in nontabular output format and escaping of special characters. Escaping may be disabled by using raw mode; see the description for the --raw option.
-L, --skip-auto-rehashDisable automatic rehashing. See --auto-rehash.
-N, --skip-column-namesDon't write column names in results. See --column-names.
-L, --skip-commentsDiscard comments. Set by default, see --comments to enable.
-L, --skip-line-numbersDon't write line number for errors. See --line-numbers.
-L, --skip-progress-reportsDisables getting progress reports for long running commands. See --progress-reports.
-L, --skip-reconnectDon't reconnect if the connection is lost. See --reconnect.
-S, --socket=nameFor connections to localhost, the Unix socket file to use, or, on Windows, the name of the named pipe to use.
--sslEnables TLS. TLS is also enabled even without setting this option when certain other TLS options are set. Starting with MariaDB 10.2, the --ssl option will not enable verifying the server certificate by default. In order to verify the server certificate, the user must specify the --ssl-verify-server-cert option.
--ssl-ca=nameDefines a path to a PEM file that should contain one or more X509 certificates for trusted Certificate Authorities (CAs) to use for TLS. This option requires that you use the absolute path, not a relative path. See Secure Connections Overview: Certificate Authorities (CAs) for more information. This option implies the --ssl option.
--ssl-capath=nameDefines a path to a directory that contains one or more PEM files that should each contain one X509 certificate for a trusted Certificate Authority (CA) to use for TLS. This option requires that you use the absolute path, not a relative path. The directory specified by this option needs to be run through the openssl rehash command. See Secure Connections Overview: Certificate Authorities (CAs) for more information. This option is only supported if the client was built with OpenSSL or yaSSL. If the client was built with GnuTLS or Schannel, then this option is not supported. See TLS and Cryptography Libraries Used by MariaDB for more information about which libraries are used on which platforms. This option implies the --ssl option.
--ssl-cert=nameDefines a path to the X509 certificate file to use for TLS. This option requires that you use the absolute path, not a relative path. This option implies the --ssl option.
--ssl-cipher=nameList of permitted ciphers or cipher suites to use for TLS. This option implies the --ssl option.
--ssl-crl=nameDefines a path to a PEM file that should contain one or more revoked X509 certificates to use for TLS. This option requires that you use the absolute path, not a relative path. See Secure Connections Overview: Certificate Revocation Lists (CRLs) for more information. This option is only supported if the client was built with OpenSSL or Schannel. If the client was built with yaSSL or GnuTLS, then this option is not supported. See TLS and Cryptography Libraries Used by MariaDB for more information about which libraries are used on which platforms.
--ssl-crlpath=nameDefines a path to a directory that contains one or more PEM files that should each contain one revoked X509 certificate to use for TLS. This option requires that you use the absolute path, not a relative path. The directory specified by this option needs to be run through the openssl rehash command. See Secure Connections Overview: Certificate Revocation Lists (CRLs) for more information. This option is only supported if the client was built with OpenSSL. If the client was built with yaSSL, GnuTLS, or Schannel, then this option is not supported. See TLS and Cryptography Libraries Used by MariaDB for more information about which libraries are used on which platforms.
--ssl-key=nameDefines a path to a private key file to use for TLS. This option requires that you use the absolute path, not a relative path. This option implies the --ssl option.
--ssl-verify-server-certEnables server certificate verification. This option is disabled by default.
-t, --tableDisplay output in table format. This is the default for interactive use, but can be used to produce table output in batch mode.
--tee=nameAppend everything into outfile. See interactive help (h) also. Does not work in batch mode. Disable with --disable-tee. This option is disabled by default.
--tls-version=nameThis option accepts a comma-separated list of TLS protocol versions. A TLS protocol version will only be enabled if it is present in this list. All other TLS protocol versions will not be permitted. See Secure Connections Overview: TLS Protocol Versions for more information. This option was added in MariaDB 10.4.6.
-n, --unbufferedFlush buffer after each query.
-u, --user=nameUser for login if not current user.
-v, --verboseWrite more. (-v -v -v gives the table output format).
-V, --versionOutput version information and exit.
-E, --verticalPrint the output of a query (rows) vertically. Use the G delimiter to apply to a particular statement if this option is not enabled.
-w, --waitIf the connection cannot be established, wait and retry instead of aborting.
-X, --xmlProduce XML output. See the mysqldump --xml option for more.

Option Files

In addition to reading options from the command-line, mysql can also read options from option files. If an unknown option is provided to mysql in an option file, then it is ignored.

The following options relate to how MariaDB command-line tools handles option files. They must be given as the first argument on the command-line: Gmt +14.

OptionDescription
--print-defaultsPrint the program argument list and exit.
--no-defaultsDon't read default options from any option file.
--defaults-file=# Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.
--defaults-group-suffix=# In addition to the default option groups, also read option groups with this suffix.

In MariaDB 10.2 and later, mysql is linked with MariaDB Connector/C. However, MariaDB Connector/C does not yet handle the parsing of option files for this client. That is still performed by the server option file parsing code. See MDEV-19035 for more information.

Option Groups

mysql reads options from the following option groups from option files:

GroupDescription
[mysql] Options read by mysql, which includes both MariaDB Server and MySQL Server.
[mariadb-client]Options read by mysql. Available starting with MariaDB 10.4.6.
[client] Options read by all MariaDB and MySQL client programs, which includes both MariaDB and MySQL clients. For example, mysqldump.
[client-server]Options read by all MariaDB client programs and the MariaDB Server. This is useful for options like socket and port, which is common between the server and the clients.
[client-mariadb]Options read by all MariaDB client programs.

How to Specify Which Protocol to Use When Connecting to the mysqld Server

The following is true for all MySQL and MariaDB command line clients:

You can force which protocol to be used to connect to the mysqld server by giving the protocol option one of the following values: tcp, socket, pipe or memory.

If protocol is not specified, then the following happens:

Linux/Unix

  • If hostname is not specified or hostname is localhost, then Unix sockets are used. Unused connection parameters (such as port) will be ignored.
  • In other cases (hostname is given and it's not localhost) then a tcpip connection through the port option is used.

Note that localhost is a special value. Using 127.0.0.1 is not the same thing. The latter will connect to the mysqld server through tcpip.

Windows

  • If shared-memory-base-name is specified and hostname is not specified or hostname is localhost, then the connection will happen through shared memory. Unused connection parameters (such as port) will be ignored.
  • If shared-memory-base-name is not specified and hostname is not specified or hostname is localhost, then the connection will happen through windows named pipes.
  • Named pipes will also be used if the libmysql / libmariadb client library detects that the client doesn't support tcpip.
  • In other cases then a tcpip connection through the port option is used.

How to Test Which Protocol is Used

The status command shows you information about which protocol is used:

mysql Commands

There are also a number of commands that can be run inside the client. Note that all text commands must be first on line and end with ';'

CommandDescription
?, ?Synonym for `help'.
clear, cClear the current input statement.
connect, rReconnect to the server. Optional arguments are db and host.
delimiter, dSet statement delimiter.
edit, eEdit command with $EDITOR.
ego, GSend command to mysql server, display result vertically.
exit, qExit mysql. Same as quit.
go, gSend command to mysql server.
help, hDisplay this help.
nopager, nDisable pager, print to stdout.
notee, tDon't write into outfile.
pager, PSet PAGER [to_pager]. Print the query results via PAGER.
print, pPrint current command.
prompt, RChange your mysql prompt. See prompt command for options.
quit, qQuit mysql.
rehash, # Rebuild completion hash.
source, .Execute an SQL script file. Takes a file name as an argument.
status, sGet status information from the server.
system, !Execute a system shell command. Only works in Unix-like systems.
tee, TSet outfile [to_outfile]. Append everything into given outfile.
use, uUse another database. Takes database name as argument.
charset, CSwitch to another charset. Might be needed for processing binlog with multi-byte charsets.
warnings, WShow warnings after every statement.
nowarning, wDon't show warnings after every statement.

The mysql_history File

On Unix, the mysql client writes a record of executed statements to a historyfile. By default, this file is named .mysql_history and is created in your homedirectory. To specify a different file, set the value of the MYSQL_HISTFILEenvironment variable.

The .mysql_history file should be protected with a restrictive access mode becausesensitive information might be written to it, such as the text of SQLstatements that contain passwords.

If you do not want to maintain a history file, first remove .mysql_history ifit exists, and then use either of the following techniques:

  • Set the MYSQL_HISTFILE variable to /dev/null. To cause this setting to take effect each time you log in, put the setting in one of your shell's startup files.
  • Create .mysql_history as a symbolic link to /dev/null:

You need do this only once.

prompt Command

The prompt command reconfigures the default prompt N [d]>. The string for defining the prompt can contain the following special sequences.

OptionDescription
cA counter that increments for each statement you issue.
DThe full current date.
dThe default database.
hThe server host.
lThe current delimiter.
mMinutes of the current time.
nA newline character.
OThe current month in three-letter format (Jan, Feb, ..).
oThe current month in numeric format.
Pam/pm.
pThe current TCP/IP port or socket file.
RThe current time, in 24-hour military time (0–23).
rThe current time, standard 12-hour time (1–12).
SSemicolon.
sSeconds of the current time.
tA tab character.
UYour full [email protected]_name account name.
uYour user name.
vThe server version.
wThe current day of the week in three-letter format (Mon, Tue, ..).
YThe current year, four digits.
yThe current year, two digits.
_A space.
A space (a space follows the backslash).
'Single quote.
'Double quote.
A literal “” backslash character.
xx, for any “x” not listed above.

mysql Tips

This section describes some techniques that can help you usemysql more effectively.

Displaying Query Results Vertically

Some query results are much more readable when displayed vertically, instead ofin the usual horizontal table format. Queries can be displayed vertically byterminating the query with G instead of a semicolon. For example, longer textvalues that include newlines often are much easier to read with verticaloutput:

Mysql Cmd Xampp Free

Using the --safe-updates Option

For beginners, a useful startup option is --safe-updates (or--i-am-a-dummy, which has the same effect). It is helpfulfor cases when you might have issued a DELETE FROM tbl_name statement but forgotten theWHERE clause. Normally, such a statement deletes all rowsfrom the table. With --safe-updates, you can delete rowsonly by specifying the key values that identify them. This helps preventaccidents.

When you use the --safe-updates option, mysql issues thefollowing statement when it connects to the MariaDB server:

The SET statement has the following effects:

  • You are not allowed to execute an UPDATE or DELETE statement unless you specify a key constraint in the WHERE clause or provide a LIMIT clause (or both). For example:
  • The server limits all largeSELECT results to 1,000 rows unless the statement includes a LIMIT clause.
  • The server aborts multiple-table SELECT statements that probably need to examine more than 1,000,000 row combinations.

To specify limits different from 1,000 and 1,000,000, you can override thedefaults by using the --select_limit and --max_join_size options:

Disabling mysql Auto-Reconnect

If the mysql client loses its connection to the server while sending astatement, it immediately and automatically tries to reconnect once to theserver and send the statement again. However, even if mysql succeeds inreconnecting, your first connection has ended and all your previous sessionobjects and settings are lost: temporary tables, the autocommit mode, anduser-defined and session variables. Also, any current transaction rolls back.This behavior may be dangerous for you, as in the following example where theserver was shut down and restarted between the first and second statementswithout you knowing it:

The @a user variable has been lost with the connection, and after thereconnection it is undefined. If it is important to have mysql terminate withan error if the connection has been lost, you can start the mysql client withthe --skip-reconnect option.

See Also

Comments

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.

XAMPP stack of software is an open-source localhost server providing a number of functionalities through the package of software it contains. The software, which is part of XAMPP is started/stopped using the XAMPP Control Panel. It is used for testing the projects and modifications offline before launching it on the global web. One such very important functionality provided by XAMPP is the creation of the MySQL database. This is done by using phpMyAdmin. The detailed explanation of what is phpMyAdmin and how to use it to create MySQL database with XAMPP will be discussed in this article.

phpMyAdmin

Xampp

phpMyAdmin is a costless and open source software that provides the functionality of operating and managing MySQL over the internet. It provides an ease to the user to control and supervise the database with the help of a graphic user interface known as phpMyAdmin.This GUI is written in PHP programming language. Over time it has gained a lot of trust and demand for the purpose of finding a web-based MySQL administration solution. The user can operate upon MySQL via phpMyAdmin user interface while still directly executing SQL queries. The GUI allows the host to carry a number of manipulation operations on the database, such as editing, creating, dropping, amending, alteration of fields, tables, indexes, etc. It can also be used to manage access control over the data by giving privileges and permissions. phpMyAdmin has thus a vital role to play in handling and creating a database.

Steps To Create MySQL Database Using XAMPP

STEP 1- Navigate to XAMPP in your system or simply launch it by clicking the XAMPP Icon. The Control Panel is now visible and can be used to initiate or halt the working of any module.

STEP 2- Click on the 'Start' button corresponding to Apache and MySQL modules. Once it starts working, the user can see the following screen:

STEP 3- Now click on the 'Admin' button corresponding to the MySQL module. This automatically redirects the user to a web browser to the following address-

http://localhost/phpmyadmin

STEP 4- One can see a number of tabs such as Database, SQL, User Accounts, Export, Import, Settings, etc. Click on the 'Database' tab. Here you can see the Create option. Choose an appropriate name for the input field titled Database name. Things to keep in mind while selecting the name for the database are-

  • The number of characters used should be equal to or less than 64.
  • The name should comprise of letters, numbers and underscore.
  • The DB name should not start with a number.
  • It should be relevant to the topic for which it is being created.

Make sure the database is successfully created.

STEP 5- It is very important to create tables in order to store the information in a systematic manner. In this step, we will build tables for the created database. In the created Database (Login page in this case), click on the 'Structure' tab. Towards the end of the tables list, the user will see a 'Create Table' option. Fill the input fields titled 'Name' and 'Number of Columns' and hit the 'Go' button.

STEP 6- Now, we have to initialize our columns based on their type. Enter the names for each of your columns, select the type, and the maximum length allowed for the input field. Click on 'Save' in the bottom right corner. The table with the initialized columns has been created. You can create any number of tables for your database.

Mysql Cmd Xampp Software

Controlling Access

Mysql Cmd Xampp Command

In order to limit the audience in terms of users allowed to modify and read the data, you can set a password to the created database. In terms of default settings, the host's username is 'root' and there no password is provided. Follow the given steps to increase the privacy of your database:

STEP 1- Click on the 'User Accounts' tab at the top of the page.

STEP 2- Press 'Edit Privileges' under 'Actions' option corresponding the Username= 'root' and Hostname = 'localhost'

STEP 3- Click on the tab 'Change password' and type your password in the provided field. Retype the password to confirm it and then finally click on the 'Go.' Now the password has been set.

Next TopicUninstalling Xampp