1. 準備好配置檔案 my.cnf
2.建立my.cnf中用到的必要的目錄
3.在mysql目錄下有個scripts/mysql_install_db, 執行:
scripts/mysql_install_db --defaults-file=/opt/etc/my.cnf --user=mysql
4.啟動服務
/opt/mysql/bin/mysqld_safe --defaults-file=/opt/mysql/etc/my.cnf &
5. 修改密碼
/opt/mysql/bin/mysqladmin -u root password '123456' --socket=/opt/data/mysqld.sock
/opt/mysql/bin/mysqladmin -u root -h your_host_name password '123456' --socket=/opt/data/mysqld.sock
6.登陸驗證
bin/mysql -uroot --socket=/opt/data/mysqld.sock