安裝
cd /usr/ports/databases/mysql57-server/
make install

初始化資料庫
以前會習慣下mysql_install_db,但是不是用mysql server 5.7
[root@example] /usr/local# mysql_install_db
2017-04-13 17:35:05 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2017-04-13 17:35:05 [ERROR]   The data directory needs to be specified.

請改用以下指令,最後他會給你一組臨時密碼,請再自行修改密碼
[root@example] /usr/local# ./libexec/mysqld --initialize
 100
 100 200
 100 200
2017-04-13T09:36:14.023452Z 0 [Warning] InnoDB: New log files created, LSN=45790
 100
2017-04-13T09:36:14.264529Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
mysqld: Error on delete of './auto.cnf' (Errcode: 2 - No such file or directory)
2017-04-13T09:36:14.336677Z 0 [Warning] World-writable config file './auto.cnf' has been removed.

2017-04-13T09:36:14.336909Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: a2ff2237-202c-11e7-8f2a-000c29f3f239.
2017-04-13T09:36:14.338930Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-04-13T09:36:15.160029Z 0 [Warning] CA certificate ca.pem is self signed.
2017-04-13T09:36:15.342263Z 1 [Note] A temporary password is generated for root@localhost: f-gsjI#kHHKd
 

啟動
/usr/local/etc/rc.d/mysql-server onerestart


未修改預設密碼前,如果要操作資料庫可能會出現以下訊息
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

修改密碼
預設密碼會存在 /root/.mysql_secret
可以透過mysqladmin 或是 mysql_secure_installation 來修改密碼

如果出現以下錯誤訊息
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
mysqladmin: connect to server at 'localhost' failed
error: 'Your password has expired. To log in you must change it using a client that supports expired passwords.'

可以試試以下操作
root@localhost [(none)]> alter user 'root'@'localhost' identified by 'NEW_PASSWORD', 'root'@'localhost' password expire never;


設定開機後自動啟用
vi /etc/rc.conf
mysql_enable="YES"

undefined
圖解資料庫系統理論:使用MySQL實作

arrow
arrow
    文章標籤
    freebsd mysql
    全站熱搜

    helloworld 發表在 痞客邦 留言(0) 人氣()