Hướng dẫn cài đặt sql server trên ubuntu 16.04
MySQL là một hệ quản trị database open-souce, thường được cài đặt như một phần của LAMP (Linux, Apache, MySQL, PHP / Python / Perl) phổ biến. Nó sử dụng database quan hệ và SQL (Ngôn ngữ truy vấn có cấu trúc) để quản lý dữ liệu. Show
Version ngắn gọn cài đặt rất đơn giản: cập nhật index gói của bạn, cài đặt gói undefined 3 và sau đó chạy tập lệnh bảo mật đi kèm. undefined
undefined Hướng dẫn này sẽ giải thích cách cài đặt MySQL version 5.7 trên server Ubuntu 16.04. Tuy nhiên, nếu bạn đang tìm cách cập nhật cài đặt MySQL hiện có lên version 5.7, bạn có thể đọc hướng dẫn cập nhật MySQL 5.7 này để thay thế. Yêu cầuĐể làm theo hướng dẫn này, bạn cần:
Bước 1 - Cài đặt MySQLTrên Ubuntu 16.04, chỉ có version MySQL mới nhất được bao gồm trong repository APT theo mặc định. Tại thời điểm viết bài, đó là MySQL 5.7 Để cài đặt nó, chỉ cần cập nhật index gói trên server và cài đặt gói mặc định với undefined 4 . undefined
undefined Bạn cần tạo password root trong khi cài đặt. Tiếp theo, ta sẽ hoàn thành việc cấu hình MySQL. Bước 2 - Cấu hình MySQLĐối với các bản cài đặt mới, bạn cần chạy tập lệnh bảo mật đi kèm. Điều này thay đổi một số tùy chọn mặc định kém an toàn hơn cho những thứ như đăng nhập root từ xa và user mẫu. Trên các version MySQL cũ hơn, bạn cũng cần phải khởi tạo folder dữ liệu theo cách thủ công, nhưng điều này được thực hiện tự động ngay bây giờ. Chạy tập lệnh bảo mật. undefined
undefined Thao tác này sẽ nhắc bạn nhập password root mà bạn đã tạo ở Bước 1. Bạn có thể nhấn undefined 5 rồi undefined 6 để chấp nhận các giá trị mặc định cho tất cả các câu hỏi tiếp theo, ngoại trừ câu hỏi bạn có muốn thay đổi password root hay không. Bạn chỉ cần đặt nó ở Bước 1, vì vậy bạn không cần phải thay đổi nó. Để có hướng dẫn chi tiết hơn về các tùy chọn này, bạn có thể xem . Để khởi tạo folder dữ liệu MySQL, bạn sẽ sử dụng undefined 7 cho các version trước 5.7.6 và undefined 8 cho 5.7.6 trở lên. Tuy nhiên, nếu bạn đã cài đặt MySQL từ bản phân phối Debian, giống như trong Bước 1, folder dữ liệu được khởi tạo tự động; bạn không phải làm bất cứ điều gì. Nếu vẫn chạy lệnh, bạn sẽ thấy lỗi sau: Kết quả
Cuối cùng, hãy kiểm tra cài đặt MySQL. Bước 3 - Kiểm tra MySQLMySQL tất nhiên cần chạy tự động. Để kiểm tra điều này, hãy kiểm tra trạng thái của nó. undefined
undefined Bạn sẽ thấy kết quả giống như sau: Kết quả
Nếu MySQL không chạy, bạn có thể khởi động nó bằng undefined 9 . Để kiểm tra thêm, bạn có thể thử kết nối với database bằng công cụ undefined 0 , là một ứng dụng client cho phép bạn chạy các lệnh quản trị. Ví dụ: lệnh này cho biết kết nối với MySQL dưới dạng root ( undefined 1 ), nhắc nhập password ( undefined 2 ) và trả về version. undefined
undefined Bạn sẽ thấy kết quả giống như sau: Kết quả undefined 2 Nghĩa là MySQL đang hoạt động. Kết luậnĐến đây ta đã cài đặt MySQL cơ bản trên server. Dưới đây là một số ví dụ về các bước tiếp theo mà ta có thể thực hiện: Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support. Quickstart: Install SQL Server and create a database on Ubuntu
In this articleApplies to: - Linux In this quickstart, you install SQL Server 2017 (14.x) on Ubuntu 18.04. Then you can connect with sqlcmd to create your first database and run queries. For more information on supported platforms, see Release notes for SQL Server 2017 on Linux. In this quickstart, you install SQL Server 2019 (15.x) on Ubuntu 20.04. Then you can connect with sqlcmd to create your first database and run queries. For more information on supported platforms, see Release notes for SQL Server 2019 on Linux. In this quickstart, you install SQL Server 2022 (16.x) on Ubuntu 20.04 or 22.04. Then you can connect with sqlcmd to create your first database and run queries. For more information on supported platforms, see Release notes for SQL Server 2022 (16.x) on Linux. If you choose to have a preinstalled SQL Server VM on Ubuntu ready to run your production-based workload, then follow the best practices for creating the SQL Server VM. Azure Marketplace imagesYou can create your VM based on one of the following two Azure Marketplace images:
When you use these images, you avoid the installation step, and can directly configure the instance by providing the SKU and the
1 password needed to get started with SQL Server. SQL Server Azure VMs deployed on Ubuntu Pro using the above Marketplace images, are fully supported by both Microsoft and Canonical. You can configure SQL Server on Linux with mssql-conf, using the following command:
Azure Marketplace imageYou can create your VM based on the following Azure Marketplace image: Ubuntu 20.04. When you use this image, you avoid the installation step, and can directly configure the instance by providing the SKU and the
1 password needed to get started with SQL Server. SQL Server Azure VMs deployed on Ubuntu Pro using the above Marketplace images, are fully supported by both Microsoft and Canonical. You can configure SQL Server on Linux with mssql-conf, using the following command:
PrerequisitesIf you've previously installed a Community Technology Preview (CTP) or Release Candidate (RC) of SQL Server, you must first remove the old repository before following these steps. For more information, see Configure repositories for installing and upgrading SQL Server on Linux. The Windows Subsystem for Linux isn't supported as an installation target for SQL Server. For other system requirements, see . Install SQL ServerTo configure SQL Server on Ubuntu, run the following commands in a terminal to install the mssql-server package.
At this point, SQL Server is running on your Ubuntu machine and is ready to use! Disable the
1 account as a best practice When you connect to your SQL Server instance using the
1 account for the first time after installation, it's important for you to follow these steps, and then immediately disable the
1 login as a security best practice.
To create a database, you need to connect with a tool that can run Transact-SQL statements on SQL Server. The following steps install the SQL Server command-line tools: sqlcmd utility and bcp utility. Use the following steps to install the mssql-tools18 on Ubuntu. Note
Connect locallyThe following steps use sqlcmd to locally connect to your new SQL Server instance.
Create and query dataThe following sections walk you through using sqlcmd to create a new database, add data, and run a simple query. For more information about writing Transact-SQL statements and queries, see Tutorial: Writing Transact-SQL Statements. Create a new databaseThe following steps create a new database named
5.
Insert dataNext create a new table,
7, and insert two new rows.
Select dataNow, run a query to return data from the
7 table.
Exit the sqlcmd command promptTo end your sqlcmd session, type
3:
0 Performance best practicesAfter installing SQL Server on Linux, review the best practices for configuring Linux and SQL Server to improve performance for production scenarios. For more information, see Performance best practices and configuration guidelines for SQL Server on Linux. In addition to sqlcmd, you can use the following cross-platform tools to manage SQL Server: Tool Description Azure Data Studio A cross-platform GUI database management utility. Visual Studio Code A cross-platform GUI code editor that run Transact-SQL statements with the mssql extension. PowerShell Core A cross-platform automation and configuration tool based on cmdlets. mssql-cli A cross-platform command-line interface for running Transact-SQL commands. Connect from WindowsSQL Server tools on Windows connect to SQL Server instances on Linux in the same way they would connect to any remote SQL Server instance. If you have a Windows machine that can connect to your Linux machine, try the same steps in this topic from a Windows command-prompt running sqlcmd. You must use the target Linux machine name or IP address rather than
0, and make sure that TCP port 1433 is open on the SQL Server machine. If you have any problems connecting from Windows, see . For other tools that run on Windows but connect to SQL Server on Linux, see:
Other deployment scenariosFor other installation scenarios, see the following resources:
For answers to frequently asked questions, see the SQL Server on Linux FAQ. Related content
Contribute to SQL documentationDid you know that you can edit SQL content yourself? If you do so, not only do you help improve our documentation, but you also get credited as a contributor to the page. |