How to Initialize a New MySQL Installation and Create New Da_MySQL
Related MicroZone Resources
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-
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:- MySQL
- Tips and Tricks
- SQL
- Tools & Methods
上一篇: PHP5指针的类别介绍
下一篇: php中全局变量在多个文件中引用有关问题