How to Initialize a New MySQL Installation and Create New Database
Join the DZone community and get the full member experience.Join For Free
For a freshly installed MySQL server, you would need to initialize the system tables and data directory like this:
scripts/mysql_install_db --basedir=. --datadir=data bin/mysqld_safe --defaults-file=my.cnf &
CREATE DATABASE mydb; GRANT ALL PRIVILEGES ON mydb.* TO 'myuser'@'%' IDENTIFIED BY 'secret'; GRANT ALL PRIVILEGES ON mydb.* TO 'myuser'@'localhost' IDENTIFIED BY 'secret';
Published at DZone with permission of Zemian Deng, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.