====== MySQL Server: Installation & Management ====== The last fundamental piece of our web development environment is, of course, a database management system of choice: MySQL. ===== Install MySQL Server ===== Installing MySQL server is an easy task, simply issue the following commands in a Terminal window: <code> sudo apt-get install mysql-server </code> You will be asked to enter the password you wish to set for the mysql root user.\\ Once the install process has completed, verify that mysql is running using: <code> sudo service mysql status </code> Easy! Once you have installed MySQL, we should activate it with this command: <code> > sudo mysql_install_db </code> Finish up by running the MySQL set up script: <code> > sudo /usr/bin/mysql_secure_installation </code> ===== Let Your MySQL Server Be Accessed From the Outside ===== In order for other computers on your network to view the server you have created, you must first edit the "Bind Address". Begin by opening up Terminal to edit the my.cnf file. <code> sudo nano /etc/mysql/my.cnf </code> Change the line <code> bind-address = 127.0.0.1 </code> Changing the 127.0.0.1 to your IP address. ===== Add the Apache & PHP Modules ===== NEEDS TO BE ADAPTED <code> sudo apt-get install libapache2-mod-auth-mysql php5-mysql sudo nano /etc/php5/apache2/php.ini </code> Uncomment this line:\\ ;extension=mysql.so Like this:\\ extension=mysql.so Now just restart Apache and you are all set! ===== Change the root User's Password ===== It is fundamental to protect access to you databases, setting a root password is essential to this point. In case the installer didn't ask you for a password, or you left it blank, you'll have to set it "manually", here is how:\\ Note that the same procedure can be used to **change the current root user's password**. <code> mysql -u root mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword'); </code> Make sure to change yourpassword to a password of your choice. ===== Install (the latest) MySQL Workbench ===== You might be surprised here as the usual procedure for AMP installations usually would now instruct you how to install PhpMyAdmin, which is a fine MySQL management tool. Although my personal choice goes for MySQL Workbench. It has a lot more power and features than PhpMyAdmin and can even connect to remote hosts, providing a central management tool for your development environment as well as for your production one. That's only one of the many reasons that make me think it's much better suited on a development system that PhpMyAdmin. You could easily install MySQL Workbench from the "Software Manager" application. Unfortunately the version that is available in there is quite outdated, 5.2.40, while version 6.0.8 is available on the [[http://dev.mysql.com/downloads/tools/workbench/|MySQL website]]. === Download the .deb Installer === At the bottom of the [[http://dev.mysql.com/downloads/tools/workbench/|MySQL Worbench download page]], select "Unbuntu Linux" as the platform. Then download the **Ubuntu Linux 13.04 (x86, 64-bit), DEB** version (you might have to select the 32-bit version depending on your system's architecture). Also if you didn't apply the LMDE UP7 upgrade, you'd better use the 12.04 version. The insatller .deb file is now in your ~/Downloads directory, let's double click on it.\\ The "Packager Installation" app shows you the state of the process... Done ! You now have a "MySQL Worbench" icon in your "Applications > Programming" menu.