On Windows, the data directory and the grant tables do not have to
be created. MySQL Windows distributions include the grant tables
with a set of preinitialized accounts in the
mysql
database under the data directory. It is
unnecessary to run the mysql_install_db script
that is used on Unix. Regarding passwords, if you installed MySQL
using the Windows Installation Wizard, you may have already
assigned passwords to the accounts. (See
Section 2.5.3.1, “Using the MySQL Installation Wizard”.) Otherwise, use the
password-assignment procedure given in
Section 2.13.2, “Securing the Initial MySQL Accounts”.
Before setting up passwords, you might want to try running some client programs to make sure that you can connect to the server and that it is operating properly. Make sure that the server is running (see Section 2.5.5.4, “Starting the Server for the First Time”), and then issue the following commands to verify that you can retrieve information from the server. The output should be similar to what is shown here:
C:\> C:\mysql\bin\mysqlshow
+--------------------+
| Databases |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
The above may not work if the correct user does not exist. If
you installed using the MSI packages and used the MySQL Server
Instance Config Wizard, then the root
will
haqve been created automatically with the password you supplied.
In this case, you should use the -u
and
-p
options where you will be prompted for the
password.
The list of installed databases may vary, but will always
include the minimum of mysql
and
information_schema
. In most cases, the
test
database will also be installed
automatically.
If you specify the name of the database, then a list of the tables within a given database will be displayed:
C:\>C:\mysql\bin\mysqlshow mysql
Database: mysql +---------------------------+ | Tables | +---------------------------+ | columns_priv | | db | | event | | func | | general_log | | help_category | | help_keyword | | help_relation | | help_topic | | host | | 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 | +---------------------------+ C:\>C:\mysql\bin\mysql -e "SELECT Host,Db,User FROM db" mysql
+------+-------+------+ | host | db | user | +------+-------+------+ | % | test% | | +------+-------+------+
You may need to specify a different directory from the one shown;
if you used the Windows Installation Wizard, then the default
directory is C:\Program Files\MySQL\MySQL Server
5.1
, and the mysql and
mysqlshow client programs are in
C:\Program Files\MySQL\MySQL Server
5.1\bin
. See
Section 2.5.3.1, “Using the MySQL Installation Wizard”, for more information.
If you have already secured the initial MySQL accounts, you may
need to use the -u
and -p
options to supply a user name and password to the
mysqlshow and mysql client
programs; otherwise the programs may fail with an error, or you
may not be able to view all databases. For example, if you have
assigned the password “secretpass” to the MySQL
root
account, then you can invoke
mysqlshow and mysql as shown
here:
C:\>C:\mysql\bin\mysqlshow -uroot -psecretpass
+--------------------+ | Databases | +--------------------+ | information_schema | | mysql | | test | +--------------------+ C:\>C:\mysql\bin\mysqlshow -uroot -psecretpass mysql
Database: mysql +---------------------------+ | Tables | +---------------------------+ | columns_priv | | db | | event | | func | | general_log | | help_category | | help_keyword | | help_relation | | help_topic | | host | | 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 | +---------------------------+ C:\>C:\mysql\bin\mysql -uroot -psecretpass -e "SELECT Host,Db,User FROM db" mysql
+------+-------+------+ | host | db | user | +------+-------+------+ | % | test% | | +------+-------+------+
For more information about these programs, see Section 4.5.6, “mysqlshow — Display Database, Table, and Column Information”, and Section 4.5.1, “mysql — The MySQL Command-Line Tool”.
If you are running a version of Windows that supports services and you want the MySQL server to run automatically when Windows starts, see Section 2.5.5.6, “Starting MySQL as a Windows Service”.
User Comments
On Windows, if you get a message while using mysqlshow:
mysqlshow: Access denied for user 'ODBC'@'localhost' (using password: NO)
this means you have no user "ODBC". Instead try:
>mysqlshow -u root
which forces to log in as "root".
If then you would get:
mysqlshow: Access denied for user 'root'@'localhost' (using password: NO)
this means you should force mysql to use a password:
>mysqlshow -u root -p
Then type your root password (that you defined during installation).
I spent a lot of time for this simple problem.
Add your own comment.