f MySQL 8 在Ubuntu 上的安裝 ~ 迪貝之家

MySQL 8 在Ubuntu 上的安裝

 

現在我連ubuntu都懶得安裝了
所以在internet上找看看
有沒有現成的vm image
.......................
還真有喔~~
Ubuntu 20.04 Focal Fossa
去看info那個頁簽找帳密
osboxes/osboxes.org
切換root
sudo su -
apt-get install openssh-server
apt-get install libaio1
apt-get install libncurses5
下載MySQL 8 tar ball

為什麼用tar ball?
MySQL 8 cookbook建議使用
我也覺得它最簡便
最適合機房系統使用
因為不允許對internet的連線
root@osboxes:/usr/local# tar xvf mysql-8.0.22-linux-glibc2.12-x86_64.tar.xz
mysql-8.0.22-linux-glibc2.12-x86_64/bin/
mysql-8.0.22-linux-glibc2.12-x86_64/bin/myisam_ftdump
mysql-8.0.22-linux-glibc2.12-x86_64/bin/myisamchk
mysql-8.0.22-linux-glibc2.12-x86_64/bin/myisamlog
mysql-8.0.22-linux-glibc2.12-x86_64/bin/myisampack
.
資料庫初始指令如下:
1.groupadd mysql
2.useradd -r -g mysql -s /bin/false mysql
3.ln -s mysql-8.0.22-linux-glibc2.12-x86_64 mysql
4.cd mysql
5.root@osboxes:/usr/local/mysql# mkdir mysql-files
6.root@osboxes:/usr/local/mysql# chmod 750 mysql-files
7.root@osboxes:/usr/local/mysql# chown -R mysql .
8.root@osboxes:/usr/local/mysql# chgrp -R mysql .
9.root@osboxes:/usr/local/mysql# bin/mysqld --initialize --user=mysql

2020-11-10T07:57:42.769064Z 0 [System] [MY-013169] [Server] /usr/local/mysql-8.0.22-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.22) initializing of server in progress as process 7113
2020-11-10T07:57:42.777843Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-11-10T07:57:43.402843Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-11-10T07:57:44.323808Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: r#S8h&DeiyQf
紅色字眼是初始密碼
得記起來
等一下起了instance
要透過root登入時
它會要求這個密碼
等一下起了instance
要透過root登入時
它會要求這個密碼
10. root@osboxes:/usr/local/mysql# bin/mysql_ssl_rsa_setup
11. root@osboxes:/usr/local/mysql# chown -R root .
12. root@osboxes:/usr/local/mysql# chown -R mysql data mysql-files
13. root@osboxes:/usr/local/mysql# cp support-files/mysql.server /etc/init.d/mysql
14. root@osboxes:/usr/local/mysql# export PATH=$PATH:/usr/local/mysql/bin
15. root@osboxes:/usr/local/mysql# /etc/init.d/mysql start

Starting mysql (via systemctl): mysql.service.

16.root@osboxes:/usr/local/mysql# ps -ef |grep mysql
root 7336 1 0 03:07 ? 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/osboxes.pid
mysql 7427 7336 14 03:07 ? 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=osboxes.err --pid-file=/usr/local/mysql/data/osboxes.pid

17.root@osboxes:/usr/local/mysql# mysql -u root -p
Enter password: 輸入那組亂碼
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.22
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use mysql; 在你還沒變更密碼前,不會讓你進行任何作業
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
18.mysql> alter user 'root'@'localhost' identified by 'xxxx';
Query OK, 0 rows affected (0.02 sec)
19.root@osboxes:/usr/local/mysql# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.22 MySQL Community Server - GPL
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>