Initialize MySQL

This article is for initializing non-installation MySQL database, and create a database schema.

Initialize the database

  1. unzip the MySQL non-installation package
  2. use cmd to go to bin directory
  3. execute mysqld --initialize-insecure --username=root --console

If you want to put the database file to a directory other than %mysql%/data (the default one), you need to edit the file %mysql%/my-default.ini. There are comments within the file which is very clear.
P.S. I noticed mysqld --initialize-insecure --username=root --console may not work. Try mysqld --initialize-insecure --console instead. Delete ${MYSQL_HOME}/data folder if execution was previously failed.

Create database schema

  1. start up mysql by execute mysqld --console
  2. leave the window open and open another cmd window
  3. go to bin folder and execute mysql -u root -p with leaving empty when it asks the password
  4. create a database by execute create database dbname; and use dbname (use is optional)
  5. Optionally, you can change the Password by executing: ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';

Then it’s good for eclipse or other IDE to connect. In Eclipse, go to window -> preferences -> data management -> connectivity -> driver definitions to setup the connection. The connector jar file can be downloaded at MySQL’s official website.

In my experience, the only problem I encountered was WAMP server being installed which caused me a lots hack. The solution is to change the port in %mysql%/my-default.ini file.

Notice that you may still find some deprecated MySQL official documents which is not marked as deprecated. If you want to do some research on it, start from looking into parameters of mysqld to find more.

Advertisements

One thought on “Initialize MySQL

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s