Manjaro中MySQL 8 的安裝 -- Gnome桌面


MySQL的安裝過程

本人的系統是Manjaro,查詢了一下Archwiki發現,很多linux默認的SQL數據庫是MariaDB了。同時說,MySQL已經被移到了AUR庫里面。

按照Oracle的德行,MySQL的創始人創建了了一個MySQL的分支,MariaDB,如果MySQL閉源,MariaDB可以立刻代替MySQL使用。因此,不難知道MariaDB是完全兼容MySQL的。

不過的話,MySQL很多項目都使用這個,最后決定安裝MySQL。

安裝MySQL

安裝MySQL

sudo pacman -S mysql

安裝后的一系列配置

查看安裝日志

[2020-04-01T13:29:05+0800] [ALPM-SCRIPTLET] :: You need to initialize the MySQL data directory prior to starting
[2020-04-01T13:29:05+0800] [ALPM-SCRIPTLET]    the service. This can be done with mysqld --initialize command, e.g.:
[2020-04-01T13:29:05+0800] [ALPM-SCRIPTLET]    mysqld --initialize --user=mysql --basedir=/usr --datadir=/var/lib/mysql
[2020-04-01T13:29:05+0800] [ALPM-SCRIPTLET] :: Additionally you should secure your MySQL installation using
[2020-04-01T13:29:05+0800] [ALPM-SCRIPTLET]    mysql_secure_installation command after starting the mysqld service

看到需要初始化 MySQL

執行命令:

mysqld --initialize --user=mysql --basedir=/usr --datadir=/var/lib/mysql

初始化MySQL

mysqld --initialize --user=mysql --basedir=/usr --datadir=/var/lib/mysql

執行以后馬上就報錯了。(煩人)

2020-04-01T05:45:51.941236Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2020-04-01T05:45:51.941340Z 0 [System] [MY-013169] [Server] /usr/bin/mysqld (mysqld 8.0.19) initializing of server in progress as process 75054
2020-04-01T05:45:51.943568Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2020-04-01T05:45:51.943574Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
2020-04-01T05:45:51.943645Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-04-01T05:45:51.943786Z 0 [System] [MY-010910] [Server] /usr/bin/mysqld: Shutdown complete (mysqld 8.0.19)  Source distribution.

查看 [ERROR] 信息以后發現

The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.

好吧,那也只好這樣了。sudo su 切換到root賬戶下面。rm -rf /var/lib/mysql/* 刪除里面的文件。打開文件夾cd /后面這樣安全寫var/lib ,然后刪除mysql里面的文件rm -rf mysql/*。后面這樣做就算出錯,也不至於把系統刪了。

再次初始化

mysqld --initialize --user=mysql --basedir=/usr --datadir=/var/lib/mysql

出現日志

2020-04-01T05:52:22.017420Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2020-04-01T05:52:22.017498Z 0 [System] [MY-013169] [Server] /usr/bin/mysqld (mysqld 8.0.19) initializing of server in progress as process 75837
2020-04-01T05:52:39.779289Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: s?2P***skGeq(這是臨時密碼)

發現,沒有[ERROR]開心的很。

啟動服務

systemctl start mysqld

沒有報錯以后就是安裝成功了。

初次登錄MySQL

重置root密碼

  1. 登錄

    mysql -u root -p
    

    Enter password:

    密碼就是上面記錄的臨時密碼:s?2P***skGeq

  2. 修改密碼

    進入MySQL的shell里面以后,執行命令

    ALTER USER 'root'@'localhost' IDENTIFIED BY 'root-password';
    

安裝mysql可視化界面

mysql有一個叫做workbench的可視化界面,感覺還不錯。

sudo pacman -S mysql-workbench

參考源:

https://dev.mysql.com/doc/refman/8.0/en/installing.html


免責聲明!

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



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