Deepin 20 Beta安裝mysql並導入sql文件

  1. 安裝deepin linux 20 beta,建立用戶myuser,密碼
  2. 更新apt
    sudo apt update
    sudo apt list –upgradable
    sudo apt upgrade

     

  3. 去網站下載 mysql-apt-config_0.8.15-1_all.deb放在Downloads下
  4. 進入文件夾
    cd Downloads

     

  5. 安裝repo
    sudo dpkg -i mysql-apt-config_0.8.15-1_all.deb

     

  6. 安裝界面設置選debian buster,然後確認
  7. 安裝界面前兩個選項默認直接選Ok,然後確認
  8. 更新apt
    sudo apt-get update

     

  9. 安裝mysql(聯網)
    sudo apt-get install mysql-server mysql-client

     

  10. 輸入密碼並確認密碼
  11. 安裝界面選擇Use Strong Password Encryption
  12. 登入mysql,登入後進入mysql>模式
    sudo mysql -uroot -p
    輸入密碼

     

  13. 創建用戶
    create user ABBAdmin IDENTIFIED BY '@BcAdmin123';

     

  14. 賦權限並刷新後退出
    grant all privileges on *.* to [email protected]'%';
    flush privileges;
    exit

     

  15. 重新登入
    sudo mysql -rmyuser -p
    輸入密碼 

     

  16. 拷貝my.sql到Douments文件夾,之後在mysql導入sql文件
    source  /home/myuser/Documents/my.sql;

     

 my.sql內容

DROP DATABASE IF EXISTS Curve;
CREATE DATABASE Curve;
USE Curve;
DELIMITER ;;
CREATE PROCEDURE Init(IN x INT,IN y INT,IN z INT)
BEGIN
	DECLARE i INT DEFAULT 0;
	DECLARE j INT DEFAULT 0;
	DECLARE k INT DEFAULT 0;
	WHILE i<x DO
		SET j = 0;
		WHILE j<y DO
			SET @temp_sql = CONCAT('CREATE TABLE Curve_',i,'_',j,' (ID INT,VALUE FLOAT,TIMESTAMP TIMESTAMP(3),IsData INT(1));');
			PREPARE stmt from @temp_sql;
			EXECUTE stmt;
			DEALLOCATE PREPARE stmt;
			SET k = 0;
			WHILE k<z DO			
				SET @temp_sql = CONCAT('INSERT INTO Curve_',i,'_',j,' VALUES (',k,',',0,',current_timestamp(3),0)');
				PREPARE stmt from @temp_sql;
				EXECUTE stmt;
				DEALLOCATE PREPARE stmt;
				SET k = k + 1;
			END WHILE;			
			SET j = j + 1;
		END WHILE;
		SET i = i + 1;
	END WHILE;
END;;
DELIMITER ;
SELECT CONCAT('Start',current_timestamp(3));
CALL Init(4,6,288);
SELECT CONCAT('Finish',current_timestamp(3));

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章