![]() |
VOOZH | about |
By Hazel Virdó
staff technical writer
MySQL is an open-source database management system, commonly installed as part of the popular LAMP (Linux, Apache, MySQL, PHP/Python/Perl) stack. It uses a relational database and SQL (Structured Query Language) to manage its data.
The short version of the installation is simple: update your package index, install the mysql-server package, and then run the included security script.
- sudo apt-get update
- sudo apt-get install mysql-server
- mysql_secure_installation
This tutorial will explain how to install MySQL version 5.7 on a Ubuntu 16.04 server. However, if you’re looking to update an existing MySQL installation to version 5.7, you can read this MySQL 5.7 update guide instead.
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
former DO tech editor publishing articles here with the community, then founded the DO product docs team (https://do.co/docs). to all of my authors: you are incredible. working with you was a gift. love is what makes us great.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
If it occurs error because of broken MySQL package on Ubuntu 16.04. Just do this trick
# Purge all MySQL packages
sudo apt purge mysql*
sudo rm -rf /var/lib/mysql
sudo rm -rf /etc/mysql
# Reinstall MySQL
sudo apt install mysql-server mysql-client
Hey, There was no prompt for root password as mentioned in Step 1 :/(
This worked for me.
https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04
(use dd if=/dev/zero of=/swapfile bs=1M count=1024 if you have cheap plan, and don’t forget to purge and remove certain files as mentioned)
change mysqladmin -p -u root version to sudo mysqladmin -p -u root version to test the installation
sudo systemctl mysql start is the wrong command to manually start the service, the proper command is sudo systemctl start mysql
Thank You, worked for me :)
I haven’t had to mess with the swap file to get mysql to install, as a couple of others have commented. Must thank my lucky stars. :-)
Thanks for taking the time to explain the differences in initializing mysql_install_db between the 5.6 and 5.7 versions of mysql. I find this level of attention of detail in most D.O tutorials and is the reason why I respect them so much.
It’s also worth mentioning that many consider MariaDB a much better alternative to MySQL. Not sure why DO doesn’t have a tutorial for MariaDB and Ubuntu, but they do have one for MariaDB and CentOS. But anyway, the installation instructions and everything else is almost identical. I wrote a tutorial for both MySQL and MariaDB on Ubuntu on my website
buen tutorial
After I run ‘sudo apt-get install mysql-server’ Got this feedback:
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package mysql-server
What can be wrong here?
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.