The MySQL server package will be installed on your server, along with dependencies and client libraries. Start MySQL by running the following command:
service mysqld start
After installing MySQL, it’s recommended that you run mysql_secure_installation, a program that helps secure MySQL. While running mysql_secure_installation, you will be presented with the opportunity to change the MySQL root password, remove anonymous user accounts, disable root logins outside of localhost, and remove test databases. It is recommended that you answer yes to these options. If you are prompted to reload the privilege tables, select yes.
By default, MySQL makes some assumptions about your server environment with respect to memory. To configure MySQL more conservatively, you’ll need to edit some settings in its configuration file. Your file should resemble the following:
If you made any changes to MySQL’s configuration, issue the following command to restart it:
service mysqld restart
MySQL will bind to localhost (127.0.0.1) by default. Please reference our secure MySQL remote access guide for information on connecting to your databases with local clients.
Allowing unrestricted access to MySQL on a public IP not advised, but you may change the address it listens on by modifying the bind-address parameter. If you decide to bind MySQL to your public IP, **you should implement firewall rules that only allow connections from specific IP addresses.
To generate a list of commands for the MySQL prompt type \h:
Note that all text commands must be first on line and end with ';'
Resetting the MySQL Root Password
If you’ve forgotten your root MySQL password, you may recover it by issuing the following commands:
The following part of the password reset will now be done within the MySQL client program:
Last, restart MySQL by issuing:
Ubuntu 10.04 LTS (Lucid)
If you made any changes to MySQL’s configuration, restart it by issuing the following command: