sudo apt-get update安裝 MySQL 8.0
sudo apt-get install mysql-server這邊使用 netstat 指令來查看, netstat 的功用是顯示通訊協定統計資料以及目前的TCP/IP 網路連線,所以要使用它來查看已安裝好的 MySQL 是否有連線監聽。此指令要另外安裝,安裝指令如下:
sudo apt-get install net-tools安裝完成後就能透過 netstat 指令來查看 MySQL 是否安裝成功:
sudo netstat -tap | grep mysql設置 MySQL 允許遠端訪問
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
# If MySQL is running as a replication slave, this should be # changed. Ref https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_tmpdir # tmpdir = /tmp # # Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. #bind-address = 127.0.0.1 <== 註解起來 # # * Fine Tuning # key_buffer_size = 16M # max_allowed_packet = 64M # thread_stack = 256K進入 MySQL 服務,一開始密碼為空值
mysql -u root -p
CREATE USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '12345678'; GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'; CREATE USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '12345678'; ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '12345678'; GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'; FLUSH PRIVILEGES;其他相關
ubuntu mysql 8 的資料庫預設路徑為 /var/lib/mysql
若變更或掛載了新路徑, 記得要改權限
chmod -R 700 /var/lib/mysql chown -R mysql:mysql /var/lib/mysql查詢mysql資料庫檔案的存放位置
在mysql資料庫中,有時候並不是很容易找出mysql資料庫檔案data的存放位置,這時就可以使用mysql的命令列工具進行查詢.
show variables like '%datadir%';
沒有留言:
張貼留言