---
title: Create a MySQL server on Ubuntu
tags: Database
---
## Install MySQL on Ubuntu
* update the apt-get package index
* `sudo apt-get update`
* install the MySQL package
* `sudo apt-get install mysql-server`
* This utility prompts you to define the mysql root password and other security-related options, including removing remote access to the root user and setting the root password.
* `sudo mysql_secure_installation utility`
* Allow remote access
* `sudo ufw enable`
* `sudo ufw allow mysql`
* Start the MySQL service
* `sudo systemctl start mysql`
* Launch at reboot
* `sudo systemctl enable mysql`
* Configure interfaces
* `sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf`
* 127.0.0.1
* 0.0.0.0 ( All ip addresses. )
* Restart the mysql service
* `sudo systemctl restart mysql`
* Start the mysql shell
* `/usr/bin/mysql -u root -p`
* Set the root password
* `UPDATE mysql.user SET authentication_string = PASSWORD('password') WHERE User = 'root';`
* `FLUSH PRIVILEGES;`
* View users
* `use mysql`
* `select host, user from user;`
* `UPDATE mysql.user SET Host='%' WHERE Host='localhost' AND User='username';`
* `FLUSH PRIVILEGES;`
* if root doesn't work, create another user manually, and set ==localhost== to ==%==
[Install MySQL Server on the Ubuntu](https://docs.rackspace.com/support/how-to/install-mysql-server-on-the-ubuntu-operating-system/)
[Your password does not satisfy the current policy requirements](https://stackoverflow.com/questions/43094726/your-password-does-not-satisfy-the-current-policy-requirements)