Sun said the deal will augment its position in the enterprise IT market, including the $15 billion database market.
Sun said MySQL's product line will help it give further support to the open-source Web application platform known as LAMP, the acronym for the Linux OS, Apache Web server, MySQL database and the PHP/Perl programming languages.
MySQL's strength in software-as-a-service offerings -- where applications are delivered over the Internet through a Web browser -- are also a plus, Sun said.
Databases are crucial for Internet-based applications in sites offering a range of services, from e-commerce to social networking.
Sun will pay $800 million in cash and $200 million in options, and the deal is expected to close by the end of Sun's 2008 fiscal year, which will end June 30.
Sun's acquisition ends speculation that MySQL might become a public company.
MySQL has become a formidable competitor to other relational database management systems from companies such as Oracle and IBM. The database itself is free for people to download, and MySQL makes money by offering subscription support packages.
MySQL CEO Marten Mickos -- whose business cards list him as "Open Sourcerer"-- will join Sun's executive team. MySQL will be folded into Sun's Software, Sales and Service organizations.
Sun said it plans to create a joint team to integrate MySQL, which has 400 employees in 25 countries, into its operations.
(Peter Sayer in Paris contributed to this story).