Home >Database >Mysql Tutorial >How to Initialize a New MySQL Installation and Create New Da_MySQL
06.26.2014|5 views|
INFOGRAPHIC: The Future of the Database
Proven in Production: Clustrix Case Studies
Clustrix Whitepapers
What We Offer: Clustrix Features
Like this piece? Share it with your friends:
|More
For a freshly installed MySQL server, you would need to initialize the system tables and data directory like this:
cd mysql-<version></version>
scripts/mysql_install_db --basedir=. --datadir=databin/mysqld_safe --defaults-file=my.cnf &
Before MySQL 5.6, this will setup a "root" with empty password that you can immediately login. For MySQL 5.7 however, it creates a random password for "root" user now. The password is generated under $HOME/.mysql_secret. You need to login and run "SET PASSWORD = PASSWORD('secret')" to change it. After above, you my login using "root" and start creating your own database and users. For example:
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 ofZemian Deng, author and DZone MVB. (source)
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)
Tags: