mysql在ubuntu上的安裝過程

2021-09-02 12:25:27 字數 3412 閱讀 6065

1、安裝mysql-server:

hadoop@stcn501a0166:~$ mysql

程式 'mysql' 已包含在下列軟體包中:

* mysql-client-core-5.5

* mariadb-client-core-5.5

* mysql-client-core-5.6

* percona-xtradb-cluster-client-5.5

請嘗試:sudo apt-get install 《選定的軟體包》

hadoop@stcn501a0166:~$ sudo apt-get install mysql-server

[sudo] password for hadoop:

正在讀取軟體包列表... 完成

正在分析軟體包的依賴關係樹

正在讀取狀態資訊... 完成

說明:遇到輸入的地方輸入y,過程中需要設定root使用者的密碼,設定時記住密碼

2、root使用者登入:

hadoop@stcn501a0166:~$ mysql -u root -p

enter password:

welcome to the mysql monitor. commands end with ; or \g.

your mysql connection id is 48

server version: 5.5.44-0ubuntu0.14.04.1 (ubuntu)

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>

3、檢視系統中的資料庫:

mysql> show databases;

+--------------------+

| database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

+--------------------+

3 rows in set (0.00 sec)

mysql>

4、新建測試用資料庫:

mysql> create database example;

query ok, 1 row affected (0.00 sec)

mysql> show databases;

+--------------------+

| database |

+--------------------+

| information_schema |

| example |

| mysql |

| performance_schema |

+--------------------+

4 rows in set (0.00 sec)

mysql>

5、建立新的使用者帳號:

mysql> create user 'mzuser'@'localhost' identified by '123456';

query ok, 0 rows affected (0.00 sec)

mysql> grant all on example.* to 'mzuser'@'localhost';

query ok, 0 rows affected (0.00 sec)

說明:給使用者賦予在example資料庫上的許可權

6、使用新使用者登入

hadoop@stcn501a0166:~$ mysql -u mzuser -p

enter password:

welcome to the mysql monitor. commands end with ; or \g.

your mysql connection id is 49

server version: 5.5.44-0ubuntu0.14.04.1 (ubuntu)

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> show databases;

+--------------------+

| database |

+--------------------+

| information_schema |

| example |

+--------------------+

2 rows in set (0.00 sec)

mysql>

7、修改使用者訪問的資料庫並檢視庫中表

mysql> use example

database changed

mysql> show tables;

empty set (0.00 sec)

mysql> exit

由於新建立的庫中沒有任何表,所以顯示為empty

8、退出登入並關閉資料庫服務:

sql>exit

~$sudo /etc/init.d/mysql stop

9、測試建立表(使用新建使用者登入,use example資料庫)

mysql> create table cmsuser(

> userid int(8) not null auto_increment primary key,

>username varchar(20) not null,

> password varchar(20),

> area varchar(10),

>deptrole varchar(10));

query ok, 0 rows affected (0.06 sec)

mysql> show tables;

+-------------------+

| tables_in_example |

+-------------------+

| cmsuser |

+-------------------+

1 row in set (0.00 sec)

MySQL在Ubuntu18 04上編譯安裝的指令碼

netstat anpt grep 3306解除安裝 檢視安裝了mysql的相關軟體包 dpkg get selections grep mysql 解除安裝mysql apt get remove purge mysql 清除本地殘留檔案 apt autoclean 清除無用依賴包 可選 apt ...

Jerasure2 0 在Ubuntu上的安裝

目錄 jerasure2.0 在ubuntu上的安裝 準備 配置 錯誤解決方法 參考資料 2.安裝autoconf automake sudo apt get install automake autoconf 2.安裝libtool sudo apt get install libtool 1.在...

valgrind簡介及在ubuntu上安裝

最近專案中要用到valgrind,所以稍微了解了一下。安裝很簡單,我的環境是ubuntu,只要在終端輸入 sudo apt get install valgrind 其中sudo可選,當你是root許可權下是不需要的。valgrind fatal error at startup a functio...