Add MySQL directory to PATH
if needed.
which mysqladmin; if [ $? == 1 ]; then export PATH=$PATH:/usr/local/mysql/bin/;fi
sudo mysqladmin -h localhost ping
(as root no mysql password is needed)Password:
root password for sudo
mysqladmin -h localhost ping
mysqld is alive
; Good news, now try status
A response of: error: 'Access denied for user 'realg1'@'localhost' (using password: NO)'
most likely means that the mysql deamon is alive but requires a password.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
The device is not ready.
:error: 'Unknown MySQL server host 'localhost' (11001)†'
confirm the spelling then
ping host
and
traceroute host
on MS windows its tracert
mysqladmin: connect to server at 'Real-World-Systems.com' failed
error: 'Unknown MySQL Server Host 'Real-World-Systems.com' (1)'
Check that mysqld is running
ps -ea |grep -i sql |grep -v grep
4653 6964 /bin/sh ./bin/mysqld_safe
Check out err log:
/usr/local/mysql/data > sudo tail `ls -tr1 /usr/local/mysql/data|tail -n1` 130430 18:16:20 InnoDB: Completed initialization of buffer pool 130430 18:16:20 InnoDB: highest supported file format is Barracuda. 130430 18:16:20 InnoDB: Waiting for the background threads to start 130430 18:16:21 InnoDB: 1.1.8 started; log sequence number 1595675 130430 18:16:21 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306 130430 18:16:21 [Note] - '0.0.0.0' resolves to '0.0.0.0'; 130430 18:16:21 [Note] Server socket created on IP: '0.0.0.0'. 130430 18:16:21 [Note] Event Scheduler: Loaded 0 events 130430 18:16:21 [Note] /usr/local/mysql/bin/mysqld: ready for connections. Version: '5.5.28' socket: '/tmp/mysql.sock' port: 3306 MySQL Community Server (GPL)
If the server isn't running, start it using:
cd /usr/local/mysql/bin
# Run MYSQL in background so I can keep going
/usr/local/mysql/bin > sudo ./mysqld_safe &
Password:
Starting mysqld daemon with databases from /usr/local/mysql/data
cd /usr/local/mysql/bin
sudo ./mysqld_safe &
/usr/local/bin/mysqladmin -h localhost -u plainuser ping -p
Enter password:
( password request from mySQL for plainuser)
/usr/local/mysql/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'plainuser'@'localhost' (using password: YES)'
( Use sudo to alter user plainuser identified by 'newpass'
)
sudo /usr/local/mysql/bin/mysql -u mysql --database=mysql
Password: select host , User , Password from user;
and that the port is 3306.
You can check this by doingtelnet Real-World-Systems.com 3306
telnet localhost 3306
results will include version number ex:
5.1.6
(and some misc characters).
00 de d1 02 00 62 30 68 3c 32 24 5e 30 00 08 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 6f 61 78 57 2c 74 26 5b 79 71 4d 68 00 1b 00 00 01 04After a few seconds
Connection to host lost.
orConnection closed by foreign host.
If no connection :
- a Firewall is blocking packets
sudo /usr/local/mysql/bin/mysqladmin -h localhost status -p
Uptime: 14568 Threads: 1 Questions: 10 Slow queries: 0 Opens: 0
Flush tables: 1 Queries per second avg: 0.000
sudo mysqladmin -h localhost version -p
mysqladmin Ver 8.41 Distrib 4.1.11, for Win32 on ia32 Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL license Server version 5.0.3-beta-nt Protocol version 10 Connection localhost via TCP/IP TCP port 3306 Uptime: 4 hours 2 min 56 sec Threads: 1 Questions: 11 Slow queries: 0 Opens: 0 Flush tables: 0 Open tries per second avg: 0.000
Using MySQLAdmin
Not interactive, commands must be provided on command line.mysqladmin -h localhost -p mysqladmin Ver 8.41 Distrib 4.1.11, for Win32 on ia32 Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB Usage: mysqladmin [OPTIONS] command command.... -h, --host=name -u, --user=name if not current user. -p, --password[=name] If password not given it will be requested -O, --set-variable=name Change the value of a variable. deprecated; use --variable-name=value. -v, --verbose -V, --version Output version information and exit. -#, --debug[=name] Output debug log. Often this is 'd:t:o,filename'. -f, --force Don't ask for confirmation on drop database; danger With multiple commands, continue even if an error occurs. -C, --compress Use compression in server/client protocol. --protocol=name tcp,socket,pipe,memory. -W, --pipe -P, --port=# -S, --socket=name Socket file to use for connection. -i, --sleep=# Execute commands again and again with a sleep between. ex: status -c, --count=# Number of iterations to make. with --sleep -r, --relative Show difference between current and previous values used with --sleep -E, --vertical Print output vertically. similar to --relative, -w, --wait[=#] Wait and retry if connection is down. --connect_timeout=# -s, --silent Silently exit if can't connect to server. --shutdown_timeout=# Variables (--variable-name=value) and boolean options {FALSE|TRUE} Value (after reading options) --------------------------------- ----------------------------- count 0 force FALSE compress FALSE character-sets-dir (No default value) default-character-set (No default value) host localhost port 3306 relative FALSE shared-memory-base-name (No default value) socket (No default value) sleep 0 user (No default value) verbose FALSE vertical FALSE connect_timeout 43200 shutdown_timeout 3600 Default options are read from the following files in the given order: C:\WINNT\my.ini C:\WINNT\my.cnf C:\my.ini C:\my.cnf The following groups are read: mysqladmin client The following options may be given as the first argument: --print-defaults Print the program argument list and exit --no-defaults Don't read default options from any options file --defaults-file=# Only read default options from the given file # --defaults-extra-file=# Read this file after the global files are readWhere command is a one or more of: (Commands may be shortened)debug Instruct server to write debug information to log create databasename drop databasename extended-status flush-hosts flush-logs flush-status flush-tables flush-threads flush-privileges Reload grant tables reload kill id,id,... Kill mysql threads password new-password Change old password to new-password, MySQL 4.1 hashin old-password new-password Change old password to new-password in old format ping Check if mysqld is alive processlist Show list of active threads in server refresh Flush all tables and close and open logfiles shutdown status start-slave stop-slave variables version
compare to MySQL status:
mysql -h localhost Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 to server version: 5.0.3-beta-nt Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> \s -------------- mysql Ver 14.7 Distrib 4.1.11, for Win32 (ia32) Connection id: 3 Current database: Current user: ODBC@SLAMMER-6GB SSL: Not in use Using delimiter: ; Server version: 5.0.3-beta-nt Protocol version: 10 Connection: localhost via TCP/IP Server characterset: latin1 Db characterset: latin1 Client characterset: latin1 Conn. characterset: latin1 TCP port: 3306 Uptime: 3 hours 50 min 42 sec Threads: 1 Questions: 8 Slow queries: 0 Opens: 0 Flush tables: 1 Open tables: 1028 Queries per second avg: 34.936 -------------- mysql> quit Bye
mysqladmin -h localhost variablesInteresting ones shown here, see MySQLadminHeavy for complete list
Variable_name Value | auto_increment_increment | 1 | auto_increment_offset | 1 | automatic_sp_privileges | ON | back_log | 50 | basedir | C:\Program Files\MySQL\MySQL Server 5.0\ ... | completion_type | 0 | concurrent_insert | ON | connect_timeout | 5 | datadir | C:\Program Files\MySQL\MySQL Server 5.0\Data | date_format | %Y-%m-%d | datetime_format | %Y-%m-%d %H:%i:%s | default_week_format | 0 ... | ft_boolean_syntax | + -><()~*:""& | ft_max_word_len | 84 | ft_min_word_len | 4 | ft_query_expansion_limit | 20 | ft_stopword_file | (built-in) ... | log_error | .\localhost.err ... | lower_case_file_system | OFF | lower_case_table_names | 1 ... | new | OFF | old_passwords | OFF ... | port | 3306 ... | system_time_zone | Eastern Standard Time ... | time_format | %H:%i:%s | time_zone | SYSTEM ... | tmpdir | updatable_views_with_limit | YES | version | 5.0.3-beta-nt | version_comment | Official MySQL binary | version_compile_machine | ia32 | version_compile_os | Win32 | wait_timeout | 28800E:\programs\MySQL\bin> mysqladmin -h smother -u root -pxxxx -v -i 10 -c 3 -r status Uptime: 59148 Threads: 1 Questions: 27 Slow queries: 0 Opens: 11 Flush tables: 1 Open tables: 0 Queries per second avg: 0.000 Uptime: 59158 Threads: 1 Questions: 27 Slow queries: 0 Opens: 11 Flush tables: 1 Open tables: 0 Queries per second avg: 0.000 Uptime: 59168 Threads: 1 Questions: 27 Slow queries: 0 Opens: 11 Flush tables: 1 Open tables: 0 Queries per second avg: 0.000 E:\programs\MySQL\bin> mysqladmin -h smother -u root -p processlist Enter password: ****** +----+------+------------------+----+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+------------------+----+---------+------+-------+------------------+ | 4 | root | SLAMMER-6GB:2442 | | Query | 0 | | show processlist | +----+------+------------------+----+---------+------+-------+------------------+ mysqladmin -h smother -u root -pxxxx -v -i 10 -c 3 -r extended-status (very large list)
show databases +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | +--------------------+ \u information_schemaSELECT TABLE_TYPE, TABLE_NAME, TABLE_CATALOG, AVG_ROW_LENGTH, CREATE_TIME, UPDATE_TIME, CREATE_OPTI ONS, TABLE_COMMENT, INDEX_LENGTH FROM TABLES +-------------+---------------------------------------+----------------+---------------------+---------------------+----------------+---------------+--------------+ | TABLE_TYPE | TABLE_NAME | AVG_ROW_LENGTH | CREATE_TIME | UPDATE_TIME | CREATE_OPTIONS | TABLE_COMMENT | INDEX_LENGTH | +-------------+---------------------------------------+----------------+---------------------+---------------------+----------------+---------------+--------------+ | SYSTEM VIEW | CHARACTER_SETS | 384 | NULL | NULL | max_rows=43690 | | 0 | | SYSTEM VIEW | COLLATIONS | 231 | NULL | NULL | max_rows=72628 | | 0 | | SYSTEM VIEW | COLLATION_CHARACTER_SET_APPLICABILITY | 195 | NULL | NULL | max_rows=86037 | | 0 | | SYSTEM VIEW | COLUMNS | 0 | 2009-12-15 23:23:24 | 2009-12-15 23:23:24 | max_rows=4560 | | 1024 | | SYSTEM VIEW | COLUMN_PRIVILEGES | 2565 | NULL | NULL | max_rows=6540 | | 0 | | SYSTEM VIEW | ENGINES | 490 | NULL | NULL | max_rows=34239 | | 0 | | SYSTEM VIEW | EVENTS | 0 | 2009-12-15 23:23:24 | 2009-12-15 23:23:24 | max_rows=618 | | 1024 | | SYSTEM VIEW | FILES | 2677 | NULL | NULL | max_rows=6267 | | 0 | | SYSTEM VIEW | GLOBAL_STATUS | 3268 | NULL | NULL | max_rows=5133 | | 0 | | SYSTEM VIEW | GLOBAL_VARIABLES | 3268 | NULL | NULL | max_rows=5133 | | 0 | | SYSTEM VIEW | KEY_COLUMN_USAGE | 4637 | NULL | NULL | max_rows=3618 | | 0 | | SYSTEM VIEW | PARTITIONS | 0 | 2009-12-15 23:23:24 | 2009-12-15 23:23:24 | max_rows=5612 | | 1024 | | SYSTEM VIEW | PLUGINS | 0 | 2009-12-15 23:23:24 | 2009-12-15 23:23:24 | max_rows=13025 | | 1024 | | SYSTEM VIEW | PROCESSLIST | 0 | 2009-12-15 23:23:24 | 2009-12-15 23:23:24 | max_rows=23899 | | 1024 | | SYSTEM VIEW | PROFILING | 308 | NULL | NULL | max_rows=54471 | | 0 | | SYSTEM VIEW | REFERENTIAL_CONSTRAINTS | 4814 | NULL | NULL | max_rows=3485 | | 0 | | SYSTEM VIEW | ROUTINES | 0 | 2009-12-15 23:23:24 | 2009-12-15 23:23:24 | max_rows=588 | | 1024 | | SYSTEM VIEW | SCHEMATA | 3464 | NULL | NULL | max_rows=4843 | | 0 | | SYSTEM VIEW | SCHEMA_PRIVILEGES | 2179 | NULL | NULL | max_rows=7699 | | 0 | | SYSTEM VIEW | SESSION_STATUS | 3268 | NULL | NULL | max_rows=5133 | | 0 | | SYSTEM VIEW | SESSION_VARIABLES | 3268 | NULL | NULL | max_rows=5133 | | 0 | | SYSTEM VIEW | STATISTICS | 2679 | NULL | NULL | max_rows=6262 | | 0 | | SYSTEM VIEW | TABLES | 3545 | NULL | NULL | max_rows=4732 | | 0 | | SYSTEM VIEW | TABLE_CONSTRAINTS | 2504 | NULL | NULL | max_rows=6700 | | 0 | | SYSTEM VIEW | TABLE_PRIVILEGES | 2372 | NULL | NULL | max_rows=7073 | | 0 | | SYSTEM VIEW | TRIGGERS | 0 | 2009-12-15 23:23:24 | 2009-12-15 23:23:24 | max_rows=569 | | 1024 | | SYSTEM VIEW | USER_PRIVILEGES | 1986 | NULL | NULL | max_rows=8447 | | 0 | | SYSTEM VIEW | VIEWS | 0 | 2009-12-15 23:23:24 | 2009-12-15 23:23:24 | max_rows=6932 | | 1024 | +-------------+---------------------------------------+----------------+---------------------+---------------------+----------------+---------------+--------------+ 28 rows in set (0.18 sec) select TABLE_CATALOG , TABLE_SCHEMA , TABLE_NAME , TABLE_ROWS, UPDATE_TIME from tables where table_name ="db" +---------------+--------------+------------+------------+---------------------+ | TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | TABLE_ROWS | UPDATE_TIME | +---------------+--------------+------------+------------+---------------------+ | NULL | mysql | db | 2 | 2010-05-06 20:56:32 | +---------------+--------------+------------+------------+---------------------+ \u mysql select * from db +------+---------+------+-------------+-------------+-------------+-------------+-------------+-----------+------------+-----------------+------------+------------+-----------------------+------------------+------------------+----------------+---------------------+--------------------+--------------+------------+--------------+ | Host | Db | User | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Create_tmp_table_priv | Lock_tables_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Execute_priv | Event_priv | Trigger_priv | +------+---------+------+-------------+-------------+-------------+-------------+-------------+-----------+------------+-----------------+------------+------------+-----------------------+------------------+------------------+----------------+---------------------+--------------------+--------------+------------+--------------+ | % | test | | Y | Y | Y | Y | Y | Y | N | Y | Y | Y | Y | Y | Y | Y | Y | N | N | Y | Y | | % | test\_% | | Y | Y | Y | Y | Y | Y | N | Y | Y | Y | Y | Y | Y | Y | Y | N | N | Y | Y | +------+---------+------+-------------+-------------+-------------+-------------+-------------+-----------+------------+-----------------+------------+------------+-----------------------+------------------+------------------+----------------+---------------------+--------------------+--------------+------------+--------------+select table_name from tables; +---------------------------------------+ | table_name | +---------------------------------------++---------------------------------------+ 51 rows in set (0.00 sec) mysql> \u mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> select * from user; +--------------------+------+----------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+ | Host | User | Password | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Show_db_priv | Super_priv | Create_tmp_table_priv | Lock_tables_priv | Execute_priv | Repl_slave_priv | Repl_client_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Create_user_priv | Event_priv | Trigger_priv | ssl_type | ssl_cipher | x509_issuer | x509_subject | max_questions | max_updates | max_connections | max_user_connections | +--------------------+------+----------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+ | localhost | root | | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | | | | | 0 | 0 | 0 | 0 | | smackerpro.germans | root | | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | | | | | 0 | 0 | 0 | 0 | | 127.0.0.1 | root | | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | | | | | 0 | 0 | 0 | 0 | | localhost | | | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | | | | | 0 | 0 | 0 | 0 | | smackerpro.germans | | | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | | | | | 0 | 0 | 0 | 0 | +--------------------+------+----------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+ 5 rows in set (0.02 sec)
| CHARACTER_SETS | | COLLATIONS | | COLLATION_CHARACTER_SET_APPLICABILITY | | COLUMNS | | COLUMN_PRIVILEGES | | ENGINES | | EVENTS | | FILES | | GLOBAL_STATUS | | GLOBAL_VARIABLES | | KEY_COLUMN_USAGE | | PARTITIONS | | PLUGINS | | PROCESSLIST | | PROFILING | | REFERENTIAL_CONSTRAINTS | | ROUTINES | | SCHEMATA | | SCHEMA_PRIVILEGES | | SESSION_STATUS | | SESSION_VARIABLES | | STATISTICS | | TABLES | | TABLE_CONSTRAINTS | | TABLE_PRIVILEGES | | TRIGGERS | | USER_PRIVILEGES | | VIEWS | tables is mysql----------------------- ed | columns_priv | | db | | event | | func | | general_log | | help_category | | help_keyword | | help_relation | | help_topic | | host | | ndb_binlog_index | | plugin | | proc | | procs_priv | | servers | | slow_log | | tables_priv | | time_zone | | time_zone_leap_second | | time_zone_name | | time_zone_transition | | time_zone_transition_type | | user |sudo /usr/local/mysql/bin/mysqladmin shutdown
additional notes at MySQLadmin Heavy