How to get mysql server info using command line? - mysql

Is there a direct command line command that provides all mysql server information like below...This is provided using Mysql GUI administrator. Do we have some direct command to get this info ussing command line ?
Username:
Hostname:
Port:
Server Information
MySQL Version:
Network Name:
IP:
Client Information
Version:
Network name:
IP:
Operating System:
Hardware:

Look at following MySQL documentation:
SHOW VARIABLES
Following command will show you most of your desired information:
SHOW VARIABLES;
Only version:
select version();
EDIT:
What is the difference between show variables and show status?
SHOW STATUS provides server status information like Connections, Opened_tables, Bytes_received, Bytes_sent, etc.
More Info
SHOW VARIABLES shows the values of MySQL system variables like time_zone, version, max_connections, etc.
More Info

Try just status:
mysql> status
--------------
mysql Ver 14.14 Distrib 5.5.33, for osx10.7 (i386) using readline 5.1
Connection id: 3
Current database: somedb
Current user: someuser#localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.5.33 Source distribution
Protocol version: 10
Connection: 127.0.0.1 via TCP/IP
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
TCP port: 3306
Uptime: 38 min 53 sec
Threads: 2 Questions: 196 Slow queries: 0 Opens: 87 Flush tables: 1 Open tables: 80 Queries per second avg: 0.084
--------------

Related

I need to know if they have an ENTERPRISE or COMMUNITY MYSQL edition

I'm doing some MYSQL work for a company, and I need to know if they have an ENTERPRISE or COMMUNITY edition. I researched this, and according to the mysql reference pages, I should be able to use the "status" command. According to that reference, the "Server Version" should say "Community", or "enterprise". Ours says neither (figures, right?), just "5.0.77 Source Distribution". Is there another way to tell?
tl;dr
Try this:
mysql> SHOW VARIABLES LIKE "%version%";
Normal answer
Using a command client (mysql), the server version of the MySQL server to which you are connected is shown once you are connected. The server version information includes community or enterprise accordingly.
For example, here is the output from a MySQL Community Server edition installed on Linux:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.0.27-standard MySQL Community Edition - Standard (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
This is an example of the output from MySQL Enterprise Server on Windows:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.28-enterprise-gpl-nt MySQL Enterprise Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
You may also determine the version information using the version variables. Both the version and version_comment variables contain version information for the server to which you are connected. Use the SHOW VARIABLES statement to obtain the information you want, as shown in this example:
mysql> SHOW VARIABLES LIKE "%version%";
+-------------------------+------------------------------------------+
| Variable_name | Value |
+-------------------------+------------------------------------------+
| protocol_version | 10 |
| version | 5.0.27-standard |
| version_comment | MySQL Community Edition - Standard (GPL) |
| version_compile_machine | i686 |
| version_compile_os | pc-linux-gnu |
+-------------------------+------------------------------------------+
5 rows in set (0.04 sec)
Straight from the documentation.
But, of course, so is STATUS;
The STATUS command displays the version as well as version comment information. For example:
mysql> STATUS;
--------------
./client/mysql Ver 14.12 Distrib 5.0.29, for pc-linux-gnu (i686) using readline 5.0
Connection id: 8
Current database:
Current user: mc#localhost
SSL: Not in use
Current pager: /usr/bin/less
Using outfile: ''
Using delimiter: ;
Server version: 5.0.27-standard MySQL Community Edition - Standard (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: latin1
Conn. characterset: latin1
UNIX socket: /tmp/mysql.sock
Uptime: 1 day 3 hours 58 min 43 sec
Threads: 2 Questions: 17 Slow queries: 0 Opens: 11 Flush tables: 1 Open tables: 6 Queries per second avg: 0.000
--------------
So I wonder whether you're actually just looking at the first line provided or whether you're checking below for the "Server version" line.
If nothing works for you then feel free to edit your question with a complete dump of what you get.
Edit
As you found out it appears that they do not disquisition between the releases since it's a specific edition release, in this case a Community Edition. Thus the answer generally only works if you can't be certain by looking up the version.

MySQL Run SQL Script in Command Prompt to create table and master data - Error

I have created a table in MySQL and have the SQL script handy to create all the tables ans master data. However, i tried all possible way but it is not letting me to do so.
From the command prompt, i connected to mysql by passing this
>mysql -localhost -root -p;
mysql> Use MYDB
mysql> source d:\script\test.sql
it is giving me a message which i don't understand, please help.
mysql Ver 14.14 Distrib 5.6.20, for Win64 (x86_64)
Connection id: 22
Current database: oyeohdb
Current user: dms#localhost
SSL: Not in use
Using delimiter: ;
Server version: 5.6.20 MySQL Community Server (GPL)
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: latin1
Db characterset: latin1
Client characterset: cp850
Conn. characterset: cp850
TCP port: 3306
Uptime: 1 hour 13 min 34 sec
Threads: 1 Questions: 99 Slow queries: 0 Opens: 68 Flush tables: 1 Open tab
les: 61 Queries per second avg: 0.022
--------------
Outfile disabled.
ERROR:
Failed to open file 'D:criptest.sql', error: 2
mysql> SOURCE D:/script/test.sql;
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 'TYPE=
MyISAM' at line 10
mysql>
Backslash is MySQL's escape character in strings. You should either double it or use forward slash:
mysql> source d:\\script\\test.sql
mysql> d:/script/test.sql
I have had a similar issue and it was solved by running
mysql_upgrade.exe
Located at:
...bin\mysql\mysql5.6.17\bin
I hope that this issue works out for you. Cheers!

Attempting to execute SQL statements using text file in command line

I am very new to SQL and in fact just started yesterday. The book I am following is asking me to run sql statements from a text file they provided. However, I am getting an error message and I dont understand why. Here is the commands I entered along with the error message:
mysql> use bank;
Database changed
mysql> source c:\sql\LearningSQLExample.sql;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 9
Current database: bank
--------------
mysql Ver 14.14 Distrib 5.6.12, for Win64 (x86_64)
Connection id: 9
Current database: bank
Current user: lrngsql#localhost
SSL: Not in use
Using delimiter: ;
Server version: 5.6.12 MySQL Community Server (GPL)
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: utf8
Db characterset: utf8
Client characterset: cp850
Conn. characterset: cp850
TCP port: 3306
Uptime: 1 day 4 hours 9 min 17 sec
Threads: 1 Questions: 6474 Slow queries: 1 Opens: 111 F
tables: 79 Queries per second avg: 0.063
--------------
ERROR:
Unknown command '\L'.
ERROR:
Failed to open file 'c:ql\LearningSQLExample.sql', error: 2
Thanks for your help.
You need to escape the backslash. Type source c:\\sql\\LearningSQLExample.sql;
Just an additional solution when for newer version of mySQL command line
Rename the LearningSQLExample.sql file to something that have underscore in it.
Something like s_s.sql then at the command line try
source c:/temp/s_s.sql;

Login to MySql using Linux terminal not responding

Im trying to login to MySQL in localhost using the root username (default) with no password entering the following command:
mysql -u root -h localhost
I dont get the 'mysql>' and it does not fail so im left with the terminal letting me type but it does not execute any commands (inside or outside of mysql). I also tried using -p and leaving the password blank and I get the same result
Check the following (taken from http://dev.mysql.com/doc/mysql-linuxunix-excerpt/5.5/en/unix-postinstallation.html )
Use mysqladmin to verify that the server is running. The following commands provide simple tests to check whether the server is up and responding to connections:
shell> bin/mysqladmin version
shell> bin/mysqladmin variables
The output from mysqladmin version varies slightly depending on your platform and version of MySQL, but should be similar to that shown here:
shell> bin/mysqladmin version
mysqladmin Ver 14.12 Distrib 5.5.29, for pc-linux-gnu on i686
...
Server version 5.5.29
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/lib/mysql/mysql.sock
Uptime: 14 days 5 hours 5 min 21 sec
Threads: 1 Questions: 366 Slow queries: 0
Opens: 0 Flush tables: 1 Open tables: 19
Queries per second avg: 0.000
If you are unable to run that command then your installation is either not complete (follow the instructions starting at the top of the page ) or you do not have permission as the user to execute the mysql program.

UTF8 characters not showing correctly in Wordpress

I am running out of ideas - Wordpress is refusing to save UTF-8 encoded characters correctly:
http://www.letosanezkou.com/
you can see that when I edit the post content directly in the MySQl DB it works correctly. I have verified the mysql db:
mysql Ver 14.14 Distrib 5.5.24, for Linux (i686) using readline 5.1
Connection id: 2120
Current database: leto_wp1
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.5.24-cll MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
and my wp-config has the default UTF-8 lines:
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
When I try to update the post, that was edited in phpmyadmin it will save the post incorrectly.
Any ideas on how to fix this please?