mysql數據庫,如何進行數據目錄的初始化操作


需求描述:

  當將mysql的二進制包解壓之后,只有通過初始化數據庫的數據目錄,創建系統表之后才能使用mysql Server

  數據庫版本:5.5.57-log

操作過程:

1.通過解壓之后的mysql包中scripts目錄下的mysql_install_db腳本對DB進行初始化

[mysql@redhat6 mysql]$ scripts/mysql_install_db --user=mysql   #通過--user=mysql來確定是使用哪個用戶來初始化數據庫,即通過哪個用戶來運行數據庫
Installing MySQL system tables...  #安裝Mysql的系統表 180408  9:56:48 [Warning] option 'slow_query_log': boolean value '/mysql/data/log/slow-query.log' wasn't recognized. Set to OFF.
180408  9:56:48 [Warning] options --log-slow-admin-statements, --log-queries-not-using-indexes and --log-slow-slave-statements have no effect if --log_slow_queries is not set
180408  9:56:48 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
180408  9:56:48 [Note] /mysql/mysql/bin/mysqld (mysqld 5.5.57-log) starting as process 2722 ...
180408  9:56:48 [Warning] You need to use --log-bin to make --binlog-format work.
OK
Filling help tables...  #增加help表 180408  9:56:48 [Warning] option 'slow_query_log': boolean value '/mysql/data/log/slow-query.log' wasn't recognized. Set to OFF.
180408  9:56:48 [Warning] options --log-slow-admin-statements, --log-queries-not-using-indexes and --log-slow-slave-statements have no effect if --log_slow_queries is not set
180408  9:56:48 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
180408  9:56:48 [Note] /mysql/mysql/bin/mysqld (mysqld 5.5.57-log) starting as process 2729 ...
180408  9:56:48 [Warning] You need to use --log-bin to make --binlog-format work.
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/mysql/mysql/bin/mysqladmin -u root password 'new-password'  #為root用戶設置密碼
/mysql/mysql/bin/mysqladmin -u root -h redhat6 password 'new-password'

Alternatively you can run:
/mysql/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /mysql/mysql ; /mysql/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /mysql/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

 

備注:在我的這個環境中,已經配置了/etc/my.cnf,里面設置datadir選項指明了將data目錄存放的位置.

 

小結:

  mysql_install_db腳本的作用就是初始化數據庫,創建系統表.

 

文檔創建時間:2018年4月8日21:52:09


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM