This is an old revision of the document!
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:
> sudo apt-get install mysql-server
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:
> sudo service mysql status
Easy! Once you have installed MySQL, we should activate it with this command:
> sudo mysql_install_db
Finish up by running the MySQL set up script:
> sudo /usr/bin/mysql_secure_installation
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.
> sudo nano /etc/mysql/my.cnf
Change the line
bind-address = 127.0.0.1
Changing the 127.0.0.1 to your IP address.
Add the Apache & PHP Modules
NEEDS TO BE ADAPTED
> sudo apt-get install libapache2-mod-auth-mysql php5-mysql > sudo nano /etc/php5/apache2/php.ini
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.
mysql -u root mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');
Make sure to change yourpassword to a password of your choice.