1. 程式人生 > >阿里雲Ubuntu 16.04 部署Mysql資料庫-極簡

阿里雲Ubuntu 16.04 部署Mysql資料庫-極簡

買了一臺阿里雲的伺服器,想搞搞事情。於是乎,準備搭建了Mysql資料庫,下面是具體的操作流程

1.安裝mysql服務端 sudo apt-get install mysql-server

[email protected]*************:~# sudo apt-get install mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
...(過多省略)
After this operation, 162 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

2.安裝mysql客戶端 sudo apt-get install mysql-client

[email protected]*************:~# sudo apt-get install mysql-client
Reading package lists... Done
Building dependency tree       
Reading state information... Done
...(過多省略)
Unpacking mysql-client (5.7.24-0ubuntu0.16.04
.1) ... Setting up mysql-client (5.7.24-0ubuntu0.16.04.1) ...

3.執行 sudo apt install libmysqlclient-dev

[email protected]*************:~# sudo apt install libmysqlclient-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
...(過多省略)
After this operation,
11.4 MB of additional disk space will be used. Do you want to continue? [Y/n] y Abort.

執行上面步驟只能使用root許可權執行,中途需要設定MySQL密碼

4.驗證Mysql安裝成功 sudo netstat -tap | grep mysql

出現下圖表示安裝成功
[email protected]*************:~# sudo netstat -tap | grep mysql
tcp        0      0 localhost:mysql         *:*                     LISTEN      1745/mysqld     
Abort.

5.【登入Mysql資料庫】

mysql -uroot -p1234
-u後面的root表示登入名,-p後面的1234表示登入密碼,在前面的步驟中設定。執行命令如果出現下圖,表示資料庫建立成功
[email protected]*************:~# mysql -uroot -p1234
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.24-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2018, 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>