How to Initialize a New MySQL Installation and Create New Da_MySQL

WBOY
發布: 2016-06-01 13:07:12
原創
1057 人瀏覽過

06.26.2014|5 views|

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-<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:
  • MySQL
  • Tips and Tricks
  • SQL
  • Tools & Methods
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!