Proxmox – Install a MySQL database server

1. install Mysql

Installation

connect on

[vz-120] # vzctl enter <mysql vm number>

install mysql server :

[vz-120] # apt-get install mysql-server-5.5

install mysql

[vz-120] # apt-get install mysql-server mysql-client 
(choose a password)

Configure access and bases

connect:

[vz-120] # mysql -p

create an admin user :

mysql> CREATE USER 'admin'@'localhost' IDENTIFIED BY '<password1>';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' ;
mysql> CREATE USER 'admin'@'%' IDENTIFIED BY '<password1>';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%';

create a database:

mysql> CREATE DATABASE web_db CHARACTER SET utf8 COLLATE utf8_general_ci;

create a web user who has only access on the web database :

mysql> GRANT ALL PRIVILEGES ON web_db.* To 'web'@'localhost' IDENTIFIED BY '<password2>';
 mysql> GRANT ALL PRIVILEGES ON web_db.* To 'web'@'%' IDENTIFIED BY '<password2>';

Configuration options
edit the configuration file:

# nano /etc/mysql/my.cnf

comment:

#bind-address = 127.0.0.1

reload mysql :

# /etc/init.d/mysql reload

2. Authorization on the HOST

Log on the host

execute:

[host] # iptables -A INPUT -s <mysql server ip> -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

tester la connexion :

[vz-120] # mysql -h <mysql server ip> -u admin -p

3. Set address

Set an address instead of an IP

[host] # nano /etc/hosts
add: 192.168.0.210   db.mydomain.ext

4. Install Phpmyadmin

Log on the web serveur, and install mysql server:

[vz-120] # apt-get install phpmyadmin php5-mysql

edit phpmyadmin config file:

[vz-120] # nano /etc/phpmyadmin/config.inc.php

put:

$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = '<sql server ip>';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['AllowNoPassword'] = true;

Change import file size, edit apache2 php config file and change the upload filesize. Here we set the size to 10 Mo:

[vz-120] # nano /etc/php5/apache2/php.ini
upload_max_filesize = 10M

 

 

Raphaël has written 45 articles

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>