Skip to content

Instantly share code, notes, and snippets.

@allanjos
Last active November 5, 2018 17:38
Show Gist options
  • Save allanjos/f9750e9fc95104813bcf8aba1e14cc1c to your computer and use it in GitHub Desktop.
Save allanjos/f9750e9fc95104813bcf8aba1e14cc1c to your computer and use it in GitHub Desktop.
MySQL setup - Windows

Initialize database

<MYSQLDIR>\bin\mysqld --initialize

Change root password

Create file mypassword.ini with the following content (change the passord):

ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';

<MYSQLDIR>\bin\mysqld --init-file=<PATH>\mypassword.ini

Now the password was changed, start database normally:

<MYSQLDIR>\bin\mysqld

ACCESS database shell

<MYSQLDIR>\bin\mysql -u root -p

You can create a configuration file my.ini and use to set configuration parameters to database:

my.ini file content:

[mysqld]
# set basedir to your installation path
basedir=<MYSQLDIR>
# set datadir to the location of your data directory
datadir=<MYSQLDIR>\data

Initialize database with settings from my.ini:

<MYSQLDIR>\bin\mysqld --init-file=<MYSQLDIR>\my.ini
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment